Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with related laws and regulations and standards, and provide corresponding operation entries for the user to select authorization or rejection.
It should be noted that the method, the device, the equipment and the storage medium for detecting the software running environment of the present application can be used in the big data field, and can also be used in any field except the big data field.
In the process of performing software function test based on the software running environment, software in the downstream software running environment can extract service data from the upstream software running environment, but the situation that the follow-up data is in overall error due to the fact that the software in the downstream software running environment is in error with the upstream software running environment exists, and at present, whether the software in the downstream software running environment is connected to the correct upstream software running environment or not can be determined by manually performing connection comparison or data comparison of the upstream software running environment. However, the comparison is performed manually, so that the problems of time and labor consumption and lower efficiency exist, and comparison errors or omission may occur, so that the test or development time is wasted and the overall task progress is influenced.
Based on the above problems, the present application provides a method, an apparatus, a device and a storage medium for detecting a software running environment, which automatically acquire data in a database table or data in a log generated by software running in a current software running environment, and determine data source information corresponding to the data, so as to determine whether the current software running environment is connected to a correct upstream software running environment according to the data source information. On the basis of ensuring that whether the current software running environment is connected to the correct upstream software running environment or not is accurately determined, the efficiency of software running environment detection can be greatly improved, the development or test efficiency is improved, and the development cost is reduced.
In the following, first, an application scenario of the solution provided by the present application is illustrated.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application. As shown in fig. 1, the application scenario may include: server cluster 101 and server cluster 102. The server cluster 101 corresponds to a downstream software running environment, and the server cluster 102 corresponds to an upstream software running environment; the server cluster 101 is in communication connection with the server cluster 102; the server cluster 101 includes a plurality of servers 1011, and the server cluster 102 includes a plurality of servers 1021. Software running on server 1011 extracts business data from server 1021. The server 1011 obtains data in a database table generated by the software operation or data in a log from the current software operation environment, and determines data source information corresponding to the data, thereby determining whether the current software operation environment is connected to the correct upstream software operation environment according to the data source information.
It should be noted that fig. 1 is only a schematic diagram of an application scenario provided by an embodiment of the present application, and the embodiment of the present application does not limit the devices included in fig. 1 or limit the positional relationship between the devices in fig. 1.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a software running environment detection method according to an embodiment of the present application, where the method according to the embodiment of the present application may be applied to an electronic device, and the electronic device may be a server or a server cluster. As shown in fig. 2, the method of the embodiment of the present application includes:
s201, acquiring target data generated by software operation from a current software operation environment, wherein the target data comprises first data in a preset database table and/or second data in a log in the current software operation environment.
In the embodiment of the application, the software in the current software running environment generates service data and logs when running. For example, software in the current software operating environment extracts and stores business data from the upstream software operating environment, the extracted business data may be stored in a database, and the generated log may be stored in a log file. Thus, the target data generated by the software running can be obtained from the current software running environment, wherein the target data comprises the first data in the preset database table and/or the second data in the log in the current software running environment. Assuming that the preset database table is table a, the data stored in table a, i.e., the first data, may be obtained by connecting a database, such as a hive database (a data warehouse tool), in a shell (a command line interpreter) script. The second data in the log is, for example, log data containing the name of the database of the current software running environment connection, or the second data in the log is, for example, log data containing the file system address of the current software running environment connection. The second data in the log may be obtained by parsing the log by the shell script.
S202, determining data source information corresponding to target data according to the target data.
For example, if the target data includes first data in a preset database table in the current software running environment, the data source information corresponding to the first data may be determined based on the target key field of the preset database table and the field value corresponding to the target key field. Or if the target data includes the second data in the log, the log may be parsed to obtain the name of the database connected to the current software running environment, and further, the data source information corresponding to the second data may be determined based on the name of the database connected to the current software running environment. Or if the target data includes the second data in the log, the log may be parsed to obtain the file system address connected to the current software operating environment, and further, the data source information corresponding to the second data may be determined based on the file system address connected to the current software operating environment. For example, python (a cross-platform computer programming language) may be utilized to determine data source information corresponding to the target data according to the target data, and the obtained data source information corresponding to the target data may be output to a preset file, so as to facilitate viewing. For how to determine the data source information corresponding to the target data according to the target data, reference may be made to the following embodiments, which are not described herein.
S203, determining whether the current software running environment is connected to the correct upstream software running environment according to the data source information.
Wherein the current software operating environment is used to extract business data from the upstream software operating environment.
In this step, after determining the data source information corresponding to the target data, it may be determined whether the current software operating environment is connected to the correct upstream software operating environment according to the data source information. For example, in the case that the target data includes the first data in the preset database table in the current software running environment, if it is determined that the data source information corresponding to the first data is the target database name including the table name of the preset database table and the first data in the database of each upstream software running environment, it may be determined whether the current software running environment is connected to the correct upstream software running environment according to the target database name and the preset database name list. The preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment. For how to determine whether the current software running environment is connected to the correct upstream software running environment according to the data source information, reference may be made to the following embodiments, which are not described herein.
According to the software running environment detection method provided by the embodiment of the application, the target data generated by running the software is obtained from the current software running environment, and the target data comprises the first data in the preset database table and/or the second data in the log in the current software running environment; determining data source information corresponding to the target data according to the target data; based on the data source information, it is determined whether the current software operating environment is connected to the correct upstream software operating environment. The embodiment of the application automatically determines whether the current software running environment is connected to the correct upstream software running environment based on the data source corresponding to the target data generated by the software running obtained from the current software running environment, rather than manually comparing the connection of the upstream software running environment and the downstream software running environment, so that the efficiency of software running environment detection can be greatly improved on the basis of ensuring that whether the current software running environment is accurately connected to the correct upstream software running environment, thereby being beneficial to improving the development or test efficiency and reducing the development cost.
Fig. 3 is a flowchart of a software running environment detection method according to another embodiment of the present application. On the basis of the embodiment, the embodiment of the application further describes a software running environment detection method. As shown in fig. 3, the method of the embodiment of the present application may include:
s301, acquiring target data generated by software operation from a current software operation environment.
A detailed description of this step may be referred to the related description of S201 in the embodiment shown in fig. 2, and will not be repeated here.
In the embodiment of the present application, step S202 in fig. 2 may further include steps S302 to S304 as follows:
s302, if the target data comprise first data in a preset database table in the current software running environment, determining a field value corresponding to a preset key field of the preset database table according to the first data; inquiring databases of all upstream software running environments of the current software running environment according to table names of preset database tables, preset key fields and field values corresponding to the preset key fields, and determining that data source information corresponding to first data is a target database name containing the table names of the preset database tables and the first data in the databases of all upstream software running environments.
For example, assuming that the preset database table is table a, the preset key field of table a is, for example, a field "name", a field value corresponding to the preset key field of the preset database table may be determined to be "xx" according to the data stored in table a. Then, according to the table name of the table a, the preset key field "name" and the field value "xx" corresponding to the preset key field, the database of each upstream software running environment of the current software running environment can be queried, and the data source information corresponding to the first data is determined to be the table name of the table a and the target database name of the first data in the database of each upstream software running environment. It will be appreciated that, since the data sources of the same field in the preset database table are the same, a record under a field may be extracted. In this embodiment, a preset key field of the table a is taken as an example, and the number of preset key fields of the preset database table is not limited in this embodiment.
After step S302 is performed, step S305 is performed.
S303, if the target data comprise second data in the log, analyzing the second data to obtain the name of a database connected with the current software running environment; and determining the data source information corresponding to the second data as the name of the database connected with the current software running environment.
In this step, the second data in the log may be, for example, log data including the name of the database connected to the current software running environment, and then the second data may be parsed to obtain the name of the database connected to the current software running environment, so that it may be determined that the data source information corresponding to the second data is the name of the database connected to the current software running environment.
After step S303 is performed, step S306 is performed.
S304, if the target data comprises second data in the log, analyzing the second data to obtain a file system address connected with the current software running environment; and determining the data source information corresponding to the second data as the file system address connected with the current software running environment.
In this step, the second data in the log may be, for example, log data including a file system address connected to the current software running environment, and then the second data may be parsed to obtain the file system address connected to the current software running environment, so that it may be determined that the data source information corresponding to the second data is the file system address connected to the current software running environment.
After the step S304 is performed, a step S307 is performed.
It should be noted that, the embodiment of the present application does not limit the execution sequence of the steps S302, S303, and S304.
In the embodiment of the present application, the step S203 in fig. 2 may further include the following steps S305 to S307:
s305, determining whether a preset database name list contains a target database name according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
In the step, after determining that the data source information corresponding to the first data is a table name of a table a and a target database name of the first data in databases of all upstream software running environments, a preset database name list can be queried according to the target database name, and whether the preset database name list contains a target database name or not is determined; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
S306, determining whether a preset database name list contains the name of a database connected with the current software running environment according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
In the step, after determining that the data source information corresponding to the second data is the name of the database connected with the current software running environment, a preset database name list can be queried according to the name of the database connected with the current software running environment, and whether the preset database name list contains the name of the database connected with the current software running environment or not is determined; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
S307, determining whether a preset file system address list contains a file system address connected with the current software running environment according to the data source information, wherein the preset file system address list is a file system address list of a correct upstream software running environment connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
In the step, after determining that the data source information corresponding to the second data is the file system address connected with the current software running environment, a preset file system address list can be queried according to the file system address connected with the current software running environment, and whether the preset file system address list contains the file system address connected with the current software running environment or not is determined; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
According to the software running environment detection method provided by the embodiment of the application, the target data generated by running the software is obtained from the current software running environment; if the target data comprises first data in a preset database table in the current software running environment, determining a field value corresponding to a preset key field of the preset database table according to the first data; inquiring databases of all upstream software running environments of the current software running environment according to table names, preset key fields and field values corresponding to the preset key fields of the preset database table, and determining that data source information corresponding to the first data is a target database name containing the table names and the first data of the preset database table in the databases of all upstream software running environments; determining whether a preset database name list contains a target database name according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, determining that the current software running environment is connected to an incorrect upstream software running environment; if the target data comprises second data in the log, analyzing the second data to obtain the name of a database connected with the current software running environment; determining the data source information corresponding to the second data as the name of a database connected with the current software running environment; determining whether a preset database name list contains the name of a database connected with the current software running environment according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, determining that the current software running environment is connected to an incorrect upstream software running environment; if the target data comprises second data in the log, analyzing the second data to obtain a file system address connected with the current software running environment; determining the data source information corresponding to the second data as the file system address connected with the current software running environment; determining whether a preset file system address list contains a file system address connected with the current software running environment according to the data source information, wherein the preset file system address list is a file system address list of a correct upstream software running environment connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment. The embodiment of the application automatically determines whether the current software running environment is connected to the correct upstream software running environment based on the data source corresponding to the target data generated by the software running obtained from the current software running environment, rather than manually comparing the connection of the upstream software running environment and the downstream software running environment, so that the efficiency of software running environment detection can be greatly improved on the basis of ensuring that whether the current software running environment is accurately connected to the correct upstream software running environment, thereby being beneficial to improving the development or test efficiency and reducing the development cost.
The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
Fig. 4 is a schematic structural diagram of a software running environment detection device according to an embodiment of the present application. As shown in fig. 4, the software running environment detection apparatus 400 according to the embodiment of the present application includes: an acquisition module 401, a first determination module 402 and a second determination module 403. Wherein:
the obtaining module 401 is configured to obtain, from a current software running environment, target data generated by running software, where the target data includes first data in a preset database table and/or second data in a log in the current software running environment.
The first determining module 402 is configured to determine, according to the target data, data source information corresponding to the target data.
A second determining module 403, configured to determine, according to the data source information, whether the current software running environment is connected to the correct upstream software running environment, where the current software running environment is used to extract service data from the upstream software running environment.
In some embodiments, the target data includes first data in a preset database table in the current software running environment, and the first determining module 402 may specifically be configured to: determining a field value corresponding to a preset key field of a preset database table according to the first data; according to the table names, preset key fields and field values corresponding to the preset key fields of a preset database table, querying databases of all upstream software running environments of the current software running environment, and determining that data source information corresponding to first data is a target database name containing the table names and the first data in the databases of all upstream software running environments.
In some embodiments, the second determining module 403 may be specifically configured to: determining whether a preset database name list contains a target database name according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
In some embodiments, the target data includes second data in a log, and the first determining module 402 may be specifically configured to: analyzing the second data to obtain the name of a database connected with the current software running environment; and determining the data source information corresponding to the second data as the name of the database connected with the current software running environment.
In some embodiments, the second determining module 403 may be specifically configured to: determining whether a preset database name list contains the name of a database connected with the current software running environment according to the data source information, wherein the preset database name list is a name list of a database of a correct upstream software running environment which is connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
In some embodiments, the target data includes second data in a log, and the first determining module 402 may be specifically configured to: analyzing the second data to obtain a file system address connected with the current software running environment; and determining the data source information corresponding to the second data as the file system address connected with the current software running environment.
In some embodiments, the second determining module 403 may be specifically configured to: determining whether a preset file system address list contains a file system address connected with the current software running environment according to the data source information, wherein the preset file system address list is a file system address list of a correct upstream software running environment connected with the current software running environment; if yes, determining that the current software running environment is connected to the correct upstream software running environment; if not, it is determined that the current software operating environment is connected to an incorrect upstream software operating environment.
The device of the embodiment of the present application may be used to execute the technical solution of any of the above-described embodiments of the method, and its implementation principle and technical effects are similar, and are not repeated here.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic device 500 may include: at least one processor 501 and a memory 502.
A memory 502 for storing a program. In particular, the program may include program code including computer-executable instructions.
The memory 502 may include high-speed random access memory (Random Access Memory, RAM) and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The processor 501 is configured to execute computer-executable instructions stored in the memory 502 to implement the software running environment detection method described in the foregoing method embodiment. The processor 501 may be a central processing unit (Central Processing Unit, CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits configured to implement embodiments of the present application. Specifically, when the software running environment detection method described in the foregoing method embodiment is implemented, the electronic device may be, for example, an electronic device having a processing function, such as a server.
Optionally, the electronic device 500 may also include a communication interface 503. In a specific implementation, if the communication interface 503, the memory 502, and the processor 501 are implemented independently, the communication interface 503, the memory 502, and the processor 501 may be connected to each other and perform communication with each other through buses. The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. Buses may be divided into address buses, data buses, control buses, etc., but do not represent only one bus or one type of bus.
Alternatively, in a specific implementation, if the communication interface 503, the memory 502, and the processor 501 are integrated on a chip, the communication interface 503, the memory 502, and the processor 501 may complete communication through internal interfaces.
The electronic device is configured to execute the software running environment detection method in any of the foregoing method embodiments, and its implementation principle and technical effects are similar, and are not described herein again.
The application also provides a computer readable storage medium, wherein the computer readable storage medium stores computer program instructions, and when the processor executes the computer program instructions, the scheme of the software running environment detection method is realized.
The application also provides a computer program product comprising a computer program which when executed by a processor implements the solution of the software running environment detection method as above.
The computer readable storage medium described above may be implemented by any type or combination of volatile or non-volatile Memory devices, such as static random access Memory (Static Random Access Memory, SRAM), electrically erasable programmable Read-Only Memory (Electrically Erasable Programmable Read Only Memory, EEPROM), erasable programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), programmable Read-Only Memory (Programmable Read Only Memory, PROM), read Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. A readable storage medium can be any available medium that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. In the alternative, the readable storage medium may be integral to the processor. The processor and the readable storage medium may reside in an application specific integrated circuit. The processor and the readable storage medium may also reside as discrete components in a software running environment detection means.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.