Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Please refer to fig. 1. The embodiment of the application provides a function obtaining method. The function acquisition method takes a server as an execution subject. The server may be one server or a server cluster including a plurality of servers. The function acquisition method may include the following steps.
Step S11: and acquiring a function identifier of the changed function in the first service system as the function identifier in the function identifier set.
In this embodiment, the number of the first service coefficients may be one or more. The first service system may be, for example, a service system such as a balance treasure, a fund, a periodic system, and the like. The functions are understood to be a set of computer program instructions capable of performing certain functions. The function identifier may be used to identify a function, and specifically may be a name or a code of the function. For example, the function identification of the product information query function QueryProductById () may be the name QueryProductById of the product information query function.
In this embodiment, the number of functions in the first service system may be one or more. The change of the source code of the first service system may cause the change of the interface function and/or the non-interface function of the first service system. For example, a developer fixes a software bug of the first business system, which may result in a change of an interface function and/or a non-interface function of the first business system. In this way, the server can acquire the source code of the current version and the source code of the historical version of the first business system through a version control tool; the method comprises the steps that a function identifier of a function changed by a first business system can be obtained based on a source code of a current version and a source code of a historical version of the first business system; the function identifier of the function in which the first service system is changed may be used as the function identifier in the function identifier set. Wherein, the version control tool is computer software for providing software version management function and storing, recording and tracking software version modification history. The version control tool may be, for example, SVN (version, a cross-platform open source version control tool), Git (an open source distributed version control tool), or the like. The function of the first service system change can be, for example, a newly added function, a modified function, a deleted function, and the like.
The server may compare the source code of the current version with the source code of the historical version of the first service system to obtain a function identifier of a function in which the first service system changes. Of course, the server may also construct an abstract syntax tree of the source code of the current version and an abstract syntax tree of the source code of the historical version of the first service system; the method includes the steps that function identifications of all functions in the current version of the first service system can be obtained based on an abstract syntax tree of a source code of the current version of the first service system and serve as function identifications in a first function identification set; function identifiers of functions in the historical version of the first service system can be obtained based on the abstract syntax tree of the source code of the historical version of the first service system and serve as function identifiers in a second function identifier set; the function identifier in the first function identifier set and the function identifier in the second function identifier set may be compared to obtain the function identifier of the function that the first service system changes. Wherein, the Abstract Syntax Tree (AST) is a Tree representation of the source code Abstract Syntax structure.
Alternatively, in this embodiment, in order to simplify the implementation of the first business system, for a relatively mature function, a developer may introduce a third-party computer program for implementing the function into the first business system. The third party computer program may be an open source package, such as Spring (an open source framework), Struts (an open source framework), and the like. Here, a third party computer program introduced by the first business system may be a component of the first business system. That is, the first business system may be considered to include the third party computer program. In this way, the server can obtain the source code of the current version and the source code of the historical version of the third-party computer program; the method comprises the steps of obtaining a function identifier of a function of the third-party computer program which is changed based on a source code of a current version and a source code of a historical version of the third-party computer program; the function identifier of the function in which the third-party computer program is changed can be used as the function identifier in the function identifier set. The function of the third-party computer program that is changed may be, for example, a newly added function, a modified function, a deleted function, and the like.
The server may compare the source code of the current version with the source code of the historical version of the third-party computer program to obtain a function identifier of a function in which the third-party computer program changes. Of course, the server may also obtain the bytecode of the current version of the third-party computer program based on the source code of the current version of the third-party computer program; analyzing the bytecode of the current version of the third-party computer program through a bytecode manipulation frame to obtain function identifications of each function in the current version of the third-party computer program, wherein the function identifications are used as function identifications in a third function identification set; the bytecode of the historical version of the third-party computer program can be acquired based on the source code of the historical version of the third-party computer program; analyzing the bytecode of the third-party computer program historical version through a bytecode manipulation frame to obtain function identifiers of all functions in the third-party computer program historical version as function identifiers in a fourth function identifier set; the function identifiers in the third function identifier set and the fourth function identifier set may be compared to obtain the function identifier of the function that the third-party computer program changes. Wherein the bytecode manipulation framework is computer software for creating, modifying and analyzing the bytecode of the computer program. The bytecode manipulation framework can be, for example, ASM, AspectJ, BCEL, Byte Buddy, CGLIB, Cojen, javasissst, Serp, etc. The bytecode (Byte-code) is a binary file that contains the execution program and is composed of a sequence of op code and/or data pairs. The bytecode can be understood as an intermediate code, which is more abstract than machine code.
Step S12: and constructing a node association network.
In this embodiment, the node-associated network may include one or more nodes, and each node may correspond to a function identifier of a function in the second service system. The node association network may further include a directed association relationship between nodes. The directed association relationship between the nodes can be understood as a directed relationship between the nodes. In particular, in the node association network, each node may have a directed association relationship with one or more other nodes. That is, in the node-associated network, each node may point to 0, 1, or more other nodes, and each node may also be pointed to by 0, 1, or more other nodes. Nodes in the node association network that are not pointed to by other nodes may be referred to as interface nodes. That is, the node pointed to by 0 nodes in the node-associated network may be used as an interface node. The corresponding function of the interface node in the second service system is typically an interface function.
The number of the second traffic coefficients may be one or more. The second service system may be, for example, a service system such as a balance treasure, a fund, a periodic system, and the like. The second service system and the first service system may be the same or different. When the second business system is different from the first business system, the second business system and the first business system may have an association relationship. Here, the second service system and the first service system have an association relationship, which may be understood as: and service data interaction can be carried out between the second service system and the first service system. For example, the second business system may receive and process business data from the first business system, and the business data may include transaction amount, and the like.
In this embodiment, the number of functions in the second service system may be one or more. The server can obtain function identification of functions in the second service system and call relation among the functions; the function identifier of the function in the second service system may be used as a node, and a node association network may be constructed based on the call relationship between the functions in the second service system.
For example, the second service system may include functions Function _ a (), Function _ B (), Function _ C (), Function _ D (), and Function _ E (). The Function _ a () may call the functions Function _ B (), Function _ C (), and Function _ D (). The functions Function _ C (), Function _ D () can call the Function _ E (), respectively. The Function identification of the Function _ a () may be Function _ a; the Function identification of the Function _ B () may be Function _ B; the Function identification of the Function _ C () may be Function _ C; the Function identification of the Function _ D () may be Function _ D; the Function identification of the Function _ E () may be Function _ E.
Then, the server may use the Function identifier Function _ a as the node Function _ a, the Function identifier Function _ B as the node Function _ B, the Function identifier Function _ C as the node Function _ C, the Function identifier Function _ D as the node Function _ D, and the Function identifier Function _ E as the node Function _ E to construct the node-associated network shown in fig. 2. In the node-associated network shown in fig. 2, the node Function _ a may point to the node Function _ B, Function _ C, Function _ D, and the node Function _ C and the node Function _ D may point to the node Function _ E, respectively. In the node-associated network shown in fig. 2, the node Function _ a may be an interface node.
In this embodiment, the server may obtain a bytecode of the second service system; the bytecode of the second service system can be analyzed by using a bytecode manipulation framework to obtain function identifiers of functions in the second service system and call relations among the functions.
In an implementation manner of this embodiment, the server may obtain, from the bytecode of the second service system, a function identifier of a function in the second service system. The source code of the second business system may be, for example, as follows.
Correspondingly, the bytecode of the second service system may be as follows.
Then the server may obtain A, B, C, D, E, F a function identification for the function in the second service system from the bytecode of the second service system.
In one embodiment of this embodiment, the call relationship between functions may include a direct call relationship and an indirect call relationship.
For example, the Function _ a () Function body includes computer program instructions for calling the Function _ B (). Then, it can be considered that the Function _ a () directly calls the Function _ B ().
As another example, the Function _ a () Function body includes computer program instructions for sending a message and the Function _ C () Function body includes computer program instructions for receiving the message. Then, the Function _ a () and the Function _ C () can be considered to be associated through the message, and specifically, the Function _ a () can be considered to indirectly call the Function _ C () through the message.
In this embodiment, a preset key in the bytecode may be used to identify the call relationship between functions.
For example, the Function _ a () bytecode includes 2 preset keywords invokevirtual, one of which corresponds to the Function identification Function _ B, and the other of which corresponds to the Function identification Function _ D. Then, it can be considered that the Function _ a () directly calls the Function _ B () which can be a Function identified by the Function identification Function _ B, and the Function _ D () which can be a Function identified by the Function identification Function _ D, respectively.
For another example, the Function _ a () bytecode includes a preset Function identifier, a preset keyword TP, and a preset keyword EC, where the preset Function identifier may be a Function identifier of a Function used for sending a message. Then, the Function _ a () can be considered for sending a message. Specifically, for example, in the Function _ a () bytecode, the attribute value corresponding to the preset key TP may be TPXXX, and the attribute value corresponding to the preset key EC may be ECXXX. Then, the Function _ a () may be considered to be used to transmit the Message _ TPXXX _ ECXXX, and the attribute values of the Message _ TPXXX _ ECXXX may include TPXXX and ECXXX.
The Function _ C () bytecode includes a preset keyword concumer, a preset keyword TP, and a preset keyword EC. Then, the Function _ C () can be considered for receiving a message. Specifically, for example, in the bytecode of the Function _ C (), the attribute value corresponding to the preset key TP may be TPXXX, and the attribute value corresponding to the preset key EC may be ECXXX. Then, the Function _ C () can be considered to be used to receive the Message _ TPXXX _ ECXXX.
Then, the Function _ a () and the Function _ C () may be considered to be associated by the Message _ TPXXX _ ECXXX, and specifically, the Function _ a () may be considered to indirectly call the Function _ C () by the Message _ TPXXX _ ECXXX.
As such, in this embodiment, for each function in the second service system, the server may obtain the function bytecode from the second service system bytecode; under the condition that the function byte code comprises at least one first preset keyword, acquiring a function identifier corresponding to each first preset keyword in the function byte code; the function can be identified, and the calling relation between the functions identified by the function identification corresponding to each first preset keyword is respectively identified. Specifically, the server may identify that the function is respectively and directly called, and each first preset keyword corresponds to the function identified by the function identifier. The first preset keyword may be invokevirtual, for example.
Or, in this embodiment, for each function in the second service system, the server may obtain the function bytecode from the second service system bytecode; under the condition that the function byte code comprises a second preset keyword and a third preset keyword, a corresponding first attribute value of the second preset keyword in the function byte code can be obtained; a second attribute value corresponding to a third preset keyword in the function byte code can be obtained; this function may be taken as the first function. The second preset keyword may be TP, for example, and the third preset keyword may be EC, for example.
The server may obtain a second function from the second service system. Wherein the second function is different from the first function. The second function may include a second preset keyword and a third keyword. The attribute value of the second preset keyword in the second function byte code is the same as the first attribute value; and the attribute value of the third preset keyword in the second function byte code is the same as the second attribute value. The server may then identify a call relationship between the first function and the second function.
Further, the server may identify whether the first function bytecode and the second function bytecode include a preset function identifier or a fourth preset keyword, respectively. The fourth preset keyword may be, for example, a Consumer, and the preset function identifier may be a function identifier of a function used for sending a message. Under the condition that the first function bytecode is recognized to contain the preset function identifier and the second function bytecode is recognized to contain the fourth preset keyword, the server can recognize that the first function indirectly calls the second function. Under the condition that the first function bytecode and the second function bytecode are recognized to contain the fourth preset keyword and the preset function identifier, the server can recognize that the second function indirectly calls the first function.
Step S13: and acquiring at least one interface node from the node association network by using the directed association relation among the nodes in the node association network based on the function identifiers in the function identifier set.
In this embodiment, as described above, the node association network may include a directed association relationship between nodes. Nodes in the node association network that are not pointed to by other nodes may serve as interface nodes. Thus, for each function identifier in the function identifier set, the server may obtain a node corresponding to the function identifier in the node association network; under the condition that the acquisition node is an interface node, the interface node corresponding to the function identifier can be acquired; under the condition that the acquisition node is not an interface node, the acquisition node can be used as a target node, and the directed association relation can be acquired from the node association network as the interface node pointing to the target node. Here, the server obtains the corresponding node of the function identifier in the node association network, which may be understood as; searching a node with the same function identifier in the node correlation network; here, the directed association relationship is an interface node pointing to the target node, and may include: the directed association is an interface node that points directly to the target node, or the directed association is an interface node that points indirectly to the target node via one or more intermediate nodes.
Please refer to fig. 6. Specifically, the server may obtain one function identifier in the set of function identifiers; the node corresponding to the function identifier in the node association network can be obtained; under the condition that the acquisition node is an interface node, the interface node corresponding to the function identifier can be acquired, and the function identifier can be deleted from the function identifier set; under the condition that the obtaining node is not an interface node, the obtaining node may be used as a target node, at least one node having a directed association relationship directly pointing to the target node may be obtained from the node association network, each node in the at least one node may be used as a function identifier in the function identifier set, and the function identifier may be deleted from the function identifier set. The server may repeatedly perform the above process until the number of function identifiers in the set of function identifiers is 0.
Of course, in this embodiment, the server may further obtain at least one interface node from the node association network by using a preset algorithm. The preset algorithm may be, for example, a Breadth-First-Search algorithm (break-First-Search), a Depth-First-Search algorithm (Depth-First-Search), or the like.
For example, the node association network may be as shown in fig. 3. In the node-associated network shown in fig. 3, the nodes CreateTrade and CloseTrade are interface nodes. The set of function identifications may include function identifications queryproductByld and CreateTrade.
Then, for the function identifier CreateTrade in the function identifier set, the server may obtain the node CreateTrade corresponding to the function identifier CreateTrade from the node association network. The node CreateTrade may be an interface node. Therefore, the server can directly obtain the interface node CreateTrade, and can delete the function identifier CreateTrade from the function identifier set. At this time, the function identification set may include a function identification queryProductByld.
For a function identifier queryProductByld in the function identifier set, the server may obtain a node queryProductByld corresponding to the function identifier queryProductByld from the node association network. The node queryproductByld is not an interface node, and the server can acquire a node CreatePartNerP2PTradeAction with a directed incidence relation directly pointing to the node queryproductByld from the node incidence network; the node CreatePartnerP2 ptradaction may be used as a function identifier in the function identifier set; the function identification queryProductByld may be deleted from the set of function identifications. At this time, the function identification set may include a function identification queryProductByld.
For a function identifier queryProductByld in the function identifier set, the server may obtain a node queryProductByld corresponding to the function identifier queryProductByld from the node association network. The node queryProductByld is not an interface node, and the server can acquire a node CreateTrade of which the directed association relationship is directly pointing to the node queryProductByld from the node association network; the node CreateTrade can be used as a function identifier in the function identifier set; the function identity CreateTrade may be deleted from the set of function identities. At this time, the function identification set may include a function identification CreateTrade.
For the function identifier CreateTrade in the function identifier set, the server may obtain a node CreateTrade corresponding to the function identifier CreateTrade from the node association network. The node CreateTrade may be an interface node. Therefore, the server can directly obtain the interface node CreateTrade, and can delete the function identifier CreateTrade from the function identifier set. At this time, the number of function identifiers in the function identifier set may be 0. Thus, the server can end the interface node acquisition process.
In this embodiment, the server may obtain a function identifier of a function that has changed in the first service system, as a function identifier in the function identifier set; a node association network can be constructed, wherein the node association network comprises at least one node, each node is a function identifier of a function in the second service system, and the node association network comprises a directed association relation between the nodes; at least one interface node can be obtained from the node association network based on the function identifier in the function identifier set by using the directed association relationship among the nodes, wherein the interface node is a node which is not pointed by other nodes in the directed association relationship in the node association network. Compared with the prior art, the first service system and the second service system can be the same or different; the function identification set may include a function identification of an interface function or a function identification of a non-interface function that is changed in the first service system. Therefore, the server of the embodiment can analyze the interface function affected by the change of the interface function or the non-interface function of the software, and the change of other software interface functions or non-interface functions associated with the software. Therefore, the embodiment can accurately analyze the interface function influenced by the software change, thereby helping a tester to screen out a proper test case.
Please refer to fig. 4. The embodiment of the application also provides a server. The server may include a memory and a processor.
In this embodiment, the Memory includes, but is not limited to, a hard disk, a usb disk, a RAM (Random-Access Memory), a ROM (Read-Only Memory), and the like. The memory may be used to store computer program instructions.
In this embodiment, the processor may be implemented in any suitable manner. For example, the processor may take the form of, for example, a microprocessor or processor and a computer-readable medium that stores computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, an embedded microcontroller, and so forth.
In this embodiment, the processor may be configured to read and execute the computer program instructions; acquiring a function identifier of a function which is changed in a first service system, and using the function identifier as a function identifier in a function identifier set; constructing a node correlation network; wherein the node association network comprises at least one node; each node is a function identification of a function in the second service system; the node association network comprises directed association relations among nodes; acquiring at least one interface node from the node association network based on the function identifier in the function identifier set by using the directed association relation among the nodes; the interface node is a node in the node association network, and the directed association relationship is not pointed to by other nodes.
The specific functions of the server, its memory and processor, which are disclosed in the embodiments of the present application, can be explained in contrast to the foregoing embodiments in the present application.
Please refer to fig. 5. The embodiment of the application also provides a function acquisition device. The device comprises a function identification obtaining unit 51, a node association network constructing unit 52 and an interface node obtaining unit 53. Wherein,
a function identifier obtaining unit 51, configured to obtain a function identifier of a function that is changed in the first service system, as a function identifier in the function identifier set;
a node-associated network construction unit 52 configured to construct a node-associated network; wherein the node association network comprises at least one node; each node is a function identification of a function in the second service system; the node association network comprises directed association relations among nodes;
an interface node obtaining unit 53, configured to obtain at least one interface node from the node association network based on the function identifier in the function identifier set by using the directed association relationship between the nodes; the interface node is a node in the node association network, and the directed association relationship is not pointed to by other nodes.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment is described with emphasis on differences from other embodiments. In particular, for server and computer storage media embodiments, because they are substantially similar to method embodiments, the description is relatively simple, and reference may be made to some descriptions of method embodiments for relevant points.
In addition, it is understood that one skilled in the art, after reading this document, may conceive of combinations of some or all of the embodiments recited in this document without the need for inventive faculty, which combinations are also within the scope of the disclosure and protection of this document.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate a dedicated integrated circuit chip 2. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most popular applications. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments of the present application.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
While the present application has been described with examples, those of ordinary skill in the art will appreciate that there are numerous variations and permutations of the present application without departing from the spirit of the application, and it is intended that the appended claims encompass such variations and permutations without departing from the spirit of the application.