当前位置:网站首页>Quickly use Jacobo code coverage statistics
Quickly use Jacobo code coverage statistics
2022-07-07 07:58:00 【Wu_ Candy】
brief introduction
Jacoco Is an open source coverage tool .
Jacoco Can be embedded into Ant
、Maven
in , And provides EclEmma Eclipse
plug-in unit , You can also use JavaAgent
Technical monitoring Java Program
.
Many third-party tools provide access to Jacoco Integration of , Such as sonar、Jenkins etc. .
Today's sharing environment is :
k8s+jenkins
Built , It involves in node Generated in the container of the node machine jacoco.exec
file , Then copy it to the node machine , Then from the node machine jacoco.exec
File copy to jenkins
In the code base of , Used to generate reports .
Operation steps
**Step1:** Introduce the corresponding jar To the directory of application services , And modify the startup script of the application service that needs to be monitored
The following is in jenkins The corresponding application service deployment script is adjusted
echo ' cd /opt/ wget http://192.168.214.100:7777/jacoco/tools/jacocoagent.jar # Here a siampleHttp service , Used to get jar package wget http://192.168.214.100:7777/jacoco/tools/jacocoant.jar wget -O buildexec.xml http://192.168.214.100:7777/jacoco/buildexec/build.xml wget http://192.168.214.100:7777/jacoco/tools/cron.sh sh cron.sh& # See... Here step2 Script edited in sed -i "s#exec java#exec java -javaagent:/opt/jacocoagent.jar=includes=*,output=tcpserver,port=8044,address=127.0.0.1 -Xverify:none -javaagent:/opt/skywalking-agent/skywalking-agent.jar #g" /opt/mt/bin/startup.sh && cd /opt/mt/ && dos2unix -k start.sh && cd /opt/mt/bin/ && dos2unix -k startup.sh && sh startup.sh '> ./start.sh
Step2: It is used to generate jacoco.exec
this jacoco.exec
The file is one generated by the fetched code execution file exec file
, This file is just Step1 A script file required in .
[[email protected] tools]# more cron.sh
while true;do ant dump -buildfile buildexec.xml;sleep 60;done
Step3: stay jenkins
Pull the source code , The generated jacoco.exec
Copy the file , Then generate the final execution report
Here is one jenkins job
cd ../test-deploy
wget -O buildreport.xml http://192.168.214.100:7777/jacoco/buildreport/build_test_model.xml
wget -nc http://192.168.214.100:7777/jacoco/tools/jacocoant.jar
wget -nc http://192.168.214.100:7777/jacoco/tools/dlexec.sh
sh dlexec.sh testqyd test-model # Detailed see step4
ant report -buildfile ./buildreport.xml # Generate executed reports
open site:http://192.168.214.100:7777/jacoco/report/testqyd/test-model/jacocoReport/ # Open the report
Step4: from docker
In order to get jacoco.exec
file , And then on jenkins
Extract the source code directory
[[email protected]]# more dlexec.sh
platformname=$1
projectname=$2
echo " ############################################# # from node Node machine download jacoco.exec File execution script # ############################################# "
case $# in
0)
echo ""
;;
1)
ssh [email protected] "kubectl get pods -n $platformname -o wide"
;;
2)
pnip=`ssh 192.168.214.50 "kubectl --kubeconfig=/etc/kubernetes/kubelet.kubeconfig get pods -n $platformname -o wide|grep $projectname|awk '{print \\$7}'|head -1"`
if [ $pnip == '192.168.214.55' ];then
pnip='[email protected]'
rqid=`ssh $pnip "docker ps |grep $platformname/$projectname|awk '{print \\$1}'|head -1"`
ssh $pnip "docker cp $rqid:/opt/jacoco.exec /opt/test/jacoco.exec"
scp $pnip:/opt/test/jacoco.exec ./
elif [ $pnip == '192.168.214.56' ];then
pnip='[email protected]'
rqid=`ssh $pnip "docker ps |grep $platformname/$projectname|awk '{print \\$1}'|head -1"`
ssh $pnip "docker cp $rqid:/opt/jacoco.exec /opt/test/jacoco.exec"
scp $pnip:/opt/test/jacoco.exec ./
else
echo "not found!"
fi
;;
esac
Jenkins The execution effect diagram is shown in the following figure :
Welcome to your attention : The way of immeasurable testing
official account , reply : Claim resources
Python+Unittest frame API automation 、
Python+Unittest frame API automation 、
Python+Pytest frame API automation 、
Python+Pandas+Pyecharts Big data analysis 、
Python+Selenium frame Web Of UI automation 、
Python+Appium frame APP Of UI automation 、
Python Programming learning resources dry goods 、
Vue Front end component framework development 、
Resources and code Free ~
contain : Data analysis 、 big data 、 machine learning 、 Test Development 、API Interface automation 、 Test operation and maintenance 、UI automation 、 Performance testing 、 code detection 、 Programming technology, etc .
WeChat search official account : The way of immeasurable testing
, Add the attention , Let's grow together !
边栏推荐
- 【斯坦福计网CS144项目】Lab4: TCPConnection
- [Stanford Jiwang cs144 project] lab4: tcpconnection
- Codeforces Global Round 19
- Idea add class annotation template and method template
- 【数学笔记】弧度
- Pytorch parameter initialization
- 2022焊工(初级)判断题及在线模拟考试
- paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
- [GUET-CTF2019]虚假的压缩包
- Chip information website Yite Chuangxin
猜你喜欢
Jenkins remote build project timeout problem
[experience sharing] how to expand the cloud service icon for Visio
今日现货白银操作建议
Linux server development, MySQL index principle and optimization
You Li takes you to talk about C language 6 (common keywords)
【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
[UTCTF2020]file header
Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)
The configuration that needs to be modified when switching between high and low versions of MySQL 5-8 (take aicode as an example here)
Leetcode 90: subset II
随机推荐
Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)
Shell 脚本的替换功能实现
[Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替
有 Docker 谁还在自己本地安装 Mysql ?
json 数据展平pd.json_normalize
Is the test cycle compressed? Teach you 9 ways to deal with it
Introduction to basic components of wechat applet
2022制冷与空调设备运行操作复训题库及答案
Pytorch parameter initialization
2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
【webrtc】m98 screen和window采集
padavan手动安装php
这5个摸鱼神器太火了!程序员:知道了快删!
[advanced digital IC Verification] command query method and common command interpretation of VCs tool
Rust Versus Go(哪种是我的首选语言?)
Leetcode 40: combined sum II
Linux server development, MySQL index principle and optimization
Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)
【斯坦福计网CS144项目】Lab4: TCPConnection
Cnopendata geographical distribution data of religious places in China