CN111930612A - Method and device for detecting code updating correctness and computing equipment - Google Patents

Method and device for detecting code updating correctness and computing equipment Download PDF

Info

Publication number
CN111930612A
CN111930612A CN202010659335.XA CN202010659335A CN111930612A CN 111930612 A CN111930612 A CN 111930612A CN 202010659335 A CN202010659335 A CN 202010659335A CN 111930612 A CN111930612 A CN 111930612A
Authority
CN
China
Prior art keywords
response message
key
difference
type
code
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.)
Granted
Application number
CN202010659335.XA
Other languages
Chinese (zh)
Other versions
CN111930612B (en
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 Pierbulaini Software Co ltd
Original Assignee
Beijing Pierbulaini Software 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 Pierbulaini Software Co ltd filed Critical Beijing Pierbulaini Software Co ltd
Priority to CN202010659335.XA priority Critical patent/CN111930612B/en
Publication of CN111930612A publication Critical patent/CN111930612A/en
Application granted granted Critical
Publication of CN111930612B publication Critical patent/CN111930612B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/194Calculation of difference between files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Hardware Design (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Quality & Reliability (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Input From Keyboards Or The Like (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method for detecting the correctness of code updating, which comprises the following steps: acquiring a first response message and a second response message from the operating environment with the deployed previous code, and acquiring a third response message from the operating environment with the deployed updated code; comparing the first response message with the third response message to obtain a first difference set; determining first, second and third type differences; determining that the update code has an error when the first set of differences includes a first type of difference and/or a second type of difference; and when the first difference set includes only differences of the third type: comparing the first response message with the second response message to obtain a second difference set, and acquiring a third type difference key-value pair from the second difference set; removing key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference; if the removed third type of difference does not include any key-value pairs, then there is no error in updating the code.

Description

Method and device for detecting code updating correctness and computing equipment
Technical Field
The present invention relates to the field of computer application technologies, and in particular, to a method and an apparatus for detecting correctness of code update, and a computing device.
Background
With the rapid development of network technology, the software updating iteration speed is also increased, and when the software is updated and iterated, the updating code is tested, which is a key link for ensuring the reliability and stability of the software after the updating iteration. Currently, the update code is often tested through regression testing, where the regression testing is to replay the captured online/offline traffic to an operating environment in which the update code and a previous code are deployed, manually compare an HTTP response message obtained from the previous code operating environment with an HTTP response message obtained from the update code operating environment to obtain a difference, and determine whether the new code has a problem based on the difference between the two HTTP response messages.
Currently, a method for manually comparing a difference between an HTTP response packet obtained from a previous code operating environment and an HTTP response packet obtained from an updated code operating environment includes: manually configuring fields of response messages which are predicted to be ignored in advance in the test system, and ignoring the corresponding difference of the configured fields when comparing the HTTP response messages obtained in the previous code operating environment with the HTTP response messages obtained in the new code operating environment; or manually performing regular replacement configuration on partial fields in the HTTP response message which needs to be ignored, and when manually comparing the HTTP response message obtained in the previous code operation environment with the HTTP response message obtained in the updated code operation environment, replacing the difference matched by the regular expression with the same value and then comparing. However, the above method of ignoring the corresponding difference of the fields to determine the correctness of the updated code when manually configuring and comparing in advance is tedious and time-consuming.
Therefore, a new method for detecting the correctness of code update is needed to solve the above problems.
Disclosure of Invention
To this end, the present invention provides a method, system and computing device for detecting correctness of code update, so as to solve or at least alleviate the above existing problems.
According to an aspect of the present invention, there is provided a method for detecting correctness of a code update, the method being executed in a computing device in which a runtime environment for running a previous code and an updated code is deployed, the method comprising:
acquiring a first response message and a second response message from a running environment with a deployed previous code, and acquiring a third response message from a running environment with a deployed updated code, wherein the first response message, the second response message and the third response message all comprise one or more key-value pairs;
comparing the first response message with the third response message to obtain a first difference set;
determining first, second and third type differences, the first type difference comprising a key-value pair where the key is present in the first response message and not present in the third response message, the second type difference comprising a key-value pair where the key is not present in the first response message and present in the third response message, and the third type difference comprising a key-value pair where the corresponding key value is not consistent in the first response message and the third response message where the key is present in both the first and third response messages;
determining that the update code has an error when the first set of differences includes a first type of difference and/or a second type of difference; and
when the first set of differences includes only differences of a third type:
comparing the first response message with the second response message to obtain a second difference set, and acquiring a difference key-value pair, in which keys exist in the first response message and the second response message and corresponding key values are inconsistent in the first response message and the second response message, from the second difference set;
removing key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference; and
if the removed third-type difference does not include any key-value pairs, then the update code is error free.
Optionally, the comparing the first response packet with the third response packet to obtain a first difference set includes:
extracting paths and values corresponding to all nodes from the first response message, wherein the nodes comprise leaf nodes;
taking the path corresponding to each node as a key and the value as a key value to form a key-value pair, and taking one or more key-value pairs as a first set;
extracting paths and values corresponding to all nodes from the third response message, wherein the nodes comprise leaf nodes;
taking the path corresponding to each node as a key and the value as a key value to form a key-value pair, and taking one or more key-value pairs as a third set;
and comparing the first set with the third set to obtain the first difference set.
Optionally, the method further comprises:
sorting key values of partial key-value pairs in the first response message, the second response message and the third response message to obtain the sorted first response message, the second response message and the third response message;
comparing the sorted first response packet with the sorted third response packet to obtain a new first difference set, where the new first difference set only includes a third type difference, and the third type difference in the new first difference set is different from the third type difference in the first difference set.
Optionally, the sorting key values of partial key-value pairs in the first response packet, the second response packet, and the third response packet includes:
extracting partial key-value pairs from the first response message, the second response message and the third response message;
sorting the key values of the extracted partial key-value pairs to obtain sorted partial key-value pairs;
and putting the sorted partial key-value pairs back to positions corresponding to the extracted partial key-value pairs of the first response message, the second response message and the third response message.
Optionally, the comparing the first response packet with the second response packet to obtain a second difference set includes:
comparing the sorted first response message with the second response message to obtain a new second difference set;
and obtaining a difference key-value pair, which is obtained from the new second difference set, wherein the keys exist in the first response message and the second response message, and the corresponding key values are inconsistent in the first response message and the second response message, and the difference key-value pair is used as a new difference key-value pair.
Optionally, said removing key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference comprises:
removing key-value pairs corresponding to the obtained new difference key-value pairs from the third type of difference of the new first difference set.
Optionally, the first response message and the second response message are obtained from the runtime environment deployed with the previous code, and the third response message is obtained from the runtime environment deployed with the updated code, in the following order:
acquiring a first response message from a running environment with a deployed previous code;
acquiring a third response message from the running environment with the deployed updating code; and
and acquiring a second response message from the operating environment with the deployed previous code.
According to an aspect of the present invention, there is provided an apparatus for detecting correctness of code update, the apparatus being executed in a computing device, a running environment running previous code and updated code being deployed in the computing device, the apparatus including:
the acquisition module is used for acquiring a first response message and a second response message from the operating environment with the deployed previous code and acquiring a third response message from the operating environment with the deployed updated code, wherein the first response message, the second response message and the third response message all comprise one or more key-value pairs;
the comparison module is used for comparing the first response message with the third response message to obtain a first difference set; and when the first set of differences includes only differences of a third type: comparing the first response message with the second response message through the comparison module to obtain a second difference set, wherein a difference key-value pair, in which keys exist in the first response message and the second response message and corresponding key values are inconsistent, is obtained from the second difference set as a first key-value pair;
a difference type determining module, configured to determine first, second, and third type differences through the difference type determining module, where the first type difference includes a key-value pair that the key exists in the first response packet and does not exist in the third response packet, the second type difference includes a key-value pair that the key does not exist in the first response packet and exists in the third response packet, and the third type difference includes a key-value pair that the key exists in both the first and third response packets and the corresponding key value does not coincide in the first response packet and the third response packet;
the judging module is used for determining that the updating code has errors when the first difference set comprises a first type difference and/or a second type difference; and if the removed third type difference does not comprise any key-value pair, judging that the update code has no error through the judging module.
A removal module to, when the first set of differences includes only third type differences: removing, by the removal module, key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference.
According to an aspect of the present invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method as described above.
According to an aspect of the present invention, there is provided a readable storage medium storing program instructions that, when read and executed by a mobile terminal, cause the mobile terminal to perform the method as described above.
According to the technical scheme of the invention, a detection method for code updating correctness is provided, a response message obtained by running a previous code for the first time is compared with a response message obtained by running an updating code for the first time to obtain a first difference set, and the difference between the response messages obtained by running the previous code for the first time and the response messages obtained by running the previous code for the second time is removed from the first difference set, so that the comparison difference for two times is realized.
Secondly, the method for comparing the difference for two times is simple to realize, can automatically classify the difference items, can automatically identify the difference called as noise, and automatically filters the difference identified as the noise in the process of testing the update code, so that the efficiency of judging whether the update code is correct is greatly improved without manual pre-configuration, and the neglect configuration of manual operation on partial nodes in the response message can be still superposed on the basis.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 is a diagram illustrating a method 200 for detecting correctness of a code update according to an embodiment of the present invention;
FIG. 3 illustrates a flow diagram of a first disparity set determination method 300 according to one embodiment of the present invention;
FIG. 4 is a diagram illustrating a method 400 for detecting correctness of a code update according to another embodiment of the present invention;
fig. 5 is a schematic diagram of a device 500 for detecting correctness of code update according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
For the update iteration of the software, the conventional method for improving the performance of the software is adopted. In the prior art, the reliability and stability of software after update iteration are ensured mainly by testing update codes. Currently, the correctness of the updated code is mostly determined through a regression test, in which the captured online/offline traffic is played back to an operating environment in which a new code and a previous code are deployed, an HTTP response message obtained from the previous code operating environment is used as a basis, the captured online/offline traffic is manually compared with an HTTP response message obtained from the new code operating environment to obtain a difference, and whether the new code has a problem is determined based on the difference between the two HTTP response messages.
The differences between the HTTP response message obtained by the previous code operating environment and the HTTP response message obtained by the new code operating environment include the following four types of differences: 1) the key values (value) of the key-value pairs in the two response messages are different, such as timestamp fields, and the difference is not caused by code updating and can be ignored in the process of updating code testing, so that the difference is called noise difference when the messages are compared; 2) the keys of the two message key-value pairs are different, when the difference occurs, the updating code is judged to have an error, and the difference cannot be ignored when the messages are compared; 3) the values or the sequence of the key-value pairs in the two messages are different, the difference is not caused by code updating, the difference can be ignored in the process of updating the code test, and the difference is also called as noise difference when the messages are compared; 4) the response codes and/or response heads of the two response messages are different, when the difference occurs, the update codes are judged to have errors, and the difference cannot be ignored when the messages are compared.
Since it is considered that the difference of noise is not caused by updating of the code, and the comparison efficiency is reduced when the difference of noise is large, at present, in order to improve the detection efficiency of the correctness of the code updating, before testing the updating code, fields in the response message which need to be ignored during comparison are manually configured in advance, so as to filter out the difference corresponding to the fields during the testing process, that is, the above-mentioned two types of differences 1) and 3) are filtered out as much as possible during testing the updating code, and whether the updating code is correct is determined based on the difference obtained by the testing.
However, the fields that need to be ignored when comparing the response messages are manually configured in advance, the configuration process is tedious and time-consuming, and the filtering is regarded as the difference effect of noise is poor. Therefore, in order to solve the above problem, the present invention proposes a method for detecting correctness of code update, which is executed in a computing device 100, wherein an execution environment for executing previous code and updated code is deployed in the computing device 100, that is, an application capable of executing previous code and updated code is deployed in the computing device 100.
In the invention, captured online/offline traffic is played back to an operating environment of a computing device 100 deployed with a previous code and an update code, online/offline traffic is played back to the operating environment deployed with the previous code twice to obtain a first response message and a second response message corresponding to the previous code, online/offline traffic is played back to the operating environment deployed with the update code once to obtain a third response message corresponding to the update code, the first response message and the third response message are compared to obtain a first difference set, and based on three difference types determined in advance, when the first difference set includes a first type difference and/or a second type difference, it is determined that the update code has an error, and when the first difference set includes only the third type difference: and comparing the first response message with the second response message to obtain a second difference set, acquiring a difference key-value pair from the second difference set, wherein the key exists in the first response message and the second response message and the corresponding key value is inconsistent in the first response message and the second response message, removing the key-value pair corresponding to the acquired difference key-value pair from the third type difference, and if the removed third type difference does not comprise any key-value pair, updating the code to be correct. According to the method, the difference items can be automatically classified, the difference called as noise can be automatically identified, the difference identified as the noise can be automatically filtered in the process of testing the updated code, particularly, the difference of the timestamp fields can be filtered by 100%, the method is simple to realize, manual pre-configuration is not needed, and the efficiency of judging whether the updated code is correct is greatly improved.
FIG. 1 shows a block diagram of a computing device 100, according to one embodiment of the invention. As shown in FIG. 1, in a basic configuration 102, a computing device 100 typically includes a system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between the processor 104 and the system memory 106.
Depending on the desired configuration, the processor 104 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a Digital Signal Processor (DSP), or any combination thereof. The processor 104 may include one or more levels of cache, such as a level one cache 110 and a level two cache 112, a processor core 114, and registers 116. The example processor core 114 may include an Arithmetic Logic Unit (ALU), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof. The example memory controller 118 may be used with the processor 104, or in some implementations the memory controller 118 may be an internal part of the processor 104.
Depending on the desired configuration, system memory 106 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 may include an operating system 120, one or more applications 122, and program data 124. The application 122 is actually a plurality of program instructions that direct the processor 104 to perform corresponding operations. In some embodiments, the application 122 may be arranged to cause the processor 104 to operate with the program data 124 on an operating system.
Computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus/interface controller 130. The example output device 142 includes a graphics processing unit 148 and an audio processing unit 150. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 158. An example communication device 146 may include a network controller 160, which may be arranged to facilitate communications with one or more other computing devices 162 over a network communication link via one or more communication ports 164.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
In the computing device 100 according to the present invention, the application 122 includes program instructions of a code update correctness detection method that can instruct the processor 104 to execute a code update correctness detection method 200 according to the present invention, so that the computing device 100 can automatically filter noise differences by executing the code update correctness detection method 200 according to the present invention, and further efficiently determine whether there is an error in the updated code.
Fig. 2 shows a schematic flow chart of a method 200 for detecting correctness of a code update in a picture set according to an embodiment of the present invention. The method 200 may be performed in an application of the computing device 100.
As shown in fig. 2, the method begins at step S210. In step S210, a first response message and a second response message are obtained from the runtime environment in which the previous code is deployed, and a third response message is obtained from the runtime environment in which the updated code is deployed. It can be understood that, the present invention runs the previous code twice in the running environment where the previous code is deployed, thereby obtaining the first response packet and the second response packet, and runs the update code once in the running environment where the update code is deployed, thereby obtaining the third response packet. And the first, second and third response messages each include one or more key-value pairs.
After the response message corresponding to the previous code and the response message corresponding to the update code are obtained, the difference between the two messages needs to be compared, so that the correctness of the update code can be judged. Subsequently, in step S220, the first response packet is compared with the third response packet to obtain a first difference set. The diagram 300 is a flow chart of a first difference set determination method, the first difference set determination method 300 starting at step S310. In step S310, paths and values corresponding to all nodes are extracted from the first response packet, and since the parameters are stored in the json text in the response packet, the paths and values corresponding to all nodes are extracted from the json text in the first response packet, and the nodes include leaf nodes.
Subsequently, in step S320, the path corresponding to each node is used as a key, and the value is used as a key value to form a key-value pair, and the obtained one or more key-value pairs are used as a first set.
After the first set is determined, in step S330, paths and values corresponding to all nodes are extracted from the third response message, and further, paths and values corresponding to all nodes are extracted from the json text of the third response message.
Next, in step S340, the path corresponding to each node is used as a key, and the value is used as a key value to form a key-value pair, and the obtained one or more key-value pairs are used as a third set.
After the first set and the third set are determined, in step S350, the first set and the third set are compared to obtain a first difference set. In an embodiment of the present invention, the first set and the third set are compared by a method provided by com. In addition, to more clearly understand the difference between the json text of the response message and the first set or the third set, examples of the json text and the first set of the first response message are given below.
First response message json text:
Figure BDA0002577938030000101
Figure BDA0002577938030000111
example of the first set:
{
"/Noticelist":"null"
"/UserName": old name "
"/SysName": management System "
"/LogoffUrl":"http://"
"/MessageUrl":"http://"
"/NavList/0/Url":"/passport/Home/Index"
"/NavList/0/Class":"nav-home"
"/NavList/0/Name": first Page "
"/NavList/0/CnName": first Page "
"/NavList/0/IsCurrent":"false"
"/NavList/0/IsNew":""
"/NavList/0/IsFloat":"false"
"/NavList/0/IsService":"false"
"/NavList/0/OrderNum":"0.0"
}
Based on the comparison between the json text of the first response packet and the first set, it can be seen that all nodes in the first set are at the same level, and further all key-value pairs are at the same level, so that the difference between the first set and the third set can be conveniently compared, and the first difference set can be conveniently determined.
Because the noise difference in the first difference set needs to be filtered out, and the influence of the noise difference on judging whether the update code is correct is eliminated, the difference type needs to be defined, and thus the difference type in the first difference set is determined. Next in step S230, first, second and third type differences are determined. In one embodiment of the present invention, defining the first type of difference includes a key-value pair where the key is present in the first response message and not present in the third response message, the second type of difference includes a key-value pair where the key is not present in the first response message and present in the third response message, and the third type of difference includes a key-value pair where the key is present in both the first and third response messages and the corresponding key values are not consistent in the first response message and the third response message, the third type of difference is the above-mentioned 1) type of difference, i.e., a difference that is considered to be noise.
By defining the difference types in the above manner, it is possible to determine the difference types in the first difference set, and further determine whether the update code is correct, and then in step S240, when the first difference set includes the first type difference and/or the second type difference, it is determined that the update code has an error, and when the first difference set does not have any difference, the update code is correct, whereas in step S250, when the first difference set includes the third type difference, in step S260, the first response message is compared with the second response message to obtain the second difference set, and a difference key-value pair, in which the key exists in both the first and second response messages and the corresponding key value is not consistent in the first response message and the second response message, is obtained from the second difference set. Subsequently, in step S270, the key-value pairs corresponding to the acquired difference key-value pairs are removed from the third-type differences. Next, in step S280, if the removed third-type difference does not include any key-value pairs, the update code is error-free.
However, when there is a second-level timestamp on the interface of the computing device 100, a third-type difference may occur in which the timestamp is unchanged within 1 second for two previous requests of the code execution environment due to a short response time, and the timestamp difference (i.e., the above-mentioned 1) type difference) cannot be identified as the second difference set. When the code running environment is requested to be updated, the timestamp difference is included in the third type difference of the first difference set due to the timestamp change, and after the key-value pair corresponding to the acquired difference key-value pair is removed from the third type difference, the timestamp difference still exists in the third type difference, at this time, the computing device 100 may make a judgment that the update code has an error, but actually, the timestamp difference is not caused by the code update, so that a misjudgment situation occurs.
In order to solve the above problem, in an embodiment of the present invention, a first response packet and a second response packet are obtained from a runtime environment in which a previous code is deployed, and a third response packet is obtained from a runtime environment in which an update code is deployed, in the following order: the method includes acquiring a first response message from a runtime environment deployed with a previous code, acquiring a third response message from a runtime environment deployed with an updated code, and acquiring a second response message from a runtime environment deployed with a previous code.
Thus, if the timestamps of the two requests of the previous code change, the difference is identified, and if the timestamps of the two requests of the previous code do not change, the time is elapsed, and the timestamps of the update codes of the intermediate requests are also consistent, so that after the key-value pair corresponding to the acquired difference key-value pair is removed from the difference of the third type, the timestamp difference does not exist in the difference of the third type, and the misjudgment condition does not occur.
According to the method, the difference items can be automatically classified, the difference called as noise can be automatically identified, the difference identified as the noise can be automatically filtered in the process of testing the update codes, particularly the difference of the timestamp fields can be filtered by 100%, the method is simple to realize and does not need manual pre-configuration, so that the efficiency of judging whether the update codes are correct is greatly improved, and manual neglect configuration of partial nodes in the response message can be still overlapped on the basis.
Since the third type differences of the first difference set may include 1) type differences and 3) type differences, in another embodiment of the present invention, based on the detection method 200 for correctness of code update, the content of the response message corresponding to the 3) type differences is configured in advance, so as to filter out all the 1) type differences and 3) type differences that may be included in the third type differences during the test process. Fig. 400 is a diagram illustrating a method for detecting correctness of code update according to another embodiment of the present invention, where the method 400 starts from step S401 and ends at step S410. Step S401 to step S405 are the same as step S210 to step S250, and are not described herein again, and step S406 to step S410 are described next.
It is determined in step S405 that when the first difference set comprises only differences of the third type: in step S406, the key values of the partial key-value pairs in the first response packet, the second response packet, and the third response packet are sorted to obtain the sorted first response packet, second response packet, and third response packet. For example, a designated child node (key of a key-value pair) is taken out from 3 response messages, if the child node is not an array, the child node is ignored, if the child node is an array, text sorting is performed on a first-layer element (key value corresponding to the key) in the child node, and then the child node and the corresponding sorted first-layer element (the sorted key-value pair) are placed back to the position where an atomic node of a json text corresponds to the corresponding first-layer element, so that when the sorted response messages are compared, 3) type differences considered as noise can be filtered out, and erroneous judgment of an update code due to different array sequences can be avoided. However, the present invention is not limited to the above method, and any method capable of sorting the key-value pairs in the first response packet, the second response packet, and the third response packet is within the protection scope of the present invention.
Subsequently, in step S407, the sorted first response packet is compared with the third response packet to obtain a new first difference set. Wherein the new first set of differences includes only third type differences and 3) type differences of the third type differences in the new first set of differences are filtered out, and thus, the third type differences of the new first set of differences includes only 1) type differences, the third type differences in the new first set of differences being different from the third type differences in the first set of differences.
After the first difference set is determined, in step S408, the sorted first response packet is compared with the second response packet to obtain a new second difference set, and a difference key-value pair, where the key exists in both the first and second response packets and the corresponding key value is inconsistent in the first and second response packets, is obtained from the new second difference set as a new difference key-value pair, and in step S409, the key-value pair corresponding to the obtained new difference key-value pair is removed from the third type difference of the new first difference set. Next in step S410, if the third-type differences of the removed new first difference set do not include any key-value pairs, then there is no error in updating the code.
By the method, the difference items can be automatically classified, the difference called as noise can be automatically identified, all the differences considered as noise are automatically filtered in the process of testing the updated code, the method is simple to realize, manual pre-configuration is not needed, and the efficiency of judging whether the updated code is correct is greatly improved.
Fig. 5 shows a schematic diagram of a device 500 for detecting correctness of code update according to an embodiment of the present invention. The code update correctness detection apparatus 500 is adapted to perform the code update correctness detection method 200 of the present invention. The code update correctness detection apparatus 500 resides in the computing device 100, so that the computing device 100 executes the code update correctness detection method 200 of the present invention.
As shown in fig. 5, the apparatus 500 for detecting correctness of code update includes an obtaining module 510, a comparing module 520, a difference type determining module 530, a determining module 540, and a removing module 550.
According to one embodiment, the obtaining module 510 obtains a first response message and a second response message from the runtime environment deployed with the previous code, and obtains a third response message from the runtime environment deployed with the updated code, where the first, second, and third response messages all include one or more key-value pairs;
according to an embodiment, the first response packet is compared with the third response packet by a comparison module 520 to obtain a first difference set; and when the first set of differences includes only differences of a third type: comparing the first response message with the second response message through a comparison module 520 to obtain a second difference set, wherein a difference key-value pair, in which keys exist in both the first and second response messages and corresponding key values are inconsistent in the first response message and the second response message, is obtained from the second difference set as a first key-value pair;
according to one embodiment, the first, second, and third type differences are determined by the difference type determination module 530, the first type differences including key-value pairs where the key is present in the first response message and not present in the third response message, the second type differences including key-value pairs where the key is not present in the first response message and present in the third response message, and the third type differences including key-value pairs where the corresponding key values are not consistent in the first response message and the third response message where the key is present in both the first and third response messages;
according to one embodiment, when the first difference set includes a first type difference and/or a second type difference, it is determined by the determining module 540 that there is an error in the updated code; and if the removed third type difference does not include any key-value pair, determining, by the determining module 540, that there is no error in the updated code.
According to one embodiment, when the first set of differences comprises only differences of a third type: the key-value pairs corresponding to the obtained difference key-value pairs are removed from the third type of difference by the removal module 550.
It should be noted that, the obtaining module 510 is specifically configured to execute the method of the foregoing step S210, the comparing module 520 is specifically configured to execute the methods of the foregoing steps S220 and S250-S260, the difference type determining module 530 is specifically configured to execute the method of the foregoing step S230, the determining module 540 is specifically configured to execute the methods of the foregoing steps S240 and S280, and the removing module 550 is specifically configured to execute the method of the foregoing step S270, and for processing logics and functions of the obtaining module 510, the comparing module 520, the difference type determining module 530, the determining module 540, and the removing module 550, reference may be made to the relevant descriptions of the foregoing steps S210 to S280, which are not described herein again. Similarly, the apparatus 500 for detecting correctness of code update is suitable for executing the method 400 for detecting correctness of code update according to another embodiment of the present invention, which is not described herein again.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the mobile terminal generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the code update correctness detection method of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense with respect to the scope of the invention, as defined in the appended claims.

Claims (10)

1. A method for detecting correctness of a code update, executed in a computing device having a runtime environment deployed therein for running a previous code and an updated code, the method comprising:
acquiring a first response message and a second response message from a running environment with a deployed previous code, and acquiring a third response message from a running environment with a deployed updated code, wherein the first response message, the second response message and the third response message all comprise one or more key-value pairs;
comparing the first response message with the third response message to obtain a first difference set;
determining first, second and third type differences, the first type difference comprising a key-value pair where the key is present in the first response message and not present in the third response message, the second type difference comprising a key-value pair where the key is not present in the first response message and present in the third response message, and the third type difference comprising a key-value pair where the corresponding key value is not consistent in the first response message and the third response message where the key is present in both the first and third response messages;
determining that the update code has an error when the first set of differences includes a first type of difference and/or a second type of difference; and
when the first set of differences includes only differences of a third type:
comparing the first response message with the second response message to obtain a second difference set, and acquiring a difference key-value pair, in which keys exist in the first response message and the second response message and corresponding key values are inconsistent in the first response message and the second response message, from the second difference set;
removing key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference; and
if the removed third-type difference does not include any key-value pairs, then the update code is error free.
2. The method of claim 1, wherein said comparing said first response packet to said third response packet to obtain a first set of differences comprises:
extracting paths and values corresponding to all nodes from the first response message, wherein the nodes comprise leaf nodes;
taking the path corresponding to each node as a key and the value as a key value to form a key-value pair, and taking one or more key-value pairs as a first set;
extracting paths and values corresponding to all nodes from the third response message, wherein the nodes comprise leaf nodes;
taking the path corresponding to each node as a key and the value as a key value to form a key-value pair, and taking one or more key-value pairs as a third set;
and comparing the first set with the third set to obtain the first difference set.
3. The method of claim 1, further comprising:
sorting key values of partial key-value pairs in the first response message, the second response message and the third response message to obtain the sorted first response message, the second response message and the third response message;
comparing the sorted first response packet with the sorted third response packet to obtain a new first difference set, where the new first difference set only includes a third type difference, and the third type difference in the new first difference set is different from the third type difference in the first difference set.
4. The method of claim 3, wherein the sorting key values of partial key-value pairs in the first response packet, the second response packet, and the third response packet comprises:
extracting partial key-value pairs from the first response message, the second response message and the third response message;
sorting the key values of the extracted partial key-value pairs to obtain sorted partial key-value pairs;
and putting the sorted partial key-value pairs back to positions corresponding to the extracted partial key-value pairs of the first response message, the second response message and the third response message.
5. The method of claim 3 or 4, wherein said comparing said first response packet with said second response packet to obtain a second set of differences comprises:
comparing the sorted first response message with the second response message to obtain a new second difference set;
and obtaining a difference key-value pair, which is obtained from the new second difference set, wherein the keys exist in the first response message and the second response message, and the corresponding key values are inconsistent in the first response message and the second response message, and the difference key-value pair is used as a new difference key-value pair.
6. The method of claim 5, wherein said removing key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference comprises:
removing key-value pairs corresponding to the obtained new difference key-value pairs from the third type of difference of the new first difference set.
7. The method of any one of claims 1 to 6, wherein the first and second response messages are obtained from the runtime environment deployed with the previous code and the third response message is obtained from the runtime environment deployed with the updated code in the following order:
acquiring a first response message from a running environment with a deployed previous code;
acquiring a third response message from the running environment with the deployed updating code; and
and acquiring a second response message from the operating environment with the deployed previous code.
8. An apparatus for detecting correctness of a code update, executed in a computing device having a runtime environment deployed therein for running a previous code and an updated code, the apparatus comprising:
the acquisition module is used for acquiring a first response message and a second response message from the operating environment with the deployed previous code and acquiring a third response message from the operating environment with the deployed updated code, wherein the first response message, the second response message and the third response message all comprise one or more key-value pairs;
the comparison module is used for comparing the first response message with the third response message to obtain a first difference set; and when the first set of differences includes only differences of a third type: comparing the first response message with the second response message through the comparison module to obtain a second difference set, wherein a difference key-value pair, in which keys exist in the first response message and the second response message and corresponding key values are inconsistent, is obtained from the second difference set as a first key-value pair;
a difference type determining module, configured to determine first, second, and third type differences through the difference type determining module, where the first type difference includes a key-value pair that the key exists in the first response packet and does not exist in the third response packet, the second type difference includes a key-value pair that the key does not exist in the first response packet and exists in the third response packet, and the third type difference includes a key-value pair that the key exists in both the first and third response packets and the corresponding key value does not coincide in the first response packet and the third response packet;
the judging module is used for determining that the updating code has errors when the first difference set comprises a first type difference and/or a second type difference; and if the removed third type difference does not comprise any key-value pair, judging that the update code has no error through the judging module.
A removal module to, when the first set of differences includes only third type differences: removing, by the removal module, key-value pairs corresponding to the obtained difference key-value pairs from the third type of difference.
9. A computing device, comprising:
at least one processor; and
a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-7.
10. A readable storage medium storing program instructions that, when read and executed by a mobile terminal, cause the mobile terminal to perform the method of any of claims 1-7.
CN202010659335.XA 2020-07-09 2020-07-09 Code updating correctness detection method and device and computing equipment Active CN111930612B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010659335.XA CN111930612B (en) 2020-07-09 2020-07-09 Code updating correctness detection method and device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010659335.XA CN111930612B (en) 2020-07-09 2020-07-09 Code updating correctness detection method and device and computing equipment

Publications (2)

Publication Number Publication Date
CN111930612A true CN111930612A (en) 2020-11-13
CN111930612B CN111930612B (en) 2024-03-19

Family

ID=73312269

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010659335.XA Active CN111930612B (en) 2020-07-09 2020-07-09 Code updating correctness detection method and device and computing equipment

Country Status (1)

Country Link
CN (1) CN111930612B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791983A (en) * 2021-09-24 2021-12-14 北京顺源开华科技有限公司 Application code testing method and device and electronic equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106569844A (en) * 2016-09-23 2017-04-19 北京五八信息技术有限公司 Processing method, processing device and equipment for program code update
CN108491331A (en) * 2018-04-13 2018-09-04 平安普惠企业管理有限公司 Method for testing software, device, equipment and computer storage media
CN108595200A (en) * 2018-04-19 2018-09-28 北京微播视界科技有限公司 Code update method, figure update method, device, storage medium and terminal
CN109271313A (en) * 2018-08-13 2019-01-25 中国平安财产保险股份有限公司 Code test method, device and computer readable storage medium
CN109460220A (en) * 2018-10-19 2019-03-12 泰康保险集团股份有限公司 The predefined code generating method of message, device, electronic equipment and storage medium
CN109710522A (en) * 2018-12-17 2019-05-03 平安普惠企业管理有限公司 Code test method, device, computer equipment and storage medium
US10635566B1 (en) * 2017-07-31 2020-04-28 Cisco Technology, Inc. Predicting code change impact within an integrated development environment
US20200133656A1 (en) * 2018-10-30 2020-04-30 Walmart Apollo, Llc Systems and methods for differential bundle updates
CN111209180A (en) * 2018-11-21 2020-05-29 中国移动通信集团浙江有限公司 Regression testing method and device based on fuzzy matching

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106569844A (en) * 2016-09-23 2017-04-19 北京五八信息技术有限公司 Processing method, processing device and equipment for program code update
US10635566B1 (en) * 2017-07-31 2020-04-28 Cisco Technology, Inc. Predicting code change impact within an integrated development environment
CN108491331A (en) * 2018-04-13 2018-09-04 平安普惠企业管理有限公司 Method for testing software, device, equipment and computer storage media
CN108595200A (en) * 2018-04-19 2018-09-28 北京微播视界科技有限公司 Code update method, figure update method, device, storage medium and terminal
CN109271313A (en) * 2018-08-13 2019-01-25 中国平安财产保险股份有限公司 Code test method, device and computer readable storage medium
CN109460220A (en) * 2018-10-19 2019-03-12 泰康保险集团股份有限公司 The predefined code generating method of message, device, electronic equipment and storage medium
US20200133656A1 (en) * 2018-10-30 2020-04-30 Walmart Apollo, Llc Systems and methods for differential bundle updates
CN111209180A (en) * 2018-11-21 2020-05-29 中国移动通信集团浙江有限公司 Regression testing method and device based on fuzzy matching
CN109710522A (en) * 2018-12-17 2019-05-03 平安普惠企业管理有限公司 Code test method, device, computer equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791983A (en) * 2021-09-24 2021-12-14 北京顺源开华科技有限公司 Application code testing method and device and electronic equipment

Also Published As

Publication number Publication date
CN111930612B (en) 2024-03-19

Similar Documents

Publication Publication Date Title
US10185650B1 (en) Testing service with control testing
WO2018000607A1 (en) Method and electronic apparatus for identifying test case failure causes
CN110474900B (en) Game protocol testing method and device
CN104978526A (en) Virus signature extraction method and apparatus
CN108875317B (en) Software clone detection method and device, detection equipment and storage medium
CN109271315B (en) Script code detection method, script code detection device, computer equipment and storage medium
CN111737137A (en) Interface test data generation method and device, host and storage medium
US11399071B2 (en) Program operation system and program operation method
CN113032580A (en) Associated file recommendation method and system and electronic equipment
CN111930612B (en) Code updating correctness detection method and device and computing equipment
CN109542462B (en) System environment deployment method, storage medium and server
US10073938B2 (en) Integrated circuit design verification
WO2016122318A1 (en) A computer implemented method for generating a variant call file
CN110430140A (en) Path processing method, device, equipment and storage medium
CN113778834B (en) System performance testing method and device of application software and computing equipment
CN114816772A (en) Debugging method, debugging system and computing device for application running based on compatible layer
CN110715799B (en) Method and device for detecting mechanical state of circuit breaker and terminal equipment
CN110503504B (en) Information identification method, device and equipment of network product
EP3249547A1 (en) Generating test data from samples using natural language processing and structure-based pattern determination
CN114912587A (en) Neural network distributed training system, method, device, computing unit and medium
CN111371818B (en) Data request verification method, device and equipment
US7650579B2 (en) Model correspondence method and device
JP2019215867A (en) Method and system for verifying properties of source code
CN113032038B (en) Application program management method and device, computing equipment and readable storage medium
CN116319762B (en) File batch copying method and device in local area network, electronic 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
GR01 Patent grant
GR01 Patent grant