CN115934546A - Go language-based block chain integration test method and system - Google Patents
Go language-based block chain integration test method and system Download PDFInfo
- Publication number
- CN115934546A CN115934546A CN202211619412.4A CN202211619412A CN115934546A CN 115934546 A CN115934546 A CN 115934546A CN 202211619412 A CN202211619412 A CN 202211619412A CN 115934546 A CN115934546 A CN 115934546A
- Authority
- CN
- China
- Prior art keywords
- test
- block chain
- tested
- case
- gosdk
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The application discloses a Go language-based block chain integration test method, which specifically comprises the following steps: initializing a configuration file by using a specified GoSDK dependency; determining a block chain cluster to be tested according to the configuration file, sending a deployment instruction by using a GoSDK (GoSDK), deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested; generating a test case according to the configuration file, and sending a test instruction by using the GoSDK to test the block chain cluster to be tested by using the test case; and collecting test logs and statistical results. The method is set based on the Go language, can directly test the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system by using the GoSDK without calling, reduces the efficiency loss caused by transferring the remote calling command to other languages in the test process, and simultaneously reduces the labor cost consumed by system maintenance.
Description
Technical Field
The application belongs to the technical field of block chain testing, and particularly relates to a Go language-based block chain integration testing method and system.
Background
In the integrated test of the existing blockchain system, python or Java is generally used as a remote call command language for execution, but the SDK of the server side uses GoSDK or JavaSDK. For the service end of the JavaSDK, since the remote call command also uses Java, the test can be directly carried out through the Java. However, for the service end of the GoSDK, a layer of transfer is needed in the middle, the remote call command sent by the GoSDK is transferred to the Python language, and then the block chain system is really called again through the Python language. Such an implementation is a significant compromise in operational efficiency and increases the maintenance cost of the test system.
In addition, due to the language characteristics or lack of corresponding dependent libraries, the implementation of some functions (such as contracts, storage, and cryptography) on the blockchain is complicated or even impossible, which increases the difficulty in implementing and developing the test of the blockchain system through the Python language.
Therefore, a method and a system for testing blockchain integration based on Go language are needed, which can directly perform integration test on a blockchain system and reduce efficiency loss of call transfer.
Disclosure of Invention
Based on the above-mentioned shortcomings and drawbacks of the prior art, an object of the present invention is to solve at least one or more of the above-mentioned problems of the prior art, in other words, to provide a method and system for testing integration of a block chain based on Go language, which meets one or more of the above-mentioned needs.
In order to achieve the purpose, the invention adopts the following technical scheme:
in a first aspect, the present invention provides a Go language-based blockchain integration test method, which is applied to a blockchain cluster, and specifically includes the steps of:
specifying GoSDK dependency, and initializing a configuration file;
determining a block chain cluster to be tested according to the configuration file, sending a deployment instruction by using a GoSDK (GoSDK), deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested;
generating a test case according to the configuration file, and sending a test instruction by using the GoSDK to test the block chain cluster to be tested by using the test case;
and collecting test logs and statistical results.
The testing method based on the Go language can complete the tasks of testing the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system, and can complete the testing tasks of the block chain cluster with higher performance by utilizing the adaptability of the Go language and the block chain cluster, and the transfer is not needed in the calling process, so that the maintenance cost of the testing system is reduced.
As a further improvement, the method further comprises:
the configuration file comprises a fuzzy test rule, and the fuzzy test rule specifies the number, the type and the value range of input parameters of one or more tests;
when generating a test case according to the configuration file, sending a test instruction by using a GoSDK, and executing a fuzzy test on the block chain cluster to be tested by using the test case according to a fuzzy test rule;
the fuzzy test specifically comprises the steps of generating fuzzy test parameters according to a fuzzy test rule, and generating a plurality of split test cases according to the fuzzy test parameters;
and sending a test instruction by using the GoSDK, and testing the block chain clusters to be tested by using a plurality of split test cases respectively.
The improved method adds a fuzzy test process to the method of the invention, generates test input parameters of specifications such as the total length of the appointed field, interval rules and the like in a certain splitting mode, and solves the defect that the traditional block chain test method can only manually set the test input parameters. The fuzzy generated test input parameters which meet the specification are used for carrying out large-scale test, the load of the block chain system and the data parameter boundary of the measuring function can be effectively tested, and the automation degree and the expandability of the block chain system test are provided.
As a further improvement, the method further comprises:
generating test cases according to the configuration file, and setting case grades for each test case;
and executing the test on the block chain cluster to be tested by using the test case, and preferentially executing the test on the block chain cluster to be tested by using the test case with the high case level or the low case level according to the case level, or selecting a certain case level range and executing the test on the block chain cluster to be tested only by using the test case in the case level range.
The improved method sets the case grades for the test cases respectively, and the test cases can be executed with a certain priority according to the level of the case grades or within a certain case grade range when the test is executed, so that the waiting verification time of development and modification of a test product is reduced, and the test efficiency is improved.
As a preferred scheme, initializing the configuration file specifically includes:
pre-generating a configuration structure;
the input configuration command is read, and the content of the configuration command is serialized to the configuration structure.
As a further improvement, the method further comprises:
after determining the block chain cluster to be tested according to the configuration file, retrieving and comparing the existing block chain cluster to determine whether the block chain cluster to be tested is deployed;
if so, sending a detection instruction by using the GoSDK, detecting the cluster state of the block chain to be detected, and if the detection fails, collecting a test log and a statistical result;
if not, a GoSDK is used for sending a deployment instruction, and each node of the block chain cluster to be tested is deployed to generate the block chain cluster to be tested.
As a further improvement, the method further comprises:
inserting a test probe into the test case when the test case is generated according to the configuration file;
when the test case is used for testing the block chain cluster to be tested, detecting whether the state of the block chain is abnormal or not according to the test probe;
if the block chain state continuous abnormal time exceeds a preset time threshold, determining that the environment is abnormal, and terminating the test.
In a second aspect, the present invention further provides a system for testing the integration of blockchain based on Go language, which is used for performing the integration test on a blockchain cluster, and the system includes:
the initialization module is used for designating GoSDK dependence, acquiring input parameters of the configuration file and initializing the configuration file according to the input parameters;
the node deployment module is used for determining the block chain cluster to be tested according to the configuration file, sending a deployment instruction by using the GoSDK, deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested;
the test plan module generates a test case according to the configuration file;
the script execution module is used for sending a test instruction by using the GoSDK to execute a test on the block chain cluster to be tested by using a test case;
and the log module is used for collecting the test logs and the statistical results.
The testing system realized based on the Go language can complete the testing of the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system by applying the method. The testing task of the block chain cluster is completed with higher performance by utilizing the adaptability of the Go language and the block chain cluster, and the transfer is not needed in the calling process, so that the maintenance cost of the testing system is reduced.
As a further improved scheme, the script execution module comprises a rule analysis module, a use case generation module and a fuzzy test module;
the rule analysis module is used for analyzing the configuration file to generate a fuzzy test rule, and the fuzzy test rule specifies the number, the type and the value range of input parameters of one or more tests;
the case generation module is used for generating a fuzzy test parameter according to the fuzzy test rule and generating a plurality of split test cases according to the fuzzy test parameter;
the fuzzy test module is used for sending a test instruction by using the GoSDK and testing the block chain cluster to be tested by using a plurality of split test cases respectively.
Similar to the improvement of the fuzzy test in the method, the rule analysis module, the case generation module and the fuzzy test module are arranged in the script execution module, so that the capability of the fuzzy test is increased for the test system, test input parameters of specifications such as the total length of the designated field, interval rules and the like are generated in a certain splitting mode, and the defect that the traditional block chain test system can only manually set the test input parameters is overcome. The fuzzy generated test input parameters which meet the specification are used for carrying out large-scale test, the load of the block chain system and the data parameter boundary of the measuring function can be effectively tested, and the automation degree and the expandability of the block chain system are provided.
In a third aspect, the invention also provides a computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the computer program implementing the method as claimed in any one of the preceding claims when executed by the processor.
In a fourth aspect, the invention also provides a computer-readable storage medium, in which a computer program is stored, which computer program, when executed by a processor, performs the method of any one of the above.
Compared with the prior art, the invention has the beneficial effects that:
the method and the system are set based on Go, the GoSDK can be used for directly testing the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system without calling, the efficiency loss caused by transferring the remote calling command to other languages in the testing process is reduced, and meanwhile, the labor cost consumed by system maintenance is reduced.
The method and the system of the invention also utilize the characteristics of the Go language and the adaptability of the Go language to the block chain system, realize the functions of case generation and fuzzy test which are difficult to realize by the Python language, conveniently and directly generate the test input parameters which meet the specification, carry out mass test by using the test input parameters, effectively test the load of the block chain system and determine the data parameter boundary of the function, and provide the degree of automation and the expandability of the block chain system test.
The method and the system can also divide the test priority according to the case grade during the test, and can firstly run some smoking cases (namely important basic function cases) in the development or repair process so as to verify the basic correctness of the smoking cases and greatly shorten the time for waiting for verification. The fuzzy test function of the method and the system is combined, so that the mass test can be carried out while the test speed is achieved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a block chain integration testing method based on Go language according to an embodiment of the present application;
FIG. 2 is a flowchart of an ambiguous use case generation method provided in an embodiment of the present application;
fig. 3 is a block diagram of a system for testing blockchain integration based on the Go language according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The following description provides embodiments of the present application, where different embodiments may be substituted or combined, and thus the present application is intended to include all possible combinations of the same and/or different embodiments described. Thus, if one embodiment includes features a, B, C and another embodiment includes features B, D, this application should also be construed as including embodiments that include all other possible combinations of one or more of a, B, C, D, although such embodiments may not be explicitly recited in the following text.
The following description provides examples, and does not limit the scope, applicability, or examples set forth in the claims. Changes may be made in the function and arrangement of elements described without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as appropriate. For example, the described methods may be performed in an order different than the order described, and various steps may be added, omitted, or combined. Furthermore, features described with respect to some examples may be combined into other examples.
The application provides a Go language-based block chain integration test method, which is used for testing a block chain cluster in the development, maintenance or repair process, and specifically comprises the following steps:
s1, firstly, goSDK dependency is designated, and a configuration file is initialized.
The GoSDK dependency is an API command applied by the method, and defines the contract deployment, the instruction used for calling the contract and the parameter transmission format of different block chains.
The configuration file is used for appointing the version number, the deployment mode and the version number of the test script of the block chain cluster to be tested; and respectively calling which scripts, how to call the scripts and counting which results in the process of controlling the deployment and the test of the block chain cluster to be tested.
As another example, the configuration file may also specify additional flow policies for the test process, such as remote invocation, retry polling policies, https, and credential configuration switches, as well as custom log output policies.
The remote calling mode can support three modes of rpc, grpc and websocket, and the port numbers of the corresponding modes are configured in the configuration file, so that the corresponding modes can be used for requesting calling.
The retransmission polling strategy is configured to support retransmission polling by default, and parameters such as retransmission times, polling time intervals and polling times can be configured in a configuration file.
In some embodiments of the present application, as a preferred implementation manner, the method for initializing the configuration file may specifically include the following steps:
s11, pre-generating a configuration structure body, wherein the configuration structure body is a data paragraph or a table with a plurality of parameter spaces, and the parameter spaces of the configuration structure body are left empty in a pre-generated initial state.
S12, reading an input configuration instruction, wherein the configuration instruction can be an independently input instruction segment, and can also be a toml or yaml file with a specified format. After the configuration command is read, the content in the configuration command is serialized into the parameter space of the configuration structure body, and the serialized configuration structure body completes initialization.
Based on the additional flow strategy of the test process specified in the configuration file in the above partial embodiment, rpc, websocket, and grpc services may also be respectively initialized in the configuration structure according to the node information and the port number of the configuration instruction. And judging whether the request needs to be sent in an https or certificate mode according to the security policy information in the configuration instruction, and if so, taking the relevant certificate when the request is sent. Or according to the polling strategy in the configuration instruction, strategy configuration is carried out, the strategy configuration comprises the retransmission times and the time interval after each retransmission, and the initialized rpc, websocket and grpc services are used for carrying out remote communication during polling.
And S2, determining the block chain cluster to be tested according to the configuration file, sending a deployment instruction by using the GoSDK, deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested.
In step S2, each parameter in the configuration file is read, a node deployment scheme is determined according to the parameter, which version is selected for each node in the block chain cluster to be tested, and then a corresponding node deployment instruction is issued using the API of the GoSDK. And after each node is deployed according to the configuration file, completing the deployment of the block chain cluster to be tested.
In some embodiments of the present application, since the blockchain cluster to be tested may have already been deployed without repeated deployment, in order to save testing time, as a further improved scheme, the following improvements are made to the method:
after determining the block chain cluster to be tested according to the configuration file, retrieving and comparing the existing block chain cluster which is already deployed, and determining whether the block chain cluster to be tested is already deployed. The retrieval comparison needs to compare each node of the whole block chain cluster, and if each node and structure of a certain block chain cluster are the same as those of the current block chain cluster to be detected, the block chain cluster to be detected is considered to be deployed completely.
The above search and comparison may be performed independently for each node of each blockchain cluster, or a group of single identification codes may be generated in advance according to each node and structure of each blockchain cluster, and the identification codes of the blockchain clusters are stored in one location. If each node and structure of a certain blockchain cluster are the same as those of the currently-to-be-tested blockchain cluster, the generated identification code is the same as one of the currently-stored identification codes, so that the two blockchain clusters can be considered to have the same structure, and the block chain cluster to be tested can be considered to be already deployed.
After retrieval, if the block chain cluster to be detected is determined to be deployed completely, a GoSDK is used for sending a detection instruction to detect whether the state of the block chain cluster to be detected is normal. If the detection returns that the block chain cluster state is normal, the detection returns can be directly used for the subsequent test process. If the detection fails and no return or return error is obtained, collecting logs and redeploying the block chain cluster to be detected.
After retrieval, if the block chain cluster to be tested is determined not to be deployed completely, if a deployment instruction is sent out by using the GoSDK in the normal process, each node of the block chain cluster to be tested is deployed, and the block chain cluster to be tested is generated.
And after the block chain cluster is deployed, performing step S3, generating a test case according to the configuration file, and sending a test instruction by using the GoSDK to execute a test on the block chain cluster to be tested by using the test case.
Test cases include how the test chooses the script to execute, in what order to execute, what parameters to use for each execution are passed into the blockchain system, and what return or output results should be obtained.
When the test case is used for executing the test on the block chain cluster to be tested, the block chain to be tested executes the service according to the script and the transmitted parameters of the test case, and outputs a corresponding result and a test log.
When the script is formally executed, firstly, the content of the test suite is initialized, whether the current script should be called in the plan is judged, and then the processes of the front operation, the test content, the rear operation and the like of the script are sequentially executed.
In some embodiments of the present application, as a further improvement, the method further inserts a test probe into the test case when the test case is generated according to the configuration file;
when the test probe executes the test on the block chain cluster to be tested by using the test case, the state of the block chain is detected at variable time, and if the abnormal state of the block chain is detected, the time for starting the abnormality is recorded. After detecting the state of the block chain by the probe for the next test, judging whether the block chain cluster is recovered to be normal, if not, judging whether the current continuous abnormal time exceeds a preset time threshold, if so, determining that the environment is abnormal, marking a corresponding script as an error, counting error scripts after continuously completing the test, considering the modification of the test scheme, or directly terminating the test.
And S4, obtaining the back reference of the block chain system in the testing process of S3, determining a testing result according to the back reference and the comparison result of the testing case, collecting a testing log, and counting the results of all tests.
Step S4, generating an all test report according to the mobile phone test result and the test log, first generating a designated json file text, and then converting the json file text into a test report of a front-end page by an all tool.
The overall flow chart of the method is shown in fig. 1, the testing method based on Go language can complete the task of testing the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system, and the testing task of the block chain cluster can be completed with higher performance by utilizing the adaptability of the Go language and the block chain cluster, and the transfer is not needed in the calling process, so that the maintenance cost of the testing system is reduced.
In some embodiments of the present application, in order to improve the capability of the method of the present application to perform batch tests and test parameter boundaries, as shown in the flowchart of the fuzzy case generating method in fig. 2, the method is further modified as follows:
the configuration file also comprises a series of fuzzy test rules, and the fuzzy test rules specify the number, the types and the value ranges of the input parameters of one or more tests. In addition, the fuzzy test rule can add an interval rule for each parameter, for example, a data needs to be marked by beginning a certain specific field, a specific derivation relationship needs to be provided between a first section and a second section of the data, and the like.
When generating a test case according to the configuration file, sending a test instruction by using a GoSDK, and executing a fuzzy test on the block chain cluster to be tested by using the test case according to a fuzzy test rule;
the fuzzing test specifically comprises the steps of generating fuzzing test parameters according to a fuzzing test rule, and generating a plurality of split test cases by the fuzzing test parameters.
The step is divided into two aspects, and in the first aspect, parameter analysis is carried out according to the incoming parameters of the test cases. A general mode is adopted in parameter analysis, and examples are as follows: if two data are to be entered for scaling, the two data need to be of the same type, i.e. both int or float types. While the incoming parameters cannot directly use a certain type in parameter resolution, but use a generic T, which can receive any type of parameters.
And in the second aspect, the fuzzy test rule is required to be read, whether the incoming parameters meet the requirements is checked according to the fuzzy test rule, when the incoming parameters pass the checking, the use cases are split, and a split test use case is generated by using a plurality of groups of incoming parameters meeting the requirements.
And sending a test instruction by using the GoSDK, and testing the block chain cluster to be tested by using the generated split test cases respectively, so that various different parameter execution scripts are generated by using the fuzzy test according to rules, and a result is returned. And when the script fails to run, displaying related call stacks and data error reporting information.
The improved method adds a fuzzy test process to the method of the invention, generates test input parameters with specified specifications such as field total length, interval rule and the like in a certain splitting mode, and solves the defect that the traditional block chain test method can only manually set the test input parameters. The fuzzy generated test input parameters which meet the specification are used for carrying out large-scale test, the load of the block chain system and the data parameter boundary of the measuring function can be effectively tested, and the automation degree and the expandability of the block chain system test are provided.
In other embodiments of the present application, the method is further modified as follows:
and when the test cases are generated according to the configuration file, setting a case grade for each test case.
Further, the use case level can be set in the following two ways:
each test case has a test name, and case grade distinction is performed by planning a specified test name, for example, a case name suffix of each test case is specified and a corresponding grade is added. And when the test case is operated, judging according to the case name, and skipping which does not belong to the grade range.
Or, marking the corresponding grade through the annotation form when generating the test case, and then setting the selectable parameter for screening the grade of the test case in the running test command when running the case to judge whether to run the case of each grade.
And executing the test on the block chain cluster to be tested by using the test case, and preferentially executing the test on the block chain cluster to be tested by using the test case with the high case level or the low case level according to the case level, or selecting a certain case level range and executing the test on the block chain cluster to be tested only by using the test case in the case level range.
In the execution of daily test activities, if functional problems of products are found, developers can make corresponding repairs, and then rewrite the running case for verification. However, in this process, the repair of the developer may cause new problems, and if it takes 6 hours to run all the scripts, the cost of waiting for verification is high. The division of the case grades sets a certain test case at a certain level in the process of writing the test case, and only the test cases at certain levels can be specified to run or run the full amount of cases when the test case is run. Therefore, some smoking cases (namely important basic function cases) can be operated after each development and repair to verify the basic correctness of the smoking cases, so that the time for waiting for verification is greatly shortened. And after the plurality of developed repairs pass, uniformly running the full quantity of cases, and then circularly iterating.
The improved method sets the case grades for the test cases respectively, and the test cases can be executed with a certain priority according to the level of the case grades or within a certain case grade range when the test is executed, so that the waiting verification time of development and modification of a test product is reduced, and the test efficiency is improved.
In addition, as a better improvement scheme, in some embodiments of the present application, the method of the present application has the above-mentioned improvements of adding the fuzzy test process and setting and executing the case level for each test case, and sets the case level for the split test cases on the basis of testing the block chain cluster with a large number of randomly generated split test cases, and executes the split test cases according to the case levels respectively. By combining the two improved methods, batch testing can be performed, meanwhile, the testing time consumption is reduced, and therefore better testing efficiency is obtained.
In a second aspect, the present invention further provides a system for testing the integration of a blockchain based on Go language, which is used for performing the above method to perform the integration test on a blockchain cluster, and a block diagram of the system structure of the system is shown in fig. 3, where the system includes:
and the configuration module is used for specifying GoSDK dependency, acquiring input parameters of the configuration file and initializing the configuration file according to the input parameters.
And the node deployment module is used for determining the block chain cluster to be tested according to the configuration file, sending a deployment instruction by using the GoSDK, deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested. The node deployment module is further provided with an external calling interface and a detection probe, the external calling interface is used for calling externally stored block chain nodes, and the detection probe is used for placing detection points in block chain link points.
And the test plan module is used for generating a test case according to the configuration file. The test planning module can generate various script scheduling strategies for forming the test cases, and based on the improvement of the test case grade in the method, the test planning module can also set the case grade for the generated test cases.
And the script execution module can generate a test suite, custom assertion and a data driving generator and carry out version control on the executed script. The script execution module is used for sending a test instruction by using the GoSDK so as to execute a test on the block chain cluster to be tested by using a test case;
and the log module is used for collecting the test logs and the statistical results. In some embodiments, the log module includes an all listener, a log format converter, a result analysis, a log presentation plug-in.
The testing system realized based on the Go language can complete the testing of the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system by applying the method. The testing task of the block chain cluster is completed with higher performance by utilizing the adaptation of the Go language and the block chain cluster, and the transfer is not needed in the calling process, so that the maintenance cost of the testing system is reduced.
Corresponding to the improvement of the fuzzy test method, in some embodiments of the application, the script execution module further includes a rule parsing module, a use case generating module and a fuzzy test module;
the rule analysis module is used for analyzing the configuration file to generate a fuzzy test rule, and the fuzzy test rule specifies the number, the type and the value range of input parameters of one or more tests;
the case generation module is used for generating a fuzzy test parameter according to the fuzzy test rule and generating a plurality of split test cases according to the fuzzy test parameter;
the fuzzy test module is used for sending a test instruction by using the GoSDK and testing the block chain cluster to be tested by using a plurality of split test cases respectively.
Similar to the improvement of the fuzzy test in the method, the rule analysis module, the case generation module and the fuzzy test module are arranged in the script execution module, so that the capability of the fuzzy test is increased for the test system, test input parameters of specifications such as the total length of the designated field, interval rules and the like are generated in a certain splitting mode, and the defect that the traditional block chain test system can only manually set the test input parameters is overcome. The fuzzy generated test input parameters which meet the specification are used for carrying out large-scale test, the load of the block chain system and the data parameter boundary of the measuring function can be effectively tested, and the automation degree and the expandability of the block chain system are provided.
The method and the system are set based on Go, the GoSDK can be used for directly testing the nodes, the network, the consensus, the contract, the storage and the cryptography of the block chain system without calling, the efficiency loss caused by transferring the remote calling command to other languages in the testing process is reduced, and meanwhile, the labor cost consumed by system maintenance is reduced.
Secondly, the method and the system of the invention also utilize the characteristics of the Go language and the adaptability of the Go language to the block chain system, realize the functions of case generation and fuzzy test which are difficult to realize by the Python language, conveniently and directly generate the test input parameters which meet the specification, carry out mass test by using the test input parameters, effectively test the load of the block chain system and determine the data parameter boundary of the function, and provide the degree of automation and the expandability of the block chain system test.
In addition, the method and the system can also divide the test priority according to the case grade during testing, and can firstly run some smoking cases (namely important basic function cases) in the development or repair process so as to verify the basic correctness of the smoking cases and greatly shorten the time for waiting for verification. The fuzzy test function of the method and the system is combined, so that the mass test can be carried out while the test speed is achieved.
Those skilled in the art can clearly understand that the technical solutions of the embodiments of the present application can be implemented by means of software and/or hardware. The term "unit" in this specification refers to software and/or hardware capable of performing a specific function independently or in cooperation with other components, wherein the hardware may be, for example, a Field-Programmable Gate Array (FPGA), an Integrated Circuit (IC), or the like.
Embodiments of the present application also provide an electronic device comprising at least one processor, at least one memory, and a computer program stored on the memory and executable on the processor.
The processor may include one or more processing cores, among others. The processor, using various interfaces and lines connecting various parts throughout the electronic device, performs various functions and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory, and calling data stored in the memory. Optionally, the processor may be implemented in at least one hardware form of DSP, FPGA, and PLA. The processor may integrate one or a combination of a CPU, GPU, modem, etc. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen.
The memory may include a RAM or a ROM. Optionally, the memory includes a non-transitory computer readable medium. The memory may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory may optionally be at least one memory device located remotely from the processor. The memory, which is a computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an application program for the above integration test.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the methods of any of the embodiments described above. The computer-readable storage medium may include, but is not limited to, any type of disk including floppy disks, optical disks, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nanosystems (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art will recognize that the embodiments described in this specification are preferred embodiments and that acts or modules referred to are not necessarily required for this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some service interfaces, devices or units, and may be an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the embodiments of the present application also provide a computer program product, which when run on a computer, causes the computer to execute and implement all or part of the procedures in the above method embodiments.
This implementation may be accomplished by a computer program that may be stored in a computer-readable storage medium and that, when executed by a processor, may implement the steps of the various method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or apparatus capable of carrying computer program code to a photographing apparatus/terminal device, a recording medium, computer Memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, optical data storage device, etc. The computer-readable storage medium referred to herein may be a non-volatile storage medium, in other words, a non-transitory storage medium.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The above description is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure should not be limited thereby. That is, all equivalent changes and modifications made in accordance with the teachings of the present disclosure are intended to be included within the scope of the present disclosure. Embodiments of the present disclosure will be readily apparent to those skilled in the art from consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
Claims (10)
1. A Go language-based block chain integration test method is applied to a block chain cluster and is characterized by comprising the following steps:
specifying GoSDK dependency, and initializing a configuration file;
determining a block chain cluster to be tested according to the configuration file, sending a deployment instruction by using a GoSDK, deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested;
generating a test case according to the configuration file, sending a test instruction by using a GoSDK, and testing the to-be-tested block chain cluster by using the test case;
and collecting test logs and statistical results.
2. The method for testing integration of blockchains based on Go language as claimed in claim 1, wherein the method further comprises:
the configuration file comprises a fuzzy test rule, and the fuzzy test rule specifies the number, the type and the value range of input parameters of one or more tests;
when generating a test case according to the configuration file, sending a test instruction by using a GoSDK, and executing a fuzzy test on the block chain cluster to be tested by using the test case according to the fuzzy test rule;
the fuzzy test specifically comprises the steps of generating fuzzy test parameters according to the fuzzy test rule, and generating a plurality of split test cases according to the fuzzy test parameters;
and sending a test instruction by using the GoSDK, and testing the block chain cluster to be tested by using the split test cases respectively.
3. The method for testing integration of blockchains based on Go language as claimed in claim 1, wherein the method further comprises:
generating test cases according to the configuration file, and setting case grades for each test case;
and executing the test on the block chain cluster to be tested by using the test case, preferentially executing the test on the block chain cluster to be tested by using the test case with the high case level or the low case level according to the case level, or selecting a certain case level range, and executing the test on the block chain cluster to be tested only by using the test case in the case level range.
4. The method for testing integration of blockchains based on Go language according to any one of claims 1 to 3, wherein the initializing the configuration file specifically includes:
pre-generating a configuration structure;
and reading the input configuration command, and serializing the content of the configuration command to the configuration structure.
5. The method for testing integration of blockchains based on Go language as claimed in claim 1, wherein the method further comprises:
after determining the block chain cluster to be tested according to the configuration file, retrieving and comparing the existing block chain cluster to determine whether the block chain cluster to be tested is deployed;
if so, sending a detection instruction by using the GoSDK, detecting the cluster state of the block chain to be detected, and if the detection fails, collecting a test log and a statistical result;
if not, using GoSDK to send a deployment instruction, deploying each node of the block chain cluster to be tested, and generating the block chain cluster to be tested.
6. The method for testing integration of blockchains based on Go language as claimed in claim 1, wherein the method further comprises:
inserting a test probe into the test case when the test case is generated according to the configuration file;
when the test case is used for testing the block chain cluster to be tested, detecting whether the state of the block chain is abnormal or not according to the test probe;
and if the block chain state continuous abnormal time exceeds a preset time threshold, determining that the environment is abnormal, and terminating the test.
7. A system for testing integration of blockchain based on Go language, the system comprising:
the initialization module is used for appointing GoSDK dependence, acquiring input parameters of a configuration file and initializing the configuration file according to the input parameters;
the node deployment module is used for determining a block chain cluster to be tested according to the configuration file, sending a deployment instruction by using a GoSDK (GoSDK), deploying each node of the block chain cluster to be tested and generating the block chain cluster to be tested;
the test plan module generates a test case according to the configuration file;
the script execution module is used for sending a test instruction by using GoSDK and executing a test on the block chain cluster to be tested by using the test case;
and the log module is used for collecting test logs and statistical results.
8. The system of claim 7, wherein the script execution module comprises a rule parsing module, a use case generation module and a fuzzy test module;
the rule analysis module is used for analyzing the configuration file to generate a fuzzy test rule, and the fuzzy test rule specifies the number, the type and the value range of input parameters of one or more tests;
the case generation module is used for generating a fuzzy test parameter according to the fuzzy test rule and generating a plurality of split test cases according to the fuzzy test parameter;
and the fuzzy test module is used for sending a test instruction by using the GoSDK and testing the block chain cluster to be tested by using the split test cases respectively.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program when executed by the processor implementing the method of any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the method of any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211619412.4A CN115934546A (en) | 2022-12-16 | 2022-12-16 | Go language-based block chain integration test method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211619412.4A CN115934546A (en) | 2022-12-16 | 2022-12-16 | Go language-based block chain integration test method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115934546A true CN115934546A (en) | 2023-04-07 |
Family
ID=86648746
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211619412.4A Pending CN115934546A (en) | 2022-12-16 | 2022-12-16 | Go language-based block chain integration test method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115934546A (en) |
-
2022
- 2022-12-16 CN CN202211619412.4A patent/CN115934546A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10534699B2 (en) | Method, device and computer program product for executing test cases | |
CN108628748B (en) | Automatic test management method and automatic test management system | |
US20090019427A1 (en) | Method and Apparatus for Providing Requirement Driven Static Analysis of Test Coverage for Web-Based, Distributed Processes | |
CN105045602A (en) | Method and device for constructing Hadoop application development framework and electronic device | |
CN109359020A (en) | Start time test method and device, computer installation and storage medium | |
CN107045475B (en) | Test method and device | |
CN110674047A (en) | Software testing method and device and electronic equipment | |
CN114138674A (en) | Automatic testing method and device and computer equipment | |
CN112817869A (en) | Test method, test device, test medium, and electronic apparatus | |
CN115827436A (en) | Data processing method, device, equipment and storage medium | |
CN113505895B (en) | Machine learning engine service system, model training method and configuration method | |
CN109558315A (en) | The determination method, device and equipment of test scope | |
CN111400171B (en) | Interface testing method, system and device and readable storage medium | |
CN109977005B (en) | End-to-end test method, medium, device and computing equipment | |
CN116955193A (en) | Interface testing method, device, equipment and storage medium | |
CN112463574A (en) | Software testing method, device, system, equipment and storage medium | |
CN116016270A (en) | Switch test management method and device, electronic equipment and storage medium | |
CN115934546A (en) | Go language-based block chain integration test method and system | |
CN115687129A (en) | Coverage rate report generation method and device, storage medium and computer equipment | |
CN115248783A (en) | Software testing method, system, readable storage medium and computer equipment | |
CN108334313A (en) | Continuous integrating method, apparatus and code management system for large-scale SOC research and development | |
CN113485919A (en) | Test method, test device and computer readable storage medium | |
CN112380118A (en) | Unit testing method, unit testing device, medium and electronic equipment | |
CN112328281A (en) | Server firmware refreshing method and device | |
CN111338968A (en) | Project function module debugging method, device, medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |