CN115858257A - Random test method and device for host operation - Google Patents

Random test method and device for host operation Download PDF

Info

Publication number
CN115858257A
CN115858257A CN202111137910.0A CN202111137910A CN115858257A CN 115858257 A CN115858257 A CN 115858257A CN 202111137910 A CN202111137910 A CN 202111137910A CN 115858257 A CN115858257 A CN 115858257A
Authority
CN
China
Prior art keywords
random test
host
random
name
class
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
Application number
CN202111137910.0A
Other languages
Chinese (zh)
Inventor
陶颖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202111137910.0A priority Critical patent/CN115858257A/en
Publication of CN115858257A publication Critical patent/CN115858257A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Test And Diagnosis Of Digital Computers (AREA)

Abstract

The embodiment of the application provides a random test method and a random test device for host operation, wherein the method comprises the following steps: determining the identity identification number ID of a host to be tested; acquiring a method name of a random test method; and calling the random test method based on the method name to carry out random test on the host operation corresponding to the ID. Through the application, the problem that random test modes are single due to the fact that the random test modes in the prior art are all tested for the Android terminal is solved.

Description

Random test method and device for host operation
Technical Field
The present application relates to the field of random testing technologies, and in particular, to a random testing method and apparatus for host operations.
Background
In non-functional testing, random testing is an important direction, and is an effective means and process for ensuring the robustness and coverage integrity of products. The existing random test modes are all for testing an Android (Android) terminal, and no mode exists for randomly testing the operation of a host in openstack (an open source cloud computing management platform project).
Disclosure of Invention
An embodiment of the present application aims to provide a method and an apparatus for randomly testing host operations, so as to solve a problem that random testing modes are relatively single because all the random testing modes in the prior art are tested for an Android terminal. The specific technical scheme is as follows:
in a first aspect of this embodiment, there is provided a method for random testing of host operations, including: determining the identity identification number ID of a host to be tested; acquiring a method name of a random test method; and calling the random test method based on the method name to carry out random test on the host operation corresponding to the ID.
In a second aspect of this embodiment, there is also provided a random test apparatus operated by a host, including: the determining module is used for determining the identity identification number ID of the host to be tested; the acquisition module is used for acquiring the method name of the random test method; and the test module is used for calling the random test method based on the method name so as to carry out random test on the host operation corresponding to the ID.
In yet another aspect of this embodiment, there is also provided a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to perform any of the above described methods of random testing of host operations.
In yet another aspect of this embodiment, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the above described methods of random testing of host operation.
In the embodiment of the application, the random test method is determined through the obtained method name of the random test method, and then the host operation corresponding to the ID is tested randomly, so that the random test on the host operation of the host to be tested can be realized, if the host to be tested is the host in the openstack, the random test on the host operation in the openstack layer can be realized, the problem that the random test modes in the prior art are all tested aiming at the Android end is solved, and the richness and diversity of the random test are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flow chart of a method for random testing of host operation in an embodiment of the present application;
FIG. 2 is a schematic structural diagram of a random test based on TestNG in the embodiment of the present application;
FIG. 3 is a diagram illustrating a random testing apparatus operated by a host according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
An embodiment of the present application provides a random test method for host operations, as shown in fig. 1, the method includes the steps of:
step 102, determining an identity identification number ID of a host to be tested;
it should be noted that the host to be tested in this embodiment of the application may be a host device in any system or platform, for example, the host device may be a host in openstack, or may be a virtual host in any cloud system or cloud platform; that is, all hosts capable of performing host operations can be the hosts to be tested in the embodiment of the present application.
Step 104, obtaining a method name of the random test method;
the method name in the embodiment of the present application may include characters and numbers, or include characters or letters, that is, the method name of obtaining the test method refers to obtaining a combination of characters and numbers, so as to obtain the method name of the random test method, for example, the method name of the random test method may be method 1, method 2, method 3, and the like, and corresponding settings are performed according to specific needs.
And 106, calling a random test method based on the method name to carry out random test on the host operation corresponding to the ID.
The host operation in the embodiment of the present application may include viewing, printing, starting, debugging, linking, and the like.
Through the steps 102 to 106, the random test method is determined through the obtained method name of the random test method, and then the host operation corresponding to the ID is tested randomly, so that the random test on the host operation of the host to be tested can be realized, if the host to be tested is the host in the openstack, the random test on the host operation in the openstack layer can be realized, the problem that the random test mode in the prior art is single due to the fact that the random test mode is tested on the Android end is solved, and the richness and diversity of the random test are improved.
In an optional implementation manner of the embodiment of the present application, for the manner that the random test method is called based on the method name in the step 106 to perform the random test on the host operation corresponding to the ID, the method further includes:
step 11, carrying out parameterization processing on the method name to obtain a parameter corresponding to the method name;
it should be noted that, if the method name is: in the method 1, the method 2 and the method 3, the method name is parameterized to obtain parameters corresponding to the method name, wherein the method 1 is parameterized to be 1, the method 2 is parameterized to be 2, and the method 3 is parameterized to be 3; the method 1 may be parameterized as 2, the method 2 may be parameterized as 3, and the method 3 may be parameterized as 1. The specific method name and the corresponding parameters are not limited in the scope of the present application, and may be set accordingly according to actual situations. Of course, the above is merely exemplary, and the method name may be in other forms.
Step 12, calling a random test method based on the class to which the parameter belongs;
in the embodiment of the application, the class to which the parameter belongs can be determined according to a reflection (reflection) mechanism of java; the reflection mechanism of Java means that in the running state of a program, an object of any class can be constructed, the class to which any object belongs can be known, the member variables and methods of any class can be known, and the attributes and methods of any object can be called. The parameter in the embodiment of the application is the name of the method, so that the class to which the object belongs can be determined based on a reflection mechanism of Java, and further the attribute or the method of the class can be determined, so that the random test method corresponding to the parameter can be called from the attribute or the method.
And step 13, performing random test on the host operation corresponding to the ID based on a random test method.
Through the steps 11 to 13, after the method name is parameterized, the corresponding random test method is called based on the type to which the parameter belongs, that is, the random test method corresponding to the method name can be called in the process of random test without encoding a target class, so that the flexibility and expansibility of the random test are improved.
In another optional implementation manner of the embodiment of the present application, the method name in the embodiment of the present application may include one or more components, and for the manner of obtaining the method name of the random test method in step 104, the method may further include:
step 21, obtaining a plurality of components;
and step 22, one or more method names are pieced together based on the plurality of components.
In an alternative implementation of the embodiments of the present application, the method name preferably consists of two parts, such as words and numbers, words and letters, and the like. Taking the method name as the combination of characters and numbers as an example, the character part of the method is the method, the number part comprises the methods 1, 2, 3 and 4, then a plurality of components are obtained from the method and the methods 1, 2, 3 and 4, the obtaining mode can be random obtaining, and if the obtaining result is the method and the methods 3 and 4, then the spliced method is named as the methods 3 and 4. Of course, the components of the above method names are merely exemplary, and further components may be included, for example, the number components may also include "5", "6", "7", "8". In addition, in the embodiment of the present application, the positive integer may be randomized based on a Random function. Wherein, the Random function: the method of generating random numbers in java.
By the method of randomly acquiring the plurality of components of the method name and splicing one or more method names based on the plurality of components, random determination of the random test method is achieved, and random testability of host operation is further improved.
In yet another optional implementation manner of the embodiment of the present application, before determining the ID of the host to be tested, the method of the embodiment of the present application may further include:
step 31, creating IDs respectively corresponding to one or more hosts;
step 32, setting a corresponding instance based on the class to which the ID belongs;
step 33, the ID is stored in the corresponding instance.
It can be seen that, in the embodiment of the present application, the class to which the ID belongs may be an ITestContext class, that is, a corresponding instance may be set for the ITestContext class, so that the ID is stored in the instance, it should be noted that the usable range of the instance is limited to declaring the current class of the instance; that is, different instances of a class store different IDs.
Based on the foregoing steps 31 to 33, the manner of determining the ID of the host to be tested in step 102 in this embodiment may further be: the class of the ID is determined and the ID is obtained from the instance of the class. Since different instances of the class store different IDs, the corresponding ID may be obtained from the corresponding instance.
The application is exemplified by taking a random test of the operations related to openstack as an example, and combining with the specific implementation of the embodiment of the application. The specific embodiment provides a random testing method based on TestNG, fig. 2 is a schematic structural diagram of a random test based on TestNG in the embodiment of the present application, and with reference to fig. 2, the random testing method based on TestNG includes the steps of:
step 301, setting a SetUp/Operation/Teardown class based on the existing TestNG automated testing framework;
the TestNG is a testing framework, has a perfect case management module, and can be conveniently managed by relying on a third-party plug-in cooperation with the Maven. The TestNG can be used for automatic testing of functions, interfaces, units and integration.
Step 302, sorting host operations related to the openstack layer;
and step 303, parameterizing functions in the three classes by combining a java reflection mechanism, and calling the functions by the methods in the RandomTest class.
In the step 303, positive integers are randomly generated in RandomTest, the positive integers are pieced into a function name, a corresponding method name is found from the SetUp/Operation/Teardown class, and a corresponding random test method is called.
Step 304, storing a variable (ID) through an instance of an ITestContext class;
since the usable range of the instance is limited to the current class which declares the instance, an ITestContext instance belonging to the instance is set for each class, and the variable value is obtained from the ITestContext through the instance of the class.
Through the embodiment of the application, the host operation of the openstack layer is randomly tested, and the method has certain strong adaptability.
Corresponding to the above random test method for host operation in fig. 1, an embodiment of the present application provides a random test apparatus for host operation, as shown in fig. 3, the apparatus includes:
the determining module 32 is configured to determine an identity ID of the host to be tested;
it should be noted that the host to be tested in this embodiment of the application may be a host device in any system or platform, for example, the host device may be a host in openstack, or may be a virtual host in any cloud system; that is, as long as the host capable of performing the host operation can be the host to be tested in the embodiment of the present application.
An obtaining module 34, configured to obtain a method name of the random test method;
the method name in the embodiment of the present application may include characters and numbers, or include characters or letters, that is, the method name for obtaining the test method refers to obtaining a combination of characters and numbers, so as to obtain the method name of the random test method, for example, the method name of the random test method may be method 1, method 2, method 3, and the like, and corresponding settings are performed according to specific needs.
And the test module 36 is configured to invoke a random test method based on the method name to perform random test on the host operation corresponding to the ID.
The host operation in the embodiment of the present application may include viewing, printing, starting, debugging, linking, and the like.
Based on the device in the embodiment of the application, the random test method is determined through the obtained method name of the random test method, and then the host operation corresponding to the ID is tested randomly, so that the host operation of the host to be tested can be tested randomly, if the host to be tested is the host in the openstack, the host operation in the openstack layer can be tested randomly, the problem that the random test mode is single due to the fact that the random test mode in the prior art is tested for the Android terminal is solved, and the richness and diversity of the random test are improved.
Optionally, the test module 36 in this embodiment of the present application further includes:
the parameterization processing unit is used for carrying out parameterization processing on the method name to obtain a parameter corresponding to the method name;
it should be noted that, if the method name is: in the method 1, the method 2 and the method 3, the method name is parameterized to obtain parameters corresponding to the method name, wherein the method 1 is parameterized to be 1, the method 2 is parameterized to be 2, and the method 3 is parameterized to be 3; the method 1 may be parameterized as 2, the method 2 may be parameterized as 3, and the method 3 may be parameterized as 1. The specific method name and the corresponding parameters are not limited in the application, and can be set according to the actual situation. Of course, the above is merely exemplary, and the method name may be in other forms.
The calling unit is used for calling the random test method based on the class to which the parameter belongs;
in the embodiment of the application, the class to which the parameter belongs can be determined according to a reflection (reflection) mechanism of java; the reflection mechanism of Java means that in the running state of a program, an object of any class can be constructed, the class to which any object belongs can be known, the member variables and methods of any class can be known, and the attributes and methods of any object can be called. The parameter in the embodiment of the application is the name of the method, so that the class to which the object belongs can be determined based on a reflection mechanism of Java, and further the attribute or the method of the class can be determined, so that the random test method corresponding to the parameter can be called from the attribute or the method.
And the test unit is used for randomly testing the host operation corresponding to the ID based on a random test method.
Through the units in the test module 36, after the method name is parameterized, the corresponding random test method is called based on the type to which the parameter belongs, that is, the random test method corresponding to the method name can be called in the process of random test without encoding a target class, so that the flexibility and expansibility of the random test are improved.
Optionally, the legal name in the embodiment of the present application includes one or more components, and based on this, the obtaining module 34 in the embodiment of the present application further includes: an acquisition unit configured to acquire a plurality of components; and the spelling unit is used for spelling one or more method names based on the plurality of components.
In an alternative implementation of the embodiments of the present application, the method name preferably consists of two parts, such as words and numbers, words and letters, and the like. Taking the method name as the combination of characters and numbers as an example, the character part of the method is 'method', the number part comprises '1', '2', '3', '4', then a plurality of components are obtained from the 'method' and '1', '2', '3', '4', if the obtained results are 'method' and '3', '4', then the spliced method name is 'method 3' and 'method 4'. Of course, the components of the above method names are merely exemplary, and may include more components, for example, the number component may also include "5", "6", "7", "8". In addition, in the embodiment of the present application, the positive integer may be randomly generated based on the Random function. Wherein, the Random function: the method of generating random numbers in java.
By the method for acquiring the plurality of components of the method name and splicing one or more method names based on the plurality of components, random determination of the random test method is achieved, and random testability of host operation is further improved.
Optionally, the apparatus in this embodiment of the present application further includes: the system comprises a creating module, a judging module and a judging module, wherein the creating module is used for creating IDs corresponding to one or more hosts before determining the ID of the host to be tested; the setting module is used for setting a corresponding example based on the class to which the ID belongs; and the storage module is used for storing the ID into the corresponding instance.
It can be seen that, in the embodiment of the present application, the class to which the ID belongs may be an ITestContext class, that is, a corresponding instance may be set for the ITestContext class, so that the ID is stored in the instance, it should be noted that the usable range of the instance is limited to declaring the current class of the instance; that is, different instances of a class store different IDs.
Optionally, the determining module 32 in this embodiment of the present application further includes: and the processing unit is used for determining the class of the ID and acquiring the ID from the instance of the class.
The embodiment of the present application further provides an electronic device, as shown in fig. 4, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, implements the following steps: determining the identity identification number ID of a host to be tested; acquiring a method name of a random test method; and calling the random test method based on the method name to carry out random test on the host operation corresponding to the ID.
In addition, when the processor 401 in the electronic device executes the program stored in the memory 403, other method steps in the random test method for host operation may also be implemented, and the functions are similar, and are not described herein again.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 4, but this does not indicate only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment provided by the present application, there is also provided a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to perform the random test method of host operation described in any of the above embodiments.
In yet another embodiment provided herein, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method for random testing of host operations as described in any of the above embodiments.
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
It should be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (10)

