CN111538660A - Method and device for counting coverage rate of program codes in container on cloud - Google Patents

Method and device for counting coverage rate of program codes in container on cloud Download PDF

Info

Publication number
CN111538660A
CN111538660A CN202010331946.1A CN202010331946A CN111538660A CN 111538660 A CN111538660 A CN 111538660A CN 202010331946 A CN202010331946 A CN 202010331946A CN 111538660 A CN111538660 A CN 111538660A
Authority
CN
China
Prior art keywords
container
code coverage
tool
program
statistics
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
CN202010331946.1A
Other languages
Chinese (zh)
Other versions
CN111538660B (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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202010331946.1A priority Critical patent/CN111538660B/en
Publication of CN111538660A publication Critical patent/CN111538660A/en
Application granted granted Critical
Publication of CN111538660B publication Critical patent/CN111538660B/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/3676Test management for coverage analysis

Abstract

The invention provides a method and a device for counting the coverage rate of program codes in a container on the cloud, wherein the method comprises the following steps: arranging a statistical tool container with a code coverage statistical tool on a node where a tested program container is located; establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other; and after communication is established, carrying out code coverage rate statistics on the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container. According to the invention, the collection and statistics of the code coverage rate in the container are realized by using the node life cycle management of the container in the cloud in a directory sharing mode, so that the modification of an application mirror image can be avoided, and the code decoupling with the application mirror image can be realized. The characteristics of the cloud container are combined, the statistical monitoring of the coverage rate is realized under the condition that the application mirror image is prevented from being matched and modified, and the purpose of testing the environment and checking the code coverage condition is achieved.

Description

Method and device for counting coverage rate of program codes in container on cloud
Technical Field
The invention relates to a cloud technology, in particular to a method and a device for counting the coverage rate of program codes in a container on the cloud.
Background
Code coverage is a measure in software testing to reflect the proportion and extent to which program code is tested, often to measure the sufficiency of code testing. In a traditional non-cloud computing environment, a mature code coverage rate statistical method is provided, for example, plug-ins or independent JAR packages of various integrated development environments are used, and a good statistical result can be obtained in a development or test stage.
In a cloud computing environment, although a traditional tool can correspondingly transplant and count the code coverage rate, the traditional tool is still used in a traditional development stage of the application or can be used in a test stage on the cloud after an application image is modified. For a cloud container environment based on Kubernetes, a requirement for counting code coverage rate indexes of a test environment also exists at present, but due to the fact that an application mirror image cannot modify a scene after submitting the test environment, a complete scheme for counting code coverage rate is not provided, and the requirement can be met.
Disclosure of Invention
In order to meet the requirement of counting code coverage indexes of a cloud container environment test environment, code coverage indexes are counted after a test environment is submitted by using a mirror image, and the embodiment of the invention provides a method for counting program code coverage in a cloud container, which comprises the following steps:
arranging a statistical tool container with a code coverage statistical tool on a node where a tested program container is located;
establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other;
and after communication is established, carrying out code coverage rate statistics on the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container.
In the embodiment of the present invention, the arranging the statistical tool container with the code coverage statistical tool at the node where the tested program container is located includes:
acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
generating a statistical tool container according to the statistical tool and the operating environment data;
and arranging the statistical tool container on a node where the tested program container is located.
In an embodiment of the present invention, the establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other includes:
and establishing a shared directory by using the emptyDir of the container on the cloud so as to enable the statistical tool container and the tested program container to communicate with each other.
In an embodiment of the present invention, the performing code coverage statistics on the tested program in the tested program container by using the code coverage statistics tool in the statistics tool container includes:
respectively configuring postStart events for the statistical tool container and the tested program container;
and according to the configured postStart event, the code coverage statistical tool in the statistical tool container carries out code coverage statistics on the tested program insertion piles in the tested program container.
In an embodiment of the present invention, the configuring postStart events for the statistical tool container and the tested program container respectively includes:
configuring postStart events of the statistics tool container to transmit code coverage statistics tools within the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container into a preset directory for instrumentation by acquiring a code coverage statistical tool from the shared directory.
In the embodiment of the invention, the container on the cloud is a Kubernetes container on the cloud.
Meanwhile, the invention also provides a device for counting the coverage rate of the program codes in the container on the cloud, which comprises the following steps:
the container arranging module is used for arranging the statistical tool container with the code coverage statistical tool on a node where the tested program container is located;
the shared directory establishing module is used for establishing a shared directory so as to enable the statistical tool container and the tested program container to communicate with each other;
and the counting module is used for carrying out code coverage rate counting on the tested program in the tested program container by using the code coverage rate counting tool in the counting tool container after communication is established.
In an embodiment of the present invention, the container arrangement module includes:
the data acquisition unit is used for acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
the container generating unit is used for generating a statistical tool container according to the statistical tool and the operating environment data;
and the arranging unit is used for arranging the statistical tool container on the node where the tested program container is located.
In the embodiment of the invention, the shared directory establishing module establishes the shared directory by using the emptyDir of the container on the cloud so as to enable the statistical tool container to be communicated with the tested program container.
In the embodiment of the present invention, the statistical module includes:
the configuration unit is used for respectively configuring postStart events for the statistical tool container and the tested program container;
and the counting unit is used for counting the code coverage rate of the tested program instrumentation in the tested program container by the code coverage rate counting tool in the counting tool container according to the configured postStart event.
In the embodiment of the present invention, the configuration unit includes:
a statistics container configuration unit, configured to configure the postStart event of the statistics tool container to transmit the code coverage statistics tool in the statistics tool container to the shared directory;
and the tested container configuration unit is used for configuring the postStart event of the tested program container into a preset directory for instrumentation by acquiring a code coverage statistical tool from the shared directory.
Meanwhile, the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the method when executing the computer program.
Meanwhile, the invention also provides a computer readable storage medium, and a computer program for executing the method is stored in the computer readable storage medium.
The invention provides a method and a device for counting container code coverage rate, which can realize the collection and the counting of the container code coverage rate by utilizing the node life cycle management of a container on a cloud in a directory sharing mode for an application mirror image which can not be modified after being packaged, and can avoid the modification of the application mirror image and the code decoupling of the application mirror image. The method transplants a coverage rate statistical tool in the traditional environment, combines the characteristics of the containers on the cloud, realizes the statistical monitoring of the coverage rate under the condition of avoiding the application of mirror image matching modification, and achieves the purpose of testing the coverage condition of the environment inspection codes.
In order to make the aforementioned and other objects, features and advantages of the invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of a method for counting coverage of program code in a container on the cloud according to the present invention;
fig. 2 is a schematic structural diagram of a node for counting container code coverage in kubernets according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method for counting container code coverage in Kubernetes according to an embodiment of the present invention;
FIG. 4 is a block diagram of an apparatus for counting program code coverage in a container on the cloud according to the present invention;
FIG. 5 is a block diagram of an embodiment of the present invention;
FIG. 6 is a block diagram of an embodiment of the present invention;
FIG. 7 is a block diagram of an embodiment of the present invention;
fig. 8 is a schematic diagram of an electronic device provided in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, 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 invention.
For the cloud-based container environment, the requirement of counting the code coverage rate index of the test environment also exists, and the requirement can be met for the scene that the application mirror image cannot be modified after submitting the test environment and a complete scheme for counting the code coverage rate is lacked.
The invention provides a statistical method for coverage rate of program codes in a cloud container, which comprises the following steps of:
step S101, arranging a statistical tool container with a code coverage rate statistical tool on a node where a tested program container is located;
step S102, establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other;
and step S103, after communication is established, carrying out code coverage rate statistics on the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container.
The method for counting the coverage rate of the program codes in the container on the cloud realizes the mutual communication between a counting tool container and a tested program container arranged in the same node by establishing a shared directory, and performs code coverage rate counting on the tested program in the tested program container by using a code coverage rate counting tool in the counting tool container.
In the embodiment of the present invention, the performing, in step S103, code coverage statistics on the tested program in the tested program container by using the code coverage statistics tool in the statistics tool container includes:
respectively configuring postStart events for the statistical tool container and the tested program container;
and according to the configured postStart event, the code coverage statistical tool in the statistical tool container carries out code coverage statistics on the tested program insertion piles in the tested program container.
The postStart event refers to a task which is executed after a container is created and before the actual operation, when one container is created, the cloud container immediately sends the postStart event, and the state of the container is changed into RUNNING only after the postStart processing function is executed. In the embodiment of the present invention, the respectively configuring postStart events for the statistical tool container and the tested program container specifically includes:
configuring a postStart event of a statistics tool container to transmit a code coverage statistics tool within the statistics tool container to the shared catalog;
and configuring the postStart event of the tested program container to acquire a code coverage statistical tool from the shared directory to a preset directory for instrumentation.
In this embodiment, the postStart event of the statistical mirror is used to transmit the test toolkit to the shared directory, and the postStart event of the application mirror is used to receive the test toolkit to the specified directory and to perform instrumentation, so as to perform the code coverage test.
The technical solution of the present invention is further described in detail with reference to specific embodiments, which provide a method for counting the code coverage rate in kubernets, and for application images that cannot be modified after being packaged, the method can use a shared directory mode.
Kubernets, an open source, is used to manage containerized applications on multiple hosts in a cloud platform, is a mechanism to make deploying containerized applications simple and efficient, and provides application deployment, planning, updating, and maintenance. The Pod is the smallest unit that can be created and deployed in Kubernetes, is an application instance in a Kubernetes cluster, and is always deployed on the same Node. The Pod includes one or more containers and also includes resources shared by the containers such as storage and network. Pod supports multiple container environments.
The method for counting the coverage rate of the container codes in the Kubernets provided by the embodiment of the invention comprehensively uses a method for counting the coverage rate of application code piles through a tool kit in a traditional environment and the capability of the Kubernets on-cloud environment, designs a technical scheme, and the technical scheme of the invention is explained in detail below with reference to the attached drawings.
Fig. 2 is a node structure diagram for calculating the container code coverage rate in kubernets according to this embodiment, and includes: statistics Container 1, shared catalog 2, application Container 3, toolkit 4, Pod5 by Kubernetes.
Wherein, the statistical container 1 is a container generated by deployment after the coverage rate tool is packaged as an independent statistical mirror image; i.e., the container generated by the mirrored deployment with the code coverage statistics tool.
The application container 3 is a container generated after the mirror image of the application is deployed; both the statistics container 1 and the application container 3 are in the same kubernets Pod5, sharing the same directory 2, and the toolkit 4 is transmitted through the shared directory 2.
Fig. 3 is a flow chart of the statistics of container code coverage in kubernets in the present embodiment, which includes the following steps:
step 1: according to a general mirror image manufacturing method, a mirror image packaging file is compiled, and a test toolkit and a required operation environment are manufactured into a test statistical mirror image.
Step 2: the statistical mirror image and the application mirror image are arranged in the same Kubernetes Pod.
That is, the step 1 and the step 2 are used to implement the aforementioned arranging of the statistical tool container with the code coverage statistical tool on the node where the tested program container is located, which specifically includes:
acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
generating a statistical tool container according to the statistical tool and the operating environment data;
and arranging the statistical tool container on a node where the tested program container is located.
And step 3: the sharing directory is set through emptyDir, and the statistical mirror image and the application mirror image are respectively set with a directory in the mirror image for sharing, so that the statistical mirror image and the application mirror image can be communicated with each other after the container is started.
And 4, step 4: setting a processing function for the life cycle event of the container, modifying the configuration file of the Pod, and adding the postStart event under the lifecycle attribute.
The postStart event refers to a task which is executed after a container is created and before the container is actually run, kubernets immediately sends the postStart event after one container is created, and the state of the container is changed into RUNNING only after the postStart processing function is executed.
Wherein, the postStart event of the statistical mirror is used for transmitting the tool kit to the shared directory;
the postStart event of the application image is used to receive toolkits to the specified directory and to instrumentation.
And 5: after configuration setup is complete, a Pod is created on Kubernets, started, and ready to run.
Step 6: based on postStart events, the toolkit is transmitted to the shared directory after the statistics container is created.
And 7: upon postStart event, the application container is created and attempts are made to transfer the toolkit for the shared directory to the specified directory within the application.
And 8: and the application container detects whether the tool pack is acquired, if the tool pack is not acquired, the step 7 is repeatedly executed, and if the acquisition is successful, the step 9 is executed.
And step 9: the application container stakes the application code through the toolkit.
Step 10: after the stat container and the application container complete the postStart event, the container service starts normally and the state changes to RUNNING.
Step 11: running test cases or testing the application container service using other testing means.
Step 12: and after full testing, accessing the statistical container service, collecting code coverage rate information according to the functions provided by the tool kit, and acquiring a statistical report.
The method for counting the code coverage rate in the Kubernetes provided by the embodiment can avoid modification of the application mirror image and code decoupling of the application mirror image. The method transplants a coverage rate statistical tool in the traditional environment, combines the characteristics of a container on the Kubernetes cloud, realizes the statistical monitoring of the coverage rate under the condition of avoiding the application of mirror image matching modification, and achieves the purpose of testing the environment to check the code coverage condition.
Meanwhile, as shown in fig. 4, the present invention further provides a device for counting coverage of program codes in a container on the cloud, including:
a container arrangement module 401, configured to arrange a statistical tool container with a code coverage statistical tool in the Pod where the tested program container is located;
a shared directory establishing module 402, configured to establish a shared directory to enable the statistical tool container and the tested program container to communicate with each other;
and the statistic module 403 is configured to perform code coverage statistic on the tested program in the tested program container by using the code coverage statistic tool in the statistic tool container after communication is established.
In an embodiment of the present invention, as shown in fig. 5, the container arranging module 401 includes:
the data acquisition unit 4011 is configured to acquire a statistical tool for performing code coverage statistics and statistical tool operating environment data;
the container generating unit 4012 is configured to generate a statistical tool container according to the statistical tool and the operating environment data;
the arranging unit 4013 is configured to arrange the statistical tool container in a node where the tested program container is located.
In the embodiment of the invention, the shared directory establishing module establishes the shared directory by using the emptyDir of the container on the cloud so as to enable the statistical tool container to be communicated with the tested program container.
In the embodiment of the present invention, as shown in fig. 6, the statistical module 403:
a configuration unit 4031, configured to configure postStart events for the statistical tool container and the tested program container, respectively;
a statistic unit 4032, configured to perform code coverage statistics on the instrumented program instrumentation in the instrumented program container by using the code coverage statistics tool in the statistics tool container according to the configured postStart event.
In this embodiment of the present invention, as shown in fig. 7, the configuration unit further includes:
a statistics container configuration unit 701, configured to configure the postStart event of the statistics tool container to transmit the code coverage statistics tool in the statistics tool container to the shared directory;
a tested container configuring unit 702, configured to configure the postStart event of the tested program container to obtain a code coverage statistical tool from the shared directory to a preset directory for instrumentation.
The embodiment of the invention also provides electronic equipment which can be a desktop computer, a tablet computer, a mobile terminal and the like, and the embodiment is not limited thereto. In this embodiment, the electronic device may be implemented by referring to the contents of the foregoing embodiments, and the contents thereof are incorporated herein, and repeated descriptions are omitted.
Fig. 8 is a schematic block diagram of a system configuration of an electronic apparatus 600 according to an embodiment of the present invention. As shown in fig. 8, the electronic device 600 may include a central processor 100 and a memory 140; the memory 140 is coupled to the central processor 100. Notably, this diagram is exemplary; other types of structures may also be used in addition to or in place of the structure to implement telecommunications or other functions.
In one embodiment, the on-cloud in-container program code coverage statistics function may be integrated into the central processor 100. The central processor 100 may be configured to control as follows:
arranging a statistical tool container with a code coverage statistical tool on a node where a tested program container is located;
establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other;
and after communication is established, carrying out code coverage rate statistics on the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container.
In the embodiment of the present invention, the arranging the statistical tool container with the code coverage statistical tool at the node where the tested program container is located includes:
acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
generating a statistical tool container according to the statistical tool and the operating environment data;
and arranging the statistical tool container on a node where the tested program container is located.
In this embodiment, the establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other includes:
and establishing a shared directory by using the emptyDir of the container on the cloud so as to enable the statistical tool container and the tested program container to communicate with each other.
In this embodiment, the performing code coverage statistics on the tested program in the tested program container by using the code coverage statistics tool in the statistics tool container includes:
respectively configuring postStart events for the statistical tool container and the tested program container;
and according to the configured postStart event, the code coverage statistical tool in the statistical tool container carries out code coverage statistics on the tested program insertion piles in the tested program container.
In this embodiment, the respectively configuring postStart events for the statistical tool container and the tested program container includes:
configuring postStart events of the statistics tool container to transmit code coverage statistics tools within the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container into a preset directory for instrumentation by acquiring a code coverage statistical tool from the shared directory.
In the embodiment of the invention, the container on the cloud is a Kubernetes container on the cloud.
The method and the device for counting the coverage rate of the container codes in the Kubernetes provided by the embodiment fully utilize the capability of a traditional code coverage rate tool and the capabilities of container sharing catalog and Pod life cycle management on the Kubernetes cloud, can realize the counting monitoring of the code coverage rate on the premise of not modifying an application mirror image, reduce the coupling between the counting tool and the application codes, improve the reuse capability and achieve the goal of counting the coverage rate under a test environment.
In another embodiment, the on-cloud container program code coverage rate statistic device may be configured separately from the central processor 100, for example, the on-cloud container program code coverage rate statistic device may be configured as a chip connected to the central processor 100, and the on-cloud container program code coverage rate statistic function is realized by the control of the central processor.
As shown in fig. 8, the electronic device 600 may further include: communication module 110, input unit 120, audio processing unit 130, display 160, power supply 170. It is noted that the electronic device 600 does not necessarily include all of the components shown in FIG. 8; furthermore, the electronic device 600 may also comprise components not shown in fig. 8, which may be referred to in the prior art.
As shown in fig. 8, the central processor 100, sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, the central processor 100 receiving input and controlling the operation of the various components of the electronic device 600.
The memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information relating to the failure may be stored, and a program for executing the information may be stored. And the central processing unit 100 may execute the program stored in the memory 140 to realize information storage or processing, etc.
The input unit 120 provides input to the cpu 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used to display an object to be displayed, such as an image or a character. The display may be, for example, an LCD display, but is not limited thereto.
The memory 140 may be a solid state memory such as Read Only Memory (ROM), Random Access Memory (RAM), a SIM card, or the like. There may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes called an EPROM or the like. The memory 140 may also be some other type of device. Memory 140 includes buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application/function storage section 142, and the application/function storage section 142 is used to store application programs and function programs or a flow for executing the operation of the electronic device 600 by the central processing unit 100.
The memory 140 may also include a data store 143, the data store 143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage portion 144 of the memory 140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging application, address book application, etc.).
The communication module 110 is a transmitter/receiver 110 that transmits and receives signals via an antenna 111. The communication module (transmitter/receiver) 110 is coupled to the central processor 100 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, may be provided in the same electronic device. The communication module (transmitter/receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and receive audio input from the microphone 132 to implement general telecommunications functions. Audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, an audio processor 130 is also coupled to the central processor 100, so that recording on the local can be enabled through a microphone 132, and so that sound stored on the local can be played through a speaker 131.
Embodiments of the present invention further provide a computer-readable program, where when the program is executed in an electronic device, the program causes a computer to execute the method for counting coverage of program codes in a container on a cloud in the electronic device according to the above embodiments.
The embodiment of the present invention further provides a storage medium storing a computer-readable program, where the computer-readable program enables a computer to execute the statistics of coverage rates of program codes in containers on a cloud in the electronic device according to the above embodiment.
The preferred embodiments of the present invention have been described above with reference to the accompanying drawings. The many features and advantages of the embodiments are apparent from the detailed specification, and thus, it is intended by the appended claims to cover all such features and advantages of the embodiments that fall within the true spirit and scope thereof. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the embodiments of the invention to the exact construction and operation illustrated and described, and accordingly, all suitable modifications and equivalents may be resorted to, falling within the scope thereof.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (14)

1. A statistical method for program code coverage in a container on a cloud is characterized by comprising the following steps:
arranging a statistical tool container with a code coverage statistical tool on a node where a tested program container is located;
establishing a shared directory to enable the statistical tool container and the tested program container to communicate with each other;
and after communication is established, carrying out code coverage rate statistics on the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container.
2. The method for counting the coverage rate of the program code in the container on the cloud according to claim 1, wherein the step of arranging the statistical tool container with the code coverage rate statistical tool at the node where the tested program container is located comprises:
acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
generating a statistical tool container according to the statistical tool and the operating environment data;
and arranging the statistical tool container on a node where the tested program container is located.
3. The on-cloud in-container program code coverage statistics method of claim 1, wherein the establishing a shared directory to enable the statistics tool container and the tested program container to communicate with each other comprises:
and establishing a shared directory by using the emptyDir of the container on the cloud so as to enable the statistical tool container and the tested program container to communicate with each other.
4. The method for counting the code coverage rate of the program code in the container on the cloud according to claim 1, wherein the step of performing the code coverage rate statistics on the program under test in the program under test container by using the code coverage rate statistics tool in the statistics tool container comprises:
respectively configuring postStart events for the statistical tool container and the tested program container;
and according to the configured postStart event, the code coverage statistical tool in the statistical tool container carries out code coverage statistics on the tested program insertion piles in the tested program container.
5. The on-cloud in-container program code coverage statistics method of claim 4, wherein the configuring postStart events for the statistics tool container and the tested program container respectively comprises:
configuring postStart events of the statistics tool container to transmit code coverage statistics tools within the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container into a preset directory for instrumentation by acquiring a code coverage statistical tool from the shared directory.
6. The on-cloud container-in-program-code coverage statistical method of claim 1, wherein the on-cloud container is a Kubernetes on-cloud container.
7. An apparatus for statistics of program code coverage in a container on the cloud, the apparatus comprising:
the container arranging module is used for arranging the statistical tool container with the code coverage statistical tool on a node where the tested program container is located;
the shared directory establishing module is used for establishing a shared directory so as to enable the statistical tool container and the tested program container to communicate with each other;
and the counting module is used for carrying out code coverage rate counting on the tested program in the tested program container by using the code coverage rate counting tool in the counting tool container after communication is established.
8. The on-cloud in-container program code coverage statistics apparatus of claim 7, wherein the container orchestration module comprises:
the data acquisition unit is used for acquiring a statistical tool for counting the code coverage rate and statistical tool operating environment data;
the container generating unit is used for generating a statistical tool container according to the statistical tool and the operating environment data;
and the arranging unit is used for arranging the statistical tool container on the node where the tested program container is located.
9. The on-cloud container program code coverage statistics apparatus of claim 7, wherein the shared directory establishing module establishes a shared directory using emptyDir of the on-cloud container, so that the statistics tool container and the tested program container communicate with each other.
10. The on-cloud in-container program code coverage statistics apparatus of claim 7, wherein the statistics module comprises:
the configuration unit is used for respectively configuring postStart events for the statistical tool container and the tested program container;
and the counting unit is used for counting the code coverage rate of the tested program instrumentation in the tested program container by the code coverage rate counting tool in the counting tool container according to the configured postStart event.
11. The on-cloud in-container program code coverage statistics apparatus according to claim 10, wherein the configuration unit comprises:
a statistics container configuration unit, configured to configure the postStart event of the statistics tool container to transmit the code coverage statistics tool in the statistics tool container to the shared directory;
and the tested container configuration unit is used for configuring the postStart event of the tested program container into a preset directory for instrumentation by acquiring a code coverage statistical tool from the shared directory.
12. The on-cloud container-in-program-code coverage statistics apparatus according to claim 7, wherein the on-cloud container is a Kubernetes on-cloud container.
13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 6 when executing the computer program.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 6.
CN202010331946.1A 2020-04-24 2020-04-24 Method and device for counting coverage rate of program codes in cloud container Active CN111538660B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010331946.1A CN111538660B (en) 2020-04-24 2020-04-24 Method and device for counting coverage rate of program codes in cloud container

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010331946.1A CN111538660B (en) 2020-04-24 2020-04-24 Method and device for counting coverage rate of program codes in cloud container

Publications (2)

Publication Number Publication Date
CN111538660A true CN111538660A (en) 2020-08-14
CN111538660B CN111538660B (en) 2023-09-26

Family

ID=71978829

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010331946.1A Active CN111538660B (en) 2020-04-24 2020-04-24 Method and device for counting coverage rate of program codes in cloud container

Country Status (1)

Country Link
CN (1) CN111538660B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170192758A1 (en) * 2016-01-04 2017-07-06 Syntel, Inc. Method and apparatus for migration of application source code
CN109614341A (en) * 2018-12-29 2019-04-12 微梦创科网络科技(中国)有限公司 A kind of test method and system of code coverage
CN109684226A (en) * 2018-12-29 2019-04-26 携程计算机技术(上海)有限公司 Java code coverage rate statistical system
CN110647332A (en) * 2019-09-30 2020-01-03 北京百度网讯科技有限公司 Software deployment method and device based on container cloud

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170192758A1 (en) * 2016-01-04 2017-07-06 Syntel, Inc. Method and apparatus for migration of application source code
CN109614341A (en) * 2018-12-29 2019-04-12 微梦创科网络科技(中国)有限公司 A kind of test method and system of code coverage
CN109684226A (en) * 2018-12-29 2019-04-26 携程计算机技术(上海)有限公司 Java code coverage rate statistical system
CN110647332A (en) * 2019-09-30 2020-01-03 北京百度网讯科技有限公司 Software deployment method and device based on container cloud

Also Published As

Publication number Publication date
CN111538660B (en) 2023-09-26

Similar Documents

Publication Publication Date Title
CN110297944B (en) Distributed XML data processing method and system
CN107404418B (en) Internet product testing method, device, equipment and storage medium
CN112463634B (en) Software testing method and device under micro-service architecture
CN111782470A (en) Distributed container log data processing method and device
CN112615753A (en) Link abnormity tracking method, first node, second node and link
CN111371695B (en) Service flow limiting method and device
CN111464352A (en) Call link data processing method and device
CN111858364A (en) Parameter configuration method, device and system of test terminal
CN110022327B (en) Short message authentication test method and device
CN110297945B (en) Data information processing method and system based on XBRL
CN111930625A (en) Log obtaining method, device and system based on cloud service platform
CN105227597A (en) A kind of method, Apparatus and system obtaining terminal equipment screen-picture
CN111538660B (en) Method and device for counting coverage rate of program codes in cloud container
CN111324480A (en) Large host transaction fault positioning system and method
CN113535578B (en) CTS test method, CTS test device and CTS test equipment
CN113050985B (en) Front-end engineering dependency automatic registration method and device
CN113268272B (en) Application delivery method, device and system based on private cloud
CN115407981A (en) Front-end data mock method and system based on middleware adaptation
CN110545296A (en) Log data acquisition method, device and equipment
CN114840421A (en) Log data processing method and device
CN114490402A (en) Method and device for checking validity of message field
CN114298840A (en) Block chain transaction endorsement method and system based on zero knowledge proof
US20140180662A1 (en) Radio frequency communication simulation
CN111158744B (en) Cross-platform heterogeneous data integration method and device
CN112751893A (en) Message track data processing method and device and electronic equipment

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