Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which the method for generating information or the apparatus for generating information of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include a terminal device 101, a server 102, and a test server 103. The server 102 is a background server of an application installed in the terminal apparatus 101. That is, a background service program of the above-mentioned certain application is deployed in the server 102. In practice, the background service program may provide an interface to the outside, so as to realize interaction between the terminal device 101 and the server 102. The test server 103 is deployed with a service program to be tested, a first contrast service program and a second contrast service program. Here, the service program to be tested is generally a service program after the background service program is modified. The first control service is generally a service that deploys the background service described above behind the test server 103. The second control service is typically a service that re-deploys the background service described above behind the test server 103. Accordingly, the service interface to be tested 1031 may be an interface provided by the service program to be tested. The first contrast service interface 1032 may be an interface provided externally by the first contrast service program. The second control service interface 1033 may be an interface provided to the outside by the second control service program.
In practice, the terminal device 101, the server 102 and the test server 103 may interact with each other via a network. Here, the network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The terminal apparatus 101 interacts with the server 102 through the network to receive or transmit messages and the like. Various communication client applications, such as a shopping application, a search application, a video playing application, a browser application, a reading application, etc., may be installed on the terminal device 101.
The terminal apparatus 101 may be hardware or software. When the terminal device 101 is hardware, it may be various electronic devices having a display screen and supporting an information transmission function, including but not limited to a smart phone, a tablet computer, an e-book reader, a laptop portable computer, a desktop computer, and the like. When the terminal apparatus 101 is software, it can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 102 may be hardware or software. When the server 102 is hardware, it may be implemented as a distributed server cluster composed of multiple servers, or may be implemented as a single server. When the server 102 is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
The test server 103 may be a server that provides various services. As an example, when the terminal device 101 accesses the server 102, the test server 103 may obtain user access data, convert the obtained user access data into a test request, and then may test an interface of the improved service program according to the test request.
The test server 103 may be hardware or software. When the test server 103 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the test server 103 is software, it may be implemented as a plurality of software or software modules (for example, to provide distributed services), or as a single software or software module. And is not particularly limited herein.
It should be noted that the test server 103 may also directly acquire user access data from the server 102. At this time, the terminal apparatus 101 may not be present.
It should be further noted that the method for generating information provided by the embodiment of the present disclosure is generally performed by the test server 103, and accordingly, the apparatus for generating information is generally disposed in the test server 103.
It should be understood that the number of terminal devices, servers and test servers in fig. 1 is merely illustrative. There may be any number of terminal devices, servers and test servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for generating information in accordance with the present disclosure is shown. The method for generating information comprises the following steps:
step 201, a test request is obtained.
In the present embodiment, an execution subject of the method for generating information (such as the test server 103 shown in fig. 1) may acquire a test request by various methods. The test request may be various types of requests depending on the transmission protocol employed. For example, when the adopted transport Protocol is http Protocol (Hypertext Transfer Protocol), the test request may be an http request. For example, when the adopted transport Protocol is https Protocol (Hypertext Transfer Protocol Secure), the test request may be an https request. It will be appreciated that the test request may also be other types of requests when the transport protocol employed is other.
As an example, a technician may pre-construct a large number of requests to be stored locally or to a communicatively connected database server. The executing agent may then obtain the request directly from a local or communicatively connected database server as a test request.
In some optional implementations of this embodiment, the execution subject may further obtain the test request through the following steps.
In a first step, user access data may be obtained. The user access data may be access data sent to a server (e.g., the server 102 shown in fig. 1) where the online service program runs when the client accesses the online service program. As an example, when a client accesses a service program running on a line, a server where the service program is located typically stores user access data sent by the client. Thus, the execution agent can acquire the user access data from the server where the service program is located. As an example, when a client accesses a service program running on a line, the execution body may directly acquire user access data from the line. It should be noted that obtaining user access data from online is a well-known technology that is widely researched and applied at present, and is not described herein again.
In a second step, a test request may be generated based on the user access data. In practice, at least one field may be included in the user access data. Among them, a Key (Key) and a Value (Value) may be included in the field.
After the user access data is acquired, the execution subject may perform various processes on the user access data. As an example, fields that are not needed for testing included in the acquired user access data may be deleted. As an example, the execution body may also change values in some fields included in the user access data according to actual needs. For example, the user access data includes a "url: XXXX" field, where "url (Uniform Resource Location) is usually a key and" XXXX "is usually a value used to characterize the storage path in the server where the Resource requested by the client is running on the thread. Then the executive may change "XXXX" to a deposit path in the server under test.
After processing the user access data, the execution subject may convert the user access data into a test request according to a predefined format of the test request.
Step 202, sending the test request to the service interface to be tested and the first contrast service interface to obtain the first result information and the second result information.
In this embodiment, the executing entity may send the test request to the service interface to be tested and the first contrast service interface, so as to obtain the first result information and the second result information. The first contrast service interface may be an interface of a service program obtained after the service program running stably on the line is deployed to the execution subject. The service interface to be tested is usually an interface of the service program obtained by improving the service program which runs stably on the line and then deploying the service program to the execution main body. It is to be understood that the first result information may be result information returned by the service interface to be tested. The second result information may be result information returned by the first control-service interface. The first result information and the second result information each include at least one field.
Step 203, generating evaluation information in response to determining that the first result information contains a field which does not match the second result information.
In this embodiment, the execution agent may generate the evaluation information in response to a determination that the first result information includes a field that does not match the second result information. In practice, the execution subject may compare each field in the first result information with each field in the second result information, and determine whether the first result information includes a field that does not match the second result information. Here, the field included in the first result information and not matching the second result information may be a field in which a key in the field is different from a key in any one of the fields in the second result information. Or fields with the same key but different values in the fields.
In the present embodiment, the evaluation information may be various information for characterizing the test failure. In practice, the evaluation information may include at least one of: text information, tables, pictures, animations, speech, etc. Here, the text information may be various text information characterizing the test failure, such as "test failure". Each field in the first result information, each field in the second result information, and the field with the mismatch marked may be listed in a table in the evaluation information. Here, the mark may be in various forms, for example, a font is bolded, underlined, a font color is modified, and the like.
The method provided by the above embodiment of the present disclosure may first obtain the test request, and then may send the obtained test request to the service interface to be tested and the first contrast service interface to obtain the first result information and the second result information. Thus, in response to determining that the first result information includes a field that does not match the second result information, evaluation information may be generated. Therefore, the test of the interface of the service program to be tested through the test request is realized.
With further reference to fig. 3, a flow 300 of yet another embodiment of a method for generating information is shown. The flow 300 of the method for generating information comprises the steps of:
step 301, a test request is obtained.
Step 302, sending the test request to the service interface to be tested and the first contrast service interface to obtain the first result information and the second result information.
Step 303, in response to determining that the first result information contains a field that does not match the second result information, generating evaluation information.
The above steps 301 to 303 are respectively consistent with the steps 201 to 203 in the foregoing embodiment, and the above description for the steps 201 to 203 also applies to the steps 301 to 303, which is not repeated herein.
Step 304, sending the test request to the second contrast service interface to obtain third result information.
In this embodiment, an executing subject of the method for generating information (e.g., the test server 103 shown in fig. 1) may send a test request to the second control service interface, resulting in third result information. Wherein the second contrast service interface matches the first contrast service interface. Specifically, the second control service interface is generally an interface of a service program obtained after the online stably running service program is re-deployed to the execution subject. In practice, the second and first contrast service interfaces may use respective resources (e.g., pictures, files, video, audio, etc.), or may share some resources.
It will be appreciated that the third result information is typically the result information returned by the second control service interface.
Step 305, in response to determining that the second result information contains a field that does not match the third result information, determining whether the field that does not match the third result information in the second result information belongs to a preset category field.
In this embodiment, the execution subject may compare each field in the second result information with each field in the third result information, and then determine whether the second result information includes a field that does not match the third result information. Here, the field included in the second result information and not matching the third result information may be a field in which a key in the field is different from a key in any one of the fields in the third result information. Or fields with the same key but different values in the fields.
In this embodiment, in response to determining that the second result information includes a field that does not match the third result information, the execution main body may determine whether the field that does not match the third result information in the second result information belongs to the preset category field. The preset category field is generally various fields that can be determined as noise when testing an interface of a service program. Optionally, the preset category field may include at least one of: timestamp field, nonce field. Here, the value in the timestamp field may be the time when the interface of the service program returns the result information. In practice, the interface of the service program may generate a random number in the process of responding to the request, and accordingly, the random number field may be a field whose value is the generated random number in the result information returned by the interface of the service program. It should be understood that the preset category field may also be other fields that can be determined as noise, and will not be described herein.
As an example, the technician may previously store keys in various fields of preset categories, and thus, for a field included in the second result information and not matching the third result information, the execution subject may use the key in the field to match the various previously stored keys, and if there is a key identical to the key in the field, the execution subject may determine that the field belongs to the field of the preset categories.
In practice, for the same request, the values in the preset category fields in the result information returned by the interface of the same service program are often different in different request processes. Accordingly, for the same request, the values in the preset category fields in the result information returned by the interfaces (e.g., the second and first control service interfaces) of the two matching service programs tend to be different. Therefore, the execution body may also determine whether a field in the second result information that does not match the third result information belongs to the preset category field by the following method.
As an example, the executing entity may send the test request to the first contrast service interface again, and obtain the fourth result information. Therefore, for a field contained in the second result information and not matched with the third result information, the execution subject may compare the field with a field in the fourth result information and having the same key as the field, and if the values of the field and the field are different, the execution subject may determine that the field belongs to the preset category field. It should be understood that the executing entity may also send the test request to the second control service interface again to obtain the fifth result information. Then, whether the field contained in the second result information and not matched with the third result information belongs to the preset category field is judged according to a similar method.
Step 306, in response to determining that the field in the second result information that does not match the third result information belongs to the preset category field, updating the evaluation information based on the field in the second result information that does not match the third result information.
In this embodiment, in response to determining that a field of the second result information that does not match the third result information belongs to the preset category field, the execution subject may update the evaluation information based on the field that does not match. Specifically, after determining that a field in the second result information that does not match the third result information belongs to the field of the preset category, the execution subject may match the field in the first result information using a key in the field, and may further determine that a field in the first result information that is the same as the key in the field belongs to the field of the preset category. Thus, the execution subject may further determine whether the first result information further includes another field that does not match the second result information. If not, the execution body can modify the evaluation information into the information representing that the test passes. For example, the textual information in the evaluation information may be modified to characterize the textual information that the test passed ("test passed"). For example, the flag for marking the field that does not match in the table in the evaluation information may be deleted. If so, the execution body may delete the mark used for marking the field belonging to the preset category in the table in the evaluation information, and may retain the marks of the remaining unmatched fields.
With continued reference to fig. 4, fig. 4 is a schematic diagram of an application scenario of the method for generating information according to the present embodiment. In the application scenario of fig. 4, when the smartphone 401 sends an access request to the server 402, the test server 403 may obtain user access data 404. Here, the HTTP protocol is used for communication between the smartphone 401 and the server 402. The test server 403 may process the user access data 404 to generate a test request 405 (shown as an http request). Then, the test server 403 may send the test request 405 to the service interface under test 406 and the first contrast service interface 407, to obtain the first result information 408 and the second result information 409, respectively. Next, the test server 403 may compare each field in the first result information 408 with each field in the second result information 409. Thus, the test server 403 can determine that the value in field 4081 (shown as "date: 2018-12-1515: 50: 03" in the figure) in the first result information 408 is different from the value in field 4091 (shown as "date: 2018-12-1515: 50: 08" in the figure) in the second result information 409. Then test server 403 may generate evaluation information 410 (shown as "test failed").
Next, the test server 403 may send a test request 405 to the second control service interface 411, resulting in third result information 412. Then, the test server 403 may compare each field in the second result information 409 with each field in the third result information 412. Then the test server 403 may determine that the value in field 4091 in the second result information 409 is different from the value in field 4121 in the third result information 412 (as shown in the figure as "date: 2018-12-1515: 51: 01"). Then, the test server 403 may use "date" to match into the various keys stored in advance, whereby it can be determined that "date" exists among the various keys stored in advance. Then the test server 403 may determine that the field 4091 in the second result information 409 belongs to a preset category field. Further, the test server 403 may use "date" to match the first result information 408, and may determine that the field 4081 in the first result information 408 belongs to the predetermined category field. Meanwhile, the test server 403 may determine that the first result information 408 does not include other fields that do not match the second result information 409, and then the test server 403 may update the evaluation information 410 to generate new evaluation information 413 (shown as "test pass").
As can be seen from fig. 3, compared with the embodiment corresponding to fig. 2, the flow 300 of the method for generating information in this embodiment embodies a step of sending a test request to the second control service interface to obtain third result information, and a step of updating the evaluation information based on a field in the second result information that does not match the third result information. Thus, the scheme described in this embodiment may determine whether or not a field contained in the first result information, which is different from the value in the second result information, belongs to noise that affects the test result, by a field contained in the second result information, which is different from the value in the third result information. Thereby reducing the effect of noise on the test results.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for generating information, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 5, the apparatus 500 for generating information provided by the present embodiment includes an obtaining unit 501, a first sending unit 502, and a generating unit 503. The obtaining unit 501 may be configured to obtain a test request. A first sending unit 502, which may be configured to: and sending the test request to the service interface to be tested and the first contrast service interface to obtain first result information and second result information, wherein the first result information and the second result information both comprise at least one field. A generating unit 503, which may be configured to: in response to determining that the first result information includes a field that does not match the second result information, evaluation information is generated.
In the present embodiment, in the apparatus 500 for generating information: the specific processing of the obtaining unit 501, the first sending unit 502, and the generating unit 503 and the technical effects thereof can refer to the related descriptions of step 201, step 202, and step 203 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of this embodiment, the apparatus 500 for generating information may further include: a second sending unit (not shown in the figure), a determining unit (not shown in the figure) and an updating unit (not shown in the figure). Wherein the second transmitting unit may be configured to: and sending the test request to a second contrast service interface to obtain third result information, wherein the first contrast service interface is matched with the second contrast service interface. The determination unit may be configured to: and in response to determining that the second result information contains a field that does not match the third result information, determining whether the field that does not match the third result information in the second result information belongs to a preset category field. The update unit may be configured to: in response to determining that the field of the second result information that does not match the third result information belongs to the preset category field, updating the evaluation information based on the field of the second result information that does not match the third result information.
In some optional implementations of this embodiment, the preset category field may include at least one of the following: timestamp field, nonce field.
In some optional implementation manners of this embodiment, the obtaining unit 501 may include: an acquisition module (not shown in the figure) and a generation module (not shown in the figure). Wherein the obtaining module may be configured to obtain the user access data. The generation module may be configured to: based on the user access data, a test request is generated.
The apparatus provided by the above embodiment of the present disclosure may first obtain the test request through the obtaining unit 501, and then may send the obtained test request to the service interface to be tested and the first contrast service interface through the first sending unit 502, so as to obtain the first result information and the second result information. Thus, the evaluation information may be generated by the generation unit 503 in response to determining that a field that does not match the second result information is contained in the first result information. Therefore, the test of the interface of the service program to be tested through the test request is realized.
Referring now to FIG. 6, shown is a block diagram of a computer system 600 suitable for use as a server in implementing embodiments of the present disclosure. The server shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The above-described functions defined in the method of the present disclosure are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium of the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an acquisition unit, a first transmission unit, and a generation unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, the retrieving unit may also be described as a "unit that retrieves a test request".
As another aspect, the present disclosure also provides a computer-readable medium, which may be contained in the server described in the above embodiments; or may exist separately and not be assembled into the server. The computer readable medium carries one or more programs which, when executed by the server, cause the server to: acquiring a test request; sending the test request to a service interface to be tested and a first contrast service interface to obtain first result information and second result information, wherein the first result information and the second result information both comprise at least one field; in response to determining that the first result information includes a field that does not match the second result information, evaluation information is generated.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept as defined above. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.