1. A method for random testing of operation of a host, comprising:
determining the identity identification number ID of a host to be tested;
acquiring a method name of a random test method;
and calling the random test method based on the method name to carry out random test on the host operation corresponding to the ID.
2. The method of claim 1, wherein invoking the random test method based on the method name to randomly test the host operation corresponding to the ID comprises:
carrying out parameterization processing on the method name to obtain a parameter corresponding to the method name;
calling the random test method based on the class to which the parameter belongs;
and carrying out random test on the host operation corresponding to the ID based on the random test method.
3. The method of claim 1, wherein the method name comprises one or more components, and wherein obtaining the method name of the random test method comprises:
obtaining a plurality of said components;
and spelling one or more method names based on the plurality of components.
4. The method of claim 1, wherein prior to determining the ID of the host under test, the method further comprises:
creating IDs respectively corresponding to one or more hosts;
setting a corresponding instance based on the class to which the ID belongs;
the ID is stored into the corresponding instance.
5. The method of claim 4, wherein determining the ID of the host under test comprises:
and determining the class described by the ID, and acquiring the ID from the instance of the class.
6. A random test apparatus for host operation, comprising:
the determining module is used for determining the identity identification number ID of the host to be tested;
the acquisition module is used for acquiring the method name of the random test method;
and the test module is used for calling the random test method based on the method name so as to carry out random test on the host operation corresponding to the ID.
7. The apparatus of claim 6, wherein the testing module comprises:
the parameterization processing unit is used for carrying out parameterization processing on the method name to obtain a parameter corresponding to the method name;
the calling unit is used for calling the random test method based on the class to which the parameter belongs;
and the test unit is used for randomly testing the host operation corresponding to the ID based on the random test method.
8. The apparatus of claim 6, wherein the method name comprises one or more components, and wherein the obtaining module comprises:
an acquisition unit configured to acquire a plurality of the components;
and the spelling unit is used for spelling one or more method names based on the components.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN202111137910.0A 2021-09-27 2021-09-27 Random test method and device for host operation Pending CN115858257A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111137910.0A CN115858257A (en) 2021-09-27 2021-09-27 Random test method and device for host operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111137910.0A CN115858257A (en) 2021-09-27 2021-09-27 Random test method and device for host operation

