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

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

Info

Publication number
CN111538660B
CN111538660B CN202010331946.1A CN202010331946A CN111538660B CN 111538660 B CN111538660 B CN 111538660B CN 202010331946 A CN202010331946 A CN 202010331946A CN 111538660 B CN111538660 B CN 111538660B
Authority
CN
China
Prior art keywords
container
statistics
tool
code coverage
coverage rate
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.)
Active
Application number
CN202010331946.1A
Other languages
Chinese (zh)
Other versions
CN111538660A (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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for counting program code coverage rate in a cloud container, wherein the method comprises the following steps: arranging a statistics tool container with a code coverage rate statistics tool on a node where a tested program container is located; establishing a shared directory to communicate the statistics tool container with the tested program container; after communication is established, the code coverage rate statistics tool in the statistics tool container is utilized to carry out code coverage rate statistics on the tested programs in the tested program container. The method and the device realize collection and statistics of the code coverage rate in the container by utilizing node life cycle management of the container in the cloud in a directory sharing mode, and can avoid modification of the application mirror image and code decoupling of the application mirror image. By combining the characteristics of the container on the cloud, the statistical monitoring of coverage rate is realized under the condition of avoiding application of mirror image matching modification, and the aim of testing the coverage condition of the environment inspection code is fulfilled.

Description

Method and device for counting coverage rate of program codes in cloud container
Technical Field
The invention relates to cloud technology, in particular to a method and a device for counting program code coverage rate in a container on a cloud.
Background
Code coverage is a measure in software testing that reflects the proportion and extent to which program code is tested, often to measure the sufficiency of the code test. Under the traditional non-cloud computing environment, a well-established code coverage rate statistical method exists, such as using plug-ins of various integrated development environments or independent JAR packages, and good statistical results can be obtained in the development or test stage.
In a cloud computing environment, although a traditional tool can correspondingly migrate and count code coverage, the traditional development stage for an application is still often used, or the application image needs to be modified before the application image can be used in the on-cloud test stage. Aiming at the cloud container environment based on Kubernetes, the requirement of statistical code coverage index of the test environment exists at present, but because of the fact that the application mirror image cannot be modified after submitting the test environment, a complete scheme of statistical code coverage is not available.
Disclosure of Invention
In order to meet the requirement of the cloud container environment test environment for counting code coverage rate indexes, the application mirror image is used for counting the code coverage rate indexes after submitting the test environment, and the cloud container internal program code coverage rate counting method provided by the embodiment of the invention comprises the following steps:
arranging a statistics tool container with a code coverage rate statistics tool on a node where a tested program container is located;
establishing a shared directory to communicate the statistics tool container with the tested program container;
after communication is established, the code coverage rate statistics tool in the statistics tool container is utilized to carry out code coverage rate statistics on the tested programs in the tested program container.
In the embodiment of the present invention, the arranging the statistics tool container with the code coverage rate statistics tool in the node where the tested program container is located includes:
acquiring a statistics tool and statistics tool operation environment data for carrying out code coverage rate statistics;
generating a statistics tool container according to the statistics tool and the operation environment data;
and arranging the statistical tool container at the node where the tested program container is located.
In an embodiment of the present invention, the establishing a shared directory to enable the statistics tool container and the tested program container to communicate with each other includes:
and establishing a shared directory by utilizing the emptyDir of the container on the cloud so as to enable the statistics tool container and the tested program container to communicate with each other.
In the embodiment of the present invention, the counting the code coverage rate of the tested program in the tested program container by using the code coverage rate counting tool in the counting tool container includes:
respectively configuring postStart events for the statistics tool container and the tested program container;
and according to the configured postStart event, the code coverage statistics tool in the statistics tool container performs code coverage statistics on the tested program instrumentation in the tested program container.
In the embodiment of the present invention, the configuring postStart events for the statistics tool container and the tested program container respectively includes:
the postStart event of the statistics tool container is configured to transmit the code coverage rate statistics tool in the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
In the embodiment of the invention, the above-cloud container is a Kubernetes above-cloud container.
Meanwhile, the invention also provides a device for counting the coverage rate of the program codes in the cloud container, which comprises the following steps:
the container arrangement module is used for arranging the statistics tool container with the code coverage rate statistics tool at the node where the tested program container is located;
a shared catalog establishing module for establishing a shared catalog to communicate the statistics tool container with the tested program container;
and the statistics module is used for carrying out code coverage statistics on the tested program in the tested program container by using the code coverage statistics tool in the statistics 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 statistics tool for carrying out code coverage rate statistics and running environment data of the statistics tool;
a container generating unit for generating a statistics tool container according to the statistics tool and the operation environment data;
and the arrangement unit is used for arranging the statistical tool container at 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 utilizing the emptyDir of the container on the cloud so as to enable the statistics tool container and the tested program container to communicate with each other.
In an embodiment of the present invention, the statistics module includes:
the configuration unit is used for respectively configuring postStart events for the statistics tool container and the tested program container;
and the statistics unit is used for carrying out code coverage statistics on the tested program instrumentation in the tested program container according to the configured postStart event by the code coverage statistics tool in the statistics tool container.
In an embodiment of the present invention, the configuration unit includes:
the statistics container configuration unit is used for configuring the postStart event of the statistics tool container to transmit the code coverage rate statistics tool in the statistics tool container to the shared catalogue;
and the tested container configuration unit is used for configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
The invention also provides a computer device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the method.
Meanwhile, the invention also provides a computer readable storage medium which stores a computer program for executing the method.
The invention provides a method and a device for counting the code coverage rate of an inner container, which can collect and count the code coverage rate of the inner container by utilizing node life cycle management of the inner container on a cloud in a directory sharing mode for an application image which cannot be modified after being packaged, and can avoid modification of the application image and code decoupling of the application image. According to the method, a coverage rate statistics tool in a traditional environment is transplanted, meanwhile, the characteristics of a container on the cloud are combined, the coverage rate statistics monitoring is realized under the condition that mirror image matching modification is avoided, and the purpose of testing the coverage condition of the environment inspection codes is achieved.
The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular description of preferred embodiments, as illustrated in the accompanying drawings.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for counting program code coverage rate in a cloud container provided by the invention;
fig. 2 is a schematic node structure diagram of statistics of code coverage in Kubernetes according to an embodiment of the present invention;
FIG. 3 is a flowchart for counting code coverage rate in Kubernetes according to an embodiment of the present invention;
FIG. 4 is a block diagram of a device for counting program code coverage rate in a cloud container provided by the 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 according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Aiming at the requirements of the statistical code coverage index of the test environment based on the container environment on the cloud, the scheme of the complete statistical code coverage can meet the requirements for the scene which cannot be modified after the application mirror image is submitted to the test environment.
The invention provides a method for counting program code coverage rate in a cloud container, which is shown in fig. 1 and comprises the following steps:
step S101, arranging a statistics tool container with a code coverage rate statistics tool on a node where a tested program container is located;
step S102, establishing a shared catalog to enable the statistics tool container and the tested program container to communicate with each other;
and step S103, after communication is established, counting the code coverage rate of the tested program in the tested program container by using the code coverage rate counting tool in the counting tool container.
According to the method for counting the code coverage rate of the program in the cloud container, which is provided by the invention, the mutual communication between the counting tool container and the tested program container arranged on the same node is realized by establishing the shared catalog, and the code coverage rate counting tool in the counting tool container is used for counting the code coverage rate of the tested program in the tested program container.
In the embodiment of the present invention, in step S103, 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 statistics tool container and the tested program container;
and according to the configured postStart event, the code coverage statistics tool in the statistics tool container performs code coverage statistics on the tested program instrumentation in the tested program container.
The postStart event refers to a task that is executed after the creation of a container and before the actual RUNNING, when a container is created, the on-cloud container will immediately send the postStart event, and only after the postStart processing function is executed, the state of the container will be changed into RUNNING. In the embodiment of the present invention, postStart events are configured for the statistics tool container and the tested program container respectively, specifically:
configuring a postStart event of the statistics tool container to transmit code coverage statistics tools within the statistics tool container to the shared directory;
and configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
In this embodiment, the statistics mirror postStart event is used to transmit the test toolkit to the shared directory, and the application mirror postStart event is used to receive the test toolkit to the designated directory and instrumentation, so as to perform the code coverage test.
The technical scheme of the invention is further described in detail below with reference to a specific embodiment, and the embodiment provides a method for counting code coverage rate in the containers, and for application images which cannot be modified after being packaged, the code coverage rate in the containers can be collected and counted by using Pod lifecycle management of the Kubernetes in the embodiment in a manner of sharing a catalog.
Kubernetes, an open source for managing containerized applications on multiple hosts in a cloud platform, is a mechanism that allows for easy and efficient deployment of containerized applications, and provides for application deployment, planning, updating, and maintenance. Pod is the smallest unit in Kubernetes that can be created and deployed, and is an application instance in a Kubernetes cluster, which is always deployed on the same Node. The Pod contains one or more containers and also contains resources shared by various containers such as storage, network and the like. Pod supports a variety of container environments.
The method for counting the code coverage rate in the Kubernetes is provided by the embodiment of the invention, the method for counting the coverage rate of the application code instrumentation through the tool kit and the capability of the environment on the Kubernetes cloud are comprehensively used, a technical scheme is designed, and the technical scheme of the invention is described in detail below with reference to the attached drawings.
Fig. 2 is a node structure diagram of the code coverage rate in the statistics Kubernetes provided in this embodiment, which includes: statistics container 1, sharing directory 2, application container 3, toolkit 4, pod5 of Kubernetes.
The statistical container 1 is a container generated by deploying a coverage rate toolkit after being manufactured into an independent statistical mirror image; i.e., containers generated by mirrored deployments with code coverage statistics tools.
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 Pod5 of the same Kubernetes, sharing one and the same directory 2, and the toolkit 4 is transmitted through the shared directory 2.
Fig. 3 is a flowchart showing the statistics of the code coverage rate in Kubernetes in this embodiment, which includes the following steps:
step 1: according to the general mirror image manufacturing method, a mirror image packaging file is compiled, and a test tool package and a required running environment thereof are manufactured into a test statistical mirror image.
Step 2: the statistical image and the application image are arranged in the same Kubernetes Pod.
Namely, the step 1 and the step 2 realize that the statistics tool container with the code coverage rate statistics tool is arranged on the node where the tested program container is located, and specifically comprise the following steps:
acquiring a statistics tool and statistics tool operation environment data for carrying out code coverage rate statistics;
generating a statistics tool container according to the statistics tool and the operation environment data;
and arranging the statistical tool container at the node where the tested program container is located.
Step 3: the shared directory is set through the emptyDir, and the statistical image and the application image respectively set an intra-image directory for sharing, so that the statistical image and the application image can communicate with each other after the container is started.
Step 4: setting a processing function for the life cycle event of the container, modifying the configuration file of the Pod, and adding a postStart event under the life cycle attribute.
The postStart event refers to a task that is executed after a container is created and before the actual RUNNING, when a container is created, kubernetes will immediately send the postStart event, and only after the postStart processing function is executed, the state of the container will be changed to RUNNING.
The postStart event of the statistical mirror image is used for transmitting the tool kit to the shared directory;
the postStart event of the application image is used to receive the toolkit to the specified directory and instrumentation.
Step 5: after the configuration setting is completed, pod is created on the Kubernetes, the container is started, and the operation is ready.
Step 6: according to the postStart event, the statistical container is created and then the tool package is transmitted to the shared directory.
Step 7: upon postStart event, the application container starts to attempt to transfer the toolkit of the shared directory to the specified directory within the application after creation.
Step 8: the application container detects whether the tool package is acquired or not, if not, the step 7 is repeatedly executed, and if the acquisition is successful, the step 9 is executed.
Step 9: the application container posts the application code through the tool pack.
Step 10: after the statistics container and the application container complete the postStart event, the container service is started normally, and the state is changed into RUNNING.
Step 11: run test cases or test application container services using other testing means.
Step 12: after full testing, the statistical container service is accessed, code coverage information is collected according to the functions provided by the tool kit, and a statistical report is obtained.
The method for counting the code coverage rate in the Kubernetes can avoid modification of the application mirror image and code decoupling of the application mirror image. According to the method, a coverage rate statistics tool in a traditional environment is transplanted, meanwhile, the characteristics of a container on the Kubernetes cloud are combined, the coverage rate statistics monitoring is realized under the condition that mirror image matching modification is avoided, and the purpose of testing the coverage condition of an environment check code is achieved.
Meanwhile, as shown in fig. 4, the present invention further provides a device for counting coverage rate of program codes in a cloud container, including:
a container arrangement module 401 for arranging a statistics tool container with a code coverage statistics tool in a Pod where a program container under test is located;
a shared catalog creation module 402 for creating a shared catalog to communicate the statistics tool container with the program container under test;
and the statistics module 403 is configured to perform code coverage statistics on the tested program in the tested program container by using the code coverage statistics tool in the statistics tool container after communication is established.
In an embodiment of the present invention, as shown in fig. 5, the container arrangement module 401 includes:
a data acquisition unit 4011 for acquiring a statistical tool for performing code coverage statistics and statistical tool operation environment data;
a container generation unit 4012 for generating a statistics tool container according to the statistics tool and the operation environment data;
the arrangement unit 4013 is configured to arrange the statistical tool container at 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 utilizing the emptyDir of the container on the cloud so as to enable the statistics tool container and the tested program container to communicate with each other.
In the embodiment of the present invention, as shown in fig. 6, the statistics module 403:
a configuration unit 4031, configured to configure postStart events for the statistics tool container and the tested program container respectively;
and the statistics unit 4032 is configured to perform code coverage statistics on the tested program instrumentation in the tested program container according to the configured postStart event by using the code coverage statistics tool in the statistics tool container.
In an 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 rate statistics tool in the statistics tool container to the shared directory;
the tested container configuration unit 702 is configured to configure the postStart event of the tested program container to obtain the code coverage rate statistics tool from the shared directory to a preset directory for instrumentation.
The embodiment of the invention also provides an electronic device, which can be a desktop computer, a tablet computer, a mobile terminal and the like, and the embodiment is not limited to the desktop computer, the tablet computer, the mobile terminal and the like. In this embodiment, the electronic device may be implemented with reference to the content of the foregoing embodiment, and the content thereof is incorporated herein, and the repetition is not repeated.
Fig. 8 is a schematic block diagram of a system configuration of an electronic device 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; memory 140 is coupled to central processor 100. Notably, the diagram is exemplary; other types of structures may also be used in addition to or in place of the structures to implement telecommunications functions or other functions.
In one embodiment, the on-cloud container program code coverage statistics functionality may be integrated into the central processor 100. Wherein the central processor 100 may be configured to control as follows:
arranging a statistics tool container with a code coverage rate statistics tool on a node where a tested program container is located;
establishing a shared directory to communicate the statistics tool container with the tested program container;
after communication is established, the code coverage rate statistics tool in the statistics tool container is utilized to carry out code coverage rate statistics on the tested programs in the tested program container.
In the embodiment of the present invention, the arranging the statistics tool container with the code coverage rate statistics tool in the node where the tested program container is located includes:
acquiring a statistics tool and statistics tool operation environment data for carrying out code coverage rate statistics;
generating a statistics tool container according to the statistics tool and the operation environment data;
and arranging the statistical tool container at the node where the tested program container is located.
In this embodiment, the establishing the shared directory to enable the statistics tool container and the tested program container to communicate with each other includes:
and establishing a shared directory by utilizing the emptyDir of the container on the cloud so as to enable the statistics tool container and the tested program container to communicate with each other.
In this embodiment, the counting the code coverage rate of the program to be tested in the program container by using the code coverage rate counting tool in the counting tool container includes:
respectively configuring postStart events for the statistics tool container and the tested program container;
and according to the configured postStart event, the code coverage statistics tool in the statistics tool container performs code coverage statistics on the tested program instrumentation in the tested program container.
In this embodiment, the configuring postStart events for the statistics tool container and the tested program container respectively includes:
the postStart event of the statistics tool container is configured to transmit the code coverage rate statistics tool in the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
In the embodiment of the invention, the above-cloud container is a Kubernetes above-cloud container.
The method and the device for counting the code coverage rate in the Kubernetes, provided by the embodiment, make full use of the capability of the traditional code coverage rate tool and the capability of container sharing catalogue and Pod lifecycle management on the Kubernetes cloud, can realize the statistic monitoring of the code coverage rate on the premise of not modifying the application mirror image, reduce the coupling between the statistic tool and the application code, improve the reuse capability, and achieve the aim of counting the coverage rate in the test environment.
In another embodiment, the on-cloud container program code coverage rate statistics device may be configured separately from the central processing unit 100, for example, the on-cloud container program code coverage rate statistics device may be configured as a chip connected to the central processing unit 100, and the on-cloud container program code coverage rate statistics function is implemented under the control of the central processing unit.
As shown in fig. 8, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, a power supply 170. It is noted that the electronic device 600 need not include all of the components shown in fig. 8; in addition, the electronic device 600 may further include components not shown in fig. 8, to which reference is made to the related art.
As shown in fig. 8, the central processor 100, also sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, which central processor 100 receives inputs and controls 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 about failure may be stored, and a program for executing the information may be stored. And the central processor 100 can execute the program stored in the memory 140 to realize information storage or processing, etc.
The input unit 120 provides an input to the central processor 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 for displaying display objects such as images and characters. The display may be, for example, but not limited to, an LCD display.
The memory 140 may be a solid state memory such as Read Only Memory (ROM), random Access Memory (RAM), SIM card, or the like. But also a memory which holds information even when powered down, can be selectively erased and provided with further data, an example of which is sometimes referred to as EPROM or the like. Memory 140 may also be some other type of device. Memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application/function storage 142, the application/function storage 142 for storing application programs and function programs or a flow for executing operations of the electronic device 600 by the central processor 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 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 applications, address book applications, etc.).
The communication module 110 is a transmitter/receiver 110 that transmits and receives signals via an antenna 111. A 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, etc., 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 to receive audio input from the microphone 132 to implement usual telecommunication functions. The audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor 130 is also coupled to the central processor 100 so that sound can be recorded locally through the microphone 132 and so that sound stored locally can be played through the speaker 131.
The embodiment of the invention also provides a computer readable program, wherein when the program is executed in an electronic device, the program causes a computer to execute the method for counting the coverage rate of program codes in a cloud container in the electronic device.
The embodiment of the invention also provides a storage medium storing a computer readable program, wherein the computer readable program causes a computer to execute the statistics of the coverage rate of the program codes in the cloud container in the electronic device.
Preferred embodiments of the present invention are 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 which 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.
It will be appreciated by those skilled in the art that 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 flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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 principles and embodiments of the present invention have been described in detail with reference to specific examples, which are provided to facilitate understanding of the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (12)

1. A method for counting coverage rate of program codes in a cloud container, which is characterized by comprising the following steps:
arranging a statistics tool container with a code coverage rate statistics tool on a node where a tested program container is located;
establishing a shared directory to communicate the statistics tool container with the tested program container;
after communication is established, the code coverage rate statistics tool in the statistics tool container is utilized to carry out code coverage rate statistics on the tested program in the tested program container;
the arrangement of the statistics tool container with the code coverage rate statistics tool on the node where the tested program container is located comprises the following steps:
acquiring a statistics tool and statistics tool operation environment data for carrying out code coverage rate statistics;
generating a statistics tool container according to the statistics tool and the operation environment data;
and arranging the statistical tool container at the node where the tested program container is located.
2. The method of claim 1, wherein establishing a shared directory to enable the statistics tool container to communicate with the tested program container comprises:
and establishing a shared directory by utilizing the emptyDir of the container on the cloud so as to enable the statistics tool container and the tested program container to communicate with each other.
3. The method for counting program code coverage rate in a cloud container according to claim 1, wherein said counting the code coverage rate of the program under test in the program container by using the code coverage rate counting tool in the counting tool container comprises:
respectively configuring postStart events for the statistics tool container and the tested program container;
and according to the configured postStart event, the code coverage statistics tool in the statistics tool container performs code coverage statistics on the tested program instrumentation in the tested program container.
4. The method for counting program code coverage rate in a cloud container as recited in claim 3, wherein said configuring postStart events for said statistics tool container and said tested program container, respectively, comprises:
the postStart event of the statistics tool container is configured to transmit the code coverage rate statistics tool in the statistics tool container to a shared directory;
and configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
5. The method for counting the coverage rate of the program codes in the cloud container according to claim 1, wherein the cloud container is a Kubernetes cloud container.
6. A device for counting coverage rate of program codes in a cloud container, which is characterized by comprising:
the container arrangement module is used for arranging the statistics tool container with the code coverage rate statistics tool at the node where the tested program container is located;
a shared catalog establishing module for establishing a shared catalog to communicate the statistics tool container with the tested program container;
the statistical module is used for counting the code coverage rate of the tested program in the tested program container by using the code coverage rate statistical tool in the statistical tool container after the communication is established;
the container arrangement module comprises:
the data acquisition unit is used for acquiring a statistics tool for carrying out code coverage rate statistics and running environment data of the statistics tool;
a container generating unit for generating a statistics tool container according to the statistics tool and the operation environment data;
and the arrangement unit is used for arranging the statistical tool container at the node where the tested program container is located.
7. The on-cloud container program code coverage statistics apparatus as recited in claim 6, wherein said shared directory creation module creates a shared directory using an emptyDir of the on-cloud container to enable said statistics tool container to communicate with the tested program container.
8. The apparatus for statistics of program code coverage in a cloud container as recited in claim 6, wherein said statistics module comprises:
the configuration unit is used for respectively configuring postStart events for the statistics tool container and the tested program container;
and the statistics unit is used for carrying out code coverage statistics on the tested program instrumentation in the tested program container according to the configured postStart event by the code coverage statistics tool in the statistics tool container.
9. The on-cloud container program code coverage statistics apparatus as recited in claim 8, wherein said configuration unit comprises:
the statistics container configuration unit is used for configuring the postStart event of the statistics tool container to transmit the code coverage rate statistics tool in the statistics tool container to the shared catalogue;
and the tested container configuration unit is used for configuring the postStart event of the tested program container to acquire a code coverage rate statistics tool from the shared catalogue to a preset catalogue for instrumentation.
10. The on-cloud container program code coverage statistics apparatus of claim 6, wherein said on-cloud container is a Kubernetes on-cloud container.
11. 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 5 when executing the computer program.
12. 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 5.
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 CN111538660A (en) 2020-08-14
CN111538660B true 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 (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10162610B2 (en) * 2016-01-04 2018-12-25 Syntel, Inc. Method and apparatus for migration of application source code

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN111538660A (en) 2020-08-14

Similar Documents

Publication Publication Date Title
KR102213693B1 (en) Method and apparatus for logging data records
CN107911249B (en) Method, device and equipment for sending command line of network equipment
CN104965790A (en) Keyword-driven software testing method and system
CN111800443B (en) Data processing system and method, device and electronic equipment
CN112463634B (en) Software testing method and device under micro-service architecture
CN105187733A (en) Video processing method, device and terminal
CN113422794A (en) Traffic recording and playback processing method and device and electronic equipment
CN108684206A (en) A kind of searching method and device
CN104917796A (en) Credit account creating method, system and method
CN112667415B (en) Data calling method and device, readable storage medium and electronic equipment
CN104657435A (en) Storage management method for application data and network management system
CN111782470A (en) Distributed container log data processing method and device
CN106294108A (en) Applied program testing method and device
CN111371695B (en) Service flow limiting method and device
CN111464352A (en) Call link data processing method and device
CN111324480B (en) Large-scale host transaction fault positioning system and method
CN111538660B (en) Method and device for counting coverage rate of program codes in cloud container
WO2023116104A1 (en) Configuration parameter updating method and apparatus, and related device
CN113268272B (en) Application delivery method, device and system based on private cloud
CN113050985B (en) Front-end engineering dependency automatic registration method and device
CN114490402A (en) Method and device for checking validity of message field
US9870217B2 (en) Toolkit event configuration of applets on a card computing device with installation parameters
CN106557530B (en) Operation system, data recovery method and device
CN113918436A (en) Log processing method and device
CN111930625A (en) Log obtaining method, device and system based on cloud service platform

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