测试开发技术网站
博客
设计
设计
开发
Python
测试
unittest
运维
Linux基础应用
CI/CD
CI/CD
数据库
数据库
云计算
云计算
云原生
云原生
爬虫
爬虫
数据分析
数据分析
人工智能
人工智能
登录
注册
mugen----基于openEuler虚拟机远端执行mugen测试脚本
收藏本文
作者:redrose2100 类别: 日期:2022-11-15 05:22:17 阅读:823 次 消耗积分:0 分
[【原文链接】mugen----基于openEuler虚拟机远端执行mugen测试脚本](http://devops-dev.com/article/441) (1)首先需要准备两台台openEuler虚拟机,若未安装,可参考 [VMware安装openEuler-22.03-LTS版本的虚拟机](http://blog.redrose2100.com/article/420) 安装两台openEuler虚拟机,一台作为执行脚本的机器,一台作为远端被测机器,比如这里分别为:192.168.1.8(本地),192.168.1.12(远端) (2)本地(192.168.1.8)安装git工具,若已安装,则直接跳过 ```bash dnf install -y git ``` (3)在本地(192.168.1.8)下载mugen代码 ```bash cd /opt/ git clone https://gitee.com/openeuler/mugen.git ``` (4)本地(192.168.1.8)安装依赖 ```bash cd mugen/ chmod 777 dep_install.sh bash dep_install.sh ``` (5)查看命令帮助信息 ```bash [root@openEuler-1 mugen]# bash mugen.sh --help mugen.sh:非法选项 -- - Usage: -c: configuration environment of test framework -a: execute all use cases -f: designated test suite -r: designated test case -x: the shell script is executed in debug mode -b: do make for test suite if test suite path have makefile or Makefile file -s: runing test case at remote NODE1 Example: run all cases: normal mode: bash mugen.sh -a debug mode: bash mugen.sh -a -x run test suite: normal mode: bash mugen.sh -f test_suite debug mode: bash mugen.sh -f test_suite -x run test case: normal mode: bash mugen.sh -f test_suite -r test_case debug mode: bash mugen.sh -f test_suite -r test_case -x run at remote: normal mode: bash mugen.sh -a -s bash mugen.sh -f test_suite -s bash mugen.sh -f test_suite -r test_case -s debug mode: bash mugen.sh -a -s bash mugen.sh -f test_suite -s bash mugen.sh -f test_suite -r test_case -s configure env of test framework: bash mugen.sh -c --ip $ip --password $passwd --user $user --port $port if want run at remote should add --run_remote if want run at remote copy all testcase once add --put_all do make for test suite: for all test suite: bash mugen.sh -b -a for one test suite: bash mugen.sh -b test_suite ``` (6)在本地(192.168.1.8)配置环境变量 因为这里使用的远端(192.168.1.12)作为被测虚拟机,因此ip设置为192.168.1.12,此外还需要增加 --run_remote 参数,即 ```bash bash mugen.sh -c --ip 192.168.1.12 --password ISRCpassword123 --user root --port 22 --run_remote ``` (7)配置环境后,会自动生成confg/env.json环境变量文件 ```bash [root@openEuler-1 mugen]# cat conf/env.json { "NODE": [ { "ID": 1, "LOCALTION": "local", "MACHINE": "physical", "FRAME": "x86_64", "NIC": "ens33", "MAC": "00:0c:29:da:c2:41", "IPV4": "192.168.1.12", "USER": "root", "PASSWORD": "xxxxxx", "SSH_PORT": 22, "BMC_IP": "", "BMC_USER": "", "BMC_PASSWORD": "" } ] }[root@openEuler-1 mugen]# ``` (8)测试脚本目录说明 mugen测试目录如下,suite2cases 目录定义了所有的测试套,testcases目录下则是所有的脚本,testcases中的每个sh文件即为一个测试脚本,而目录只是用来分类管理测试用例的,测试套的名字并不是从testcases中的文件夹名。 ![](https://redrose2100.oss-cn-hangzhou.aliyuncs.com/img/b4eedea4-63e5-11ed-aed9-0242ac110002.png) 如下,展开suite2cases目录,这里可以看到每个json的文件名(去掉后缀),比如这里acl就是一个测试套,而json文件中定义了当前测试套包含哪些用例,用例的路径这了也给出了对应关系。 ![](https://redrose2100.oss-cn-hangzhou.aliyuncs.com/img/25cde3ea-63e6-11ed-aed9-0242ac110002.png) (9)然后就可以执行测试脚本了,这里如下几个参数需要关注一下: * -f:指定测试套 * -r:指定测试用例 * -a:执行所有用例 * -x:输出debug模式的信息,即控制套输出更加详细的内容 * -s:在远端节点执行脚本 比如远端执行测试套acl的的用例 ```bash bash mugen.sh -f acl -x -s ``` 执行结果如下,可以看出这里有三个成功,五个失败,具体失败原因,这里暂时不去深究,只作为演示执行的示例 ```bash [root@openEuler-1 mugen]# bash mugen.sh -f acl -x -s Tue Nov 15 12:30:24 2022 - INFO - start to put file:/opt/mugen/conf/mugen.env...... Tue Nov 15 12:30:25 2022 - INFO - start to run testcase:oe_test_acl_setfacl. Tue Nov 15 12:30:25 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:30:49 2022 - INFO - The case exit by code 0. Tue Nov 15 12:30:49 2022 - INFO - End to run testcase:oe_test_acl_setfacl. Tue Nov 15 12:30:49 2022 - INFO - start to run testcase:oe_test_acl_chacl. Tue Nov 15 12:30:50 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:12 2022 - INFO - The case exit by code 0. Tue Nov 15 12:31:12 2022 - INFO - End to run testcase:oe_test_acl_chacl. Tue Nov 15 12:31:12 2022 - INFO - start to run testcase:oe_test_acl_getfacl. Tue Nov 15 12:31:13 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:34 2022 - INFO - The case exit by code 0. Tue Nov 15 12:31:34 2022 - INFO - End to run testcase:oe_test_acl_getfacl. Tue Nov 15 12:31:34 2022 - INFO - start to run testcase:oe_test_acl_add_write_permissions. Tue Nov 15 12:31:35 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:31:35 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:35 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 12:31:35 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 12:31:36 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 12:31:36 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 12:31:36 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 12:31:36 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:38 2022 - ERROR - The case exit by code 1. Tue Nov 15 12:31:38 2022 - INFO - End to run testcase:oe_test_acl_add_write_permissions. Tue Nov 15 12:31:38 2022 - INFO - start to run testcase:oe_test_acl_check_create. Tue Nov 15 12:31:39 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:31:39 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:39 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 12:31:39 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 12:31:40 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 12:31:40 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 12:31:40 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 12:31:40 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:41 2022 - ERROR - The case exit by code 1. Tue Nov 15 12:31:42 2022 - INFO - End to run testcase:oe_test_acl_check_create. Tue Nov 15 12:31:42 2022 - INFO - start to run testcase:oe_test_acl_change_mask. Tue Nov 15 12:31:42 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 12:31:43 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:45 2022 - ERROR - The case exit by code 1. Tue Nov 15 12:31:46 2022 - INFO - End to run testcase:oe_test_acl_change_mask. Tue Nov 15 12:31:46 2022 - INFO - start to run testcase:oe_test_acl_only_root_permission. Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 12:31:47 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 12:31:48 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:50 2022 - ERROR - The case exit by code 1. Tue Nov 15 12:31:50 2022 - INFO - End to run testcase:oe_test_acl_only_root_permission. Tue Nov 15 12:31:50 2022 - INFO - start to run testcase:oe_test_acl_defaulr_rule. Tue Nov 15 12:31:51 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 12:31:51 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 12:31:51 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 12:31:51 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 12:31:51 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 12:31:52 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 12:31:52 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 12:31:52 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 12:31:53 2022 - ERROR - The case exit by code 1. Tue Nov 15 12:31:54 2022 - INFO - End to run testcase:oe_test_acl_defaulr_rule. Tue Nov 15 12:31:54 2022 - INFO - A total of 8 use cases were executed, with 3 successes and 5 failures. [root@openEuler-1 mugen]# ``` 为了更好的验证确实是远端执行的,这里把远端虚拟机(192.168.1.12)关机,然后再次执行 ```bash bash mugen.sh -f acl -x -s ``` 执行结果如下,可以看到连接均失败。这里可以从侧面说明确实在远端执行 ```bash [root@openEuler-1 mugen]# bash mugen.sh -f acl -x -s Tue Nov 15 13:13:46 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:13:46 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:13:50 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:13:50 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:13:53 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:13:53 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:13:53 2022 - INFO - start to run testcase:oe_test_acl_only_root_permission. Tue Nov 15 13:13:56 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:13:56 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:13:56 2022 - INFO - start to run testcase:oe_test_acl_check_create. Tue Nov 15 13:13:59 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:13:59 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:13:59 2022 - INFO - start to run testcase:oe_test_acl_getfacl. Tue Nov 15 13:14:02 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:02 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:02 2022 - INFO - start to run testcase:oe_test_acl_add_write_permissions. Tue Nov 15 13:14:05 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:05 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:05 2022 - INFO - start to run testcase:oe_test_acl_defaulr_rule. Tue Nov 15 13:14:08 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:08 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:08 2022 - INFO - start to run testcase:oe_test_acl_change_mask. Tue Nov 15 13:14:11 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:11 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:11 2022 - INFO - start to run testcase:oe_test_acl_setfacl. Tue Nov 15 13:14:14 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:14 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:14 2022 - INFO - start to run testcase:oe_test_acl_chacl. Tue Nov 15 13:14:17 2022 - ERROR - Failed to connect the remote machine:192.168.1.12. Tue Nov 15 13:14:17 2022 - ERROR - [Errno None] Unable to connect to port 22 on 192.168.1.12 Tue Nov 15 13:14:17 2022 - INFO - A total of 8 use cases were executed, with 0 successes and 0 failures. [root@openEuler-1 mugen]# ``` 比如想执行这里面具体一个用例 ![](https://redrose2100.oss-cn-hangzhou.aliyuncs.com/img/292bc2e4-63e8-11ed-aed9-0242ac110002.png) 则使用如下命令 ```bash bash mugen.sh -f acl -r oe_test_acl_add_write_permissions -x -s ``` 执行结果如下: ```bash [root@openEuler-1 mugen]# bash mugen.sh -f acl -r oe_test_acl_add_write_permissions -x -s Tue Nov 15 13:20:54 2022 - INFO - start to put file:/opt/mugen/conf/mugen.env...... Tue Nov 15 13:20:55 2022 - INFO - start to run testcase:oe_test_acl_add_write_permissions. Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_setfacl/oe_test_acl_setfacl.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_chacl/oe_test_acl_chacl.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_defaulr_rule.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_change_mask.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_check_create.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_add_write_permissions.sh...... Tue Nov 15 13:20:56 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_only_root_permission.sh...... Tue Nov 15 13:20:57 2022 - INFO - start to put file:/opt/mugen/testcases/cli-test/acl/oe_test_acl_getfacl/oe_test_acl_getfacl.sh...... Tue Nov 15 13:20:58 2022 - ERROR - The case exit by code 1. Tue Nov 15 13:20:59 2022 - INFO - End to run testcase:oe_test_acl_add_write_permissions. Tue Nov 15 13:20:59 2022 - INFO - A total of 1 use cases were executed, with 0 successes and 1 failures. [root@openEuler-1 mugen]# ``` 比如要执行所有脚本,则执行如下命令(这里就不演示了,数量比较多) ```bash bash mugen.sh -a -x -s ```
始终坚持开源开放共享精神,同时感谢您的充电鼓励和支持!
版权所有,转载本站文章请注明出处:redrose2100, http://blog.redrose2100.com/article/441
上一篇:
基于x86架构的CentOS7虚拟机通过qemu安装ARM架构CentOS7虚拟机
下一篇:
linux程序返回码的含义
搜索
个人成就
出版书籍
《Pytest企业级应用实战》
测试开发技术全栈公众号
测试开发技术全栈公众号
DevOps技术交流微信群
加微信邀请进群
常用网站链接
开源软件洞察
云原生技术栈全景图
Python语言官方文档
Golang官方文档
Docker官方文档
Jenkins中文用户手册
Scrapy官方文档
VUE官方文档
Harbor官方文档
openQA官方文档
云原生开源社区
开源中国
Kubernetes中文文档
Markdown语法官方教程
Kubernetes中文社区
Kubersphere官方文档
BootStrap中文网站
JavaScript中文网
NumPy官方文档
Pandas官方文档
GitLink确实开源网站
数据库排名网站
编程语言排名网站
SEO综合查询网站
数学加减法练习自动生成网站
Kickstart Generator
文章分类
最新文章
最多阅读
特别推荐
×
Close
登录
注册
找回密码
登录邮箱:
登录密码:
图片验证码:
注册邮箱:
注册密码:
邮箱验证码:
发送邮件
注册邮箱:
新的密码:
邮箱验证码:
发送邮件