Publications (1)

Publication Number Publication Date
CN115858257A true CN115858257A (en) 2023-03-28

Family

ID=85653253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111137910.0A Pending CN115858257A (en) 2021-09-27 2021-09-27 Random test method and device for host operation

Country Status (1)

Country Link
CN (1) CN115858257A (en)

Similar Documents

Publication Publication Date Title
CN108984388B (en) Method and terminal equipment for generating automatic test case
CN107766236B (en) Test task automatic management method, device, equipment and storage medium
CN110474900B (en) Game protocol testing method and device
CN110879781B (en) Program debugging method, device, electronic equipment and computer readable storage medium
CN110928777B (en) Test case processing method, device, equipment and storage medium
CN111382077B (en) Application program crash reason positioning method and device, electronic equipment and storage medium
CN107621963B (en) Software deployment method, software deployment system and electronic equipment
CN115292197A (en) Software testing method and device, electronic equipment and storage medium
CN111949513A (en) Configuration file loading method and device, electronic equipment and readable storage device
CN112948233A (en) Interface testing method, device, terminal equipment and medium
CN115391228A (en) Precise test method, device, equipment and medium
CN111782526A (en) Interface testing method and device, electronic equipment and storage medium
CN116415258A (en) Vulnerability detection method, device, equipment, medium and program product
CN115858257A (en) Random test method and device for host operation
CN110618943B (en) Security service test method and device, electronic equipment and readable storage medium
CN114201399A (en) Method, device, equipment and storage medium for identifying influence range of program change
CN109189369B (en) Method and device for compressing codes
CN109165127B (en) Problem interface positioning method and device and electronic equipment
CN113220586A (en) Automatic interface pressure test execution method, device and system
CN112800194A (en) Interface change identification method, device, equipment and storage medium
CN111309541A (en) Exception handling detection method, device and equipment and computer storage medium
CN111045724A (en) Query method and device for call chain information and readable storage medium
CN111258899A (en) Use case generation method and device, electronic equipment and computer readable storage medium
CN112650679B (en) Test verification method, device and computer system
CN113407460B (en) Page testing method, device, equipment and storage medium

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