diff --git a/docs/system_base/abrt/tc_abrt_fun001.yaml b/docs/system_base/abrt/tc_abrt_fun001.yaml new file mode 100644 index 0000000000000000000000000000000000000000..514a7bd1cc0614cf03f274eb69a140e429ee2f09 --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun001.yaml @@ -0,0 +1,23 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, abrt-journal-core.service +用例描述: abrt-journal-core.service基本功能 +修改人: douzhichong + +前置条件: +安装 abrt-addon-ccpp +测试步骤: +- 测试abrt-journal-core.service重启功能 +-测试abrt-journal-core.service停止功能 +-测试abrt-journal-core.service启动功能 +-判断当前abrt-journal-core.service启用状态,测试disable,enable功能 +-查看日志中从测试开始时间(log_time)起的日志中是否有fail或error关键字(排除无关消息)。 +-测试reload +期望结果: +-服务正常启动,停止,查看,重启 +-disable,enable功能正常 +-日志无报错 +-reload返回预期结果 diff --git a/docs/system_base/abrt/tc_abrt_fun002.yaml b/docs/system_base/abrt/tc_abrt_fun002.yaml new file mode 100644 index 0000000000000000000000000000000000000000..742149d2f9001952d34c2f1ed38e82d1892a6a9a --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun002.yaml @@ -0,0 +1,23 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, abrt-oops.service +用例描述: abrt-oops.service基本功能 +修改人: douzhichong + +前置条件: +安装 abrt-addon-ccpp +测试步骤: +- 测试abrt-oops.service重启功能 +-测试abrt-oops.service停止功能 +-测试abrt-oops.service启动功能 +-判断当前abrt-oops.service启用状态,测试disable,enable功能 +-查看日志中从测试开始时间(log_time)起的日志中是否有fail或error关键字(排除无关消息)。 +-测试reload +期望结果: +-服务正常启动,停止,查看,重启 +-disable,enable功能正常 +-日志无报错 +-reload返回预期结果 diff --git a/docs/system_base/abrt/tc_abrt_fun003.yaml b/docs/system_base/abrt/tc_abrt_fun003.yaml new file mode 100644 index 0000000000000000000000000000000000000000..634de743199043e39bb57db6ad4447d26a68383a --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun003.yaml @@ -0,0 +1,21 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local,abrt +用例描述: abrt-pstoreoops.service服务测试 +修改人: douzhichong + +前置条件: +系统已安装abrt-addon-pstoreoops + +测试步骤: +- 检查服务状态是否为inactive +- 根据服务启用状态测试enable/disable功能 +- 检查服务日志是否有错误信息 + +期望结果: +- 服务状态显示正确 +- enable/disable功能正常 +- 日志无错误信息 diff --git a/docs/system_base/abrt/tc_abrt_fun004.yaml b/docs/system_base/abrt/tc_abrt_fun004.yaml new file mode 100644 index 0000000000000000000000000000000000000000..741b45b1d1c15f4036293f1b365eab9eb458e275 --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun004.yaml @@ -0,0 +1,25 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, abrt-vmcore.service +用例描述: abrt-vmcore.service基本功能 +修改人: douzhichong + +前置条件: +-安装 abrt-addon-vmcore +-启动abrtd.service +-创建/var/crash/test文件 +测试步骤: +- 测试abrt-vmcore.service重启功能 +-测试abrt-vmcore.service停止功能 +-测试abrt-vmcore.service启动功能 +-判断当前abrt-vmcore.service启用状态,测试disable,enable功能 +-查看日志中从测试开始时间(log_time)起的日志中是否有fail或error关键字(排除无关消息)。 +-测试reload +期望结果: +-服务正常启动,停止,查看,重启 +-disable,enable功能正常 +-日志无报错 +-reload返回预期结果 diff --git a/docs/system_base/abrt/tc_abrt_fun005.yaml b/docs/system_base/abrt/tc_abrt_fun005.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bd5218fe9e5f81329e4c15b83d45634ebaa5d806 --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun005.yaml @@ -0,0 +1,24 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, abrt-xorg.service +用例描述: abrt-xorg.service基本功能 +修改人: douzhichong + +前置条件: +-安装abrt-addon-xorg +-启动abrtd.service +测试步骤: +- 测试abrt-xorg.service重启功能 +-测试abrt-xorg.service停止功能 +-测试abrt-xorg.service启动功能 +-判断当前abrt-xorg.service启用状态,测试disable,enable功能 +-查看日志中从测试开始时间(log_time)起的日志中是否有fail或error关键字(排除无关消息)。 +-测试reload +期望结果: +-服务正常启动,停止,查看,重启 +-disable,enable功能正常 +-日志无报错 +-reload返回预期结果 diff --git a/docs/system_base/abrt/tc_abrt_fun006.yaml b/docs/system_base/abrt/tc_abrt_fun006.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c27f91ebc2c1f4e161bf02f3297e7fc16578b4a4 --- /dev/null +++ b/docs/system_base/abrt/tc_abrt_fun006.yaml @@ -0,0 +1,23 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, abrtd.service +用例描述: abrtd.service基本功能 +修改人: douzhichong + +前置条件: +-安装abrt +测试步骤: +- 测试abrtd.service重启功能 +-测试abrtd.service停止功能 +-测试abrtd.service启动功能 +-判断当前abrtd.service启用状态,测试disable,enable功能 +-查看日志中从测试开始时间(log_time)起的日志中是否有fail或error关键字(排除无关消息)。 +-测试reload +期望结果: +-服务正常启动,停止,查看,重启 +-disable,enable功能正常 +-日志无报错 +-reload返回预期结果 diff --git a/tests/system_base/abrt/tc_abrt_fun001.py b/tests/system_base/abrt/tc_abrt_fun001.py new file mode 100644 index 0000000000000000000000000000000000000000..f77cc79e54f79b8b7cf9d5a0379481b8080a754e --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun001.py @@ -0,0 +1,102 @@ +""" +@File: tc_abrt_fun001.py +@Time: 2025/9/26 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun001.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt-addon-ccpp"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('systemctl start abrtd.service') + + + def test(self): + + service = 'abrt-journal-core.service' + # test_execution + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + # test_restart + code, result = self.cmd(f"systemctl restart {service}") + self.assertFalse(code, f"{service} restart failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} restart failed") + code, result = self.cmd(f"systemctl stop {service}") + self.assertFalse(code, f"{service} stop failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: inactive'") + self.assertFalse(code, f"{service} stop failed") + code, result = self.cmd(f"systemctl start {service}") + self.assertFalse(code, f"{service} start failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} start failed") + # test_enabled + command = f'systemctl is-enabled {service}' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif result.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif result.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif result.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + # test_reload + self.cmd(f'systemctl start {service}') + command = f'systemctl cat {service} | grep -q "ExecReload"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result.returncode: + code, result = self.cmd(f'systemctl reload {service}') + self.assertFalse(code, f"reload unit {service} failed") + else: + code, result = self.cmd(f'systemctl reload {service} 2>&1 | grep "Job type reload is not applicable"') + self.assertFalse(code, f"Job type reload is not applicable for unit {service}") + code, result = self.cmd(f'systemctl status {service} | grep "Active: active"') + if code: + command = f'systemctl status {service} | grep "inactive (dead)"' + result1 = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result1.returncode: + code2, result = self.cmd(f'systemctl status {service} | grep "Condition check" | grep "skip"') + self.assertFalse(code2, f'{service} reload causes the service status to change') + else: + return 1 + + def tearDown(self): + self.cmd('systemctl stop abrtd.service') + super().tearDown(self.PARAM_DIC) + diff --git a/tests/system_base/abrt/tc_abrt_fun002.py b/tests/system_base/abrt/tc_abrt_fun002.py new file mode 100644 index 0000000000000000000000000000000000000000..f054575e9d7095f2eacdc2f46feaa8aba06abfd4 --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun002.py @@ -0,0 +1,101 @@ +""" +@File: tc_abrt_fun002.py +@Time: 2025/9/26 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun002.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt-addon-kerneloops"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('systemctl start abrtd.service') + + + def test(self): + + service = 'abrt-oops.service' + # test_execution + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + # test_restart + code, result = self.cmd(f"systemctl restart {service}") + self.assertFalse(code, f"{service} restart failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} restart failed") + code, result = self.cmd(f"systemctl stop {service}") + self.assertFalse(code, f"{service} stop failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: inactive'") + self.assertFalse(code, f"{service} stop failed") + code, result = self.cmd(f"systemctl start {service}") + self.assertFalse(code, f"{service} start failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} start failed") + # test_enabled + command = f'systemctl is-enabled {service}' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif result.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif result.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif result.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + # test_reload + self.cmd(f'systemctl start {service}') + command = f'systemctl cat {service} | grep -q "ExecReload"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result.returncode: + code, result = self.cmd(f'systemctl reload {service}') + self.assertFalse(code, f"reload unit {service} failed") + else: + code, result = self.cmd(f'systemctl reload {service} 2>&1 | grep "Job type reload is not applicable"') + self.assertFalse(code, f"Job type reload is not applicable for unit {service}") + code, result = self.cmd(f'systemctl status {service} | grep "Active: active"') + if code: + command = f'systemctl status {service} | grep "inactive (dead)"' + result1 = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result1.returncode: + code2, result = self.cmd(f'systemctl status {service} | grep "Condition check" | grep "skip"') + self.assertFalse(code2, f'{service} reload causes the service status to change') + else: + return 1 + + def tearDown(self): + self.cmd('systemctl stop abrtd.service') + super().tearDown(self.PARAM_DIC) diff --git a/tests/system_base/abrt/tc_abrt_fun003.py b/tests/system_base/abrt/tc_abrt_fun003.py new file mode 100644 index 0000000000000000000000000000000000000000..bdc505f0275c6934e6bf6b54d3b01f4711fa2024 --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun003.py @@ -0,0 +1,66 @@ +""" +@File: tc_abrt_fun003.py +@Time: 2025/9/25 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun003.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt-addon-pstoreoops"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + + def test(self): + service = 'abrt-pstoreoops.service' + status = 'inactive (dead)' + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + command = f'systemctl status {service} | grep "Active" | grep -v "{status}"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error for the status of {service}") + # test_enabled + command = f'systemctl is-enabled {service}' + state = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + if state.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif state.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif state.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif state.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + + def tearDown(self): + super().tearDown(self.PARAM_DIC) \ No newline at end of file diff --git a/tests/system_base/abrt/tc_abrt_fun004.py b/tests/system_base/abrt/tc_abrt_fun004.py new file mode 100644 index 0000000000000000000000000000000000000000..4f5b79e620a1c9524e8316380c962d0605fe885d --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun004.py @@ -0,0 +1,104 @@ +""" +@File: tc_abrt_fun004.py +@Time: 2025/9/26 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun004.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt-addon-vmcore"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('systemctl start abrtd.service') + self.cmd('touch /var/crash/test') + + + def test(self): + + service = 'abrt-vmcore.service' + # test_execution + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + # test_restart + code, result = self.cmd(f"systemctl restart {service}") + self.assertFalse(code, f"{service} restart failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} restart failed") + code, result = self.cmd(f"systemctl stop {service}") + self.assertFalse(code, f"{service} stop failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: inactive'") + self.assertFalse(code, f"{service} stop failed") + code, result = self.cmd(f"systemctl start {service}") + self.assertFalse(code, f"{service} start failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} start failed") + # test_enabled + command = f'systemctl is-enabled {service}' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif result.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif result.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif result.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + # test_reload + self.cmd(f'systemctl start {service}') + command = f'systemctl cat {service} | grep -q "ExecReload"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result.returncode: + code, result = self.cmd(f'systemctl reload {service}') + self.assertFalse(code, f"reload unit {service} failed") + else: + code, result = self.cmd(f'systemctl reload {service} 2>&1 | grep "Job type reload is not applicable"') + self.assertFalse(code, f"Job type reload is not applicable for unit {service}") + code, result = self.cmd(f'systemctl status {service} | grep "Active: active"') + if code: + command = f'systemctl status {service} | grep "inactive (dead)"' + result1 = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result1.returncode: + code2, result = self.cmd(f'systemctl status {service} | grep "Condition check" | grep "skip"') + self.assertFalse(code2, f'{service} reload causes the service status to change') + else: + return 1 + + def tearDown(self): + self.cmd(' systemctl stop abrt-vmcore.service') + self.cmd('systemctl stop abrtd.service') + self.cmd(' rm -rf /var/crash/test') + super().tearDown(self.PARAM_DIC) diff --git a/tests/system_base/abrt/tc_abrt_fun005.py b/tests/system_base/abrt/tc_abrt_fun005.py new file mode 100644 index 0000000000000000000000000000000000000000..7a9314f6b61c977c25885e76c5f6cbe10125d49c --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun005.py @@ -0,0 +1,103 @@ +""" +@File: tc_abrt_fun005.py +@Time: 2025/9/26 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun005.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt-addon-xorg"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('systemctl start abrtd.service') + + + def test(self): + + service = 'abrt-xorg.service' + # test_execution + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + # test_restart + code, result = self.cmd(f"systemctl restart {service}") + self.assertFalse(code, f"{service} restart failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} restart failed") + code, result = self.cmd(f"systemctl stop {service}") + self.assertFalse(code, f"{service} stop failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: inactive'") + self.assertFalse(code, f"{service} stop failed") + code, result = self.cmd(f"systemctl start {service}") + self.assertFalse(code, f"{service} start failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} start failed") + # test_enabled + command = f'systemctl is-enabled {service}' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif result.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif result.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif result.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + # test_reload + self.cmd(f'systemctl start {service}') + command = f'systemctl cat {service} | grep -q "ExecReload"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result.returncode: + code, result = self.cmd(f'systemctl reload {service}') + self.assertFalse(code, f"reload unit {service} failed") + else: + code, result = self.cmd(f'systemctl reload {service} 2>&1 | grep "Job type reload is not applicable"') + self.assertFalse(code, f"Job type reload is not applicable for unit {service}") + code, result = self.cmd(f'systemctl status {service} | grep "Active: active"') + if code: + command = f'systemctl status {service} | grep "inactive (dead)"' + result1 = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result1.returncode: + code2, result = self.cmd(f'systemctl status {service} | grep "Condition check" | grep "skip"') + self.assertFalse(code2, f'{service} reload causes the service status to change') + else: + return 1 + + def tearDown(self): + self.cmd(' systemctl stop abrt-xorg.service') + self.cmd('systemctl stop abrtd.service') + self.cmd(' rm -rf /var/crash/test') + super().tearDown(self.PARAM_DIC) diff --git a/tests/system_base/abrt/tc_abrt_fun006.py b/tests/system_base/abrt/tc_abrt_fun006.py new file mode 100644 index 0000000000000000000000000000000000000000..7018aa4b704673f69edbadca0eb7bdd064c79e8a --- /dev/null +++ b/tests/system_base/abrt/tc_abrt_fun006.py @@ -0,0 +1,102 @@ +""" +@File: tc_abrt_fun006.py +@Time: 2025/9/26 15:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_abrt_fun006.yaml for details + + :avocado: tags=P1,noarch,local,abrt + """ + PARAM_DIC = {"pkg_name": "abrt"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + + + def test(self): + + service = 'abrtd.service' + # test_execution + code, log_time = self.cmd("date '+%Y-%m-%d %T'") + # test_restart + code, result = self.cmd(f"systemctl restart {service}") + self.assertFalse(code, f"{service} restart failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} restart failed") + code, result = self.cmd(f"systemctl stop {service}") + self.assertFalse(code, f"{service} stop failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: inactive'") + self.assertFalse(code, f"{service} stop failed") + code, result = self.cmd(f"systemctl start {service}") + self.assertFalse(code, f"{service} start failed") + self.cmd('sleep 5') + code, result = self.cmd(f"systemctl status {service}| grep 'Active: active'") + self.assertFalse(code, f"{service} start failed") + # test_enabled + command = f'systemctl is-enabled {service}' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stdout == "enabled": + code, symlink_file = self.cmd( + f'systemctl disable {service} 2>&1 | grep "Removed" | awk \'{{print $2}}\' | awk \'{{print substr($0,1,length($0)-1)}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + self.cmd(f'systemctl enable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + elif result.stdout == "disabled": + code, symlink_file = self.cmd( + f'systemctl enable "{service}" 2>&1 | grep "Created symlink" | awk \'{{print $3}}\' | tr -d \'\"\'') + code, result = self.cmd(f'find {symlink_file}') + self.assertFalse(code, f"{service} enable failed") + self.cmd(f'systemctl disable {service}') + code, result = self.cmd(f'find {symlink_file}') + self.assertTrue(code, f"{service} disable failed") + elif result.stdout == "masked": + self.log.info("Unit is masked, ignoring.") + elif result.stdout == "static": + self.log.info( + "The unit files have no installation config,This means they are not meant to be enabled using systemctl.") + else: + self.log.info("Unit is indirect, ignoring.") + # execution + command = f' journalctl --since {log_time} -u {service} | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertTrue(result.returncode, f"There is an error message for the log of {service}") + # test_reload + self.cmd(f'systemctl start {service}') + command = f'systemctl cat {service} | grep -q "ExecReload"' + result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result.returncode: + code, result = self.cmd(f'systemctl reload {service}') + self.assertFalse(code, f"reload unit {service} failed") + else: + code, result = self.cmd(f'systemctl reload {service} 2>&1 | grep "Job type reload is not applicable"') + self.assertFalse(code, f"Job type reload is not applicable for unit {service}") + code, result = self.cmd(f'systemctl status {service} | grep "Active: active"') + if code: + command = f'systemctl status {service} | grep "inactive (dead)"' + result1 = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if not result1.returncode: + code2, result = self.cmd(f'systemctl status {service} | grep "Condition check" | grep "skip"') + self.assertFalse(code2, f'{service} reload causes the service status to change') + else: + return 1 + + def tearDown(self): + self.cmd(' systemctl stop abrtd.service') + self.cmd('systemctl stop abrtd.service') + self.cmd(' rm -rf /var/crash/test') + super().tearDown(self.PARAM_DIC)