From 29e4dd3faa4f4c8f4131997d86583b066af0c16e Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 17:18:33 +0530 Subject: [PATCH 1/8] Added ifconfig, ip route show and ip addr show command funcs in APnos lib Signed-off-by: haricharan-jaka --- libs/apnos/apnos.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/libs/apnos/apnos.py b/libs/apnos/apnos.py index c521cbe430f..6f2d4900af9 100644 --- a/libs/apnos/apnos.py +++ b/libs/apnos/apnos.py @@ -687,6 +687,41 @@ def dfs_logread(self): logs = "" return logs + def get_ifconfig(self): + client = self.ssh_cli_connect() + cmd = "ifconfig" + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') + o = output + client.close() + return o + + def get_ip_route(self): + client = self.ssh_cli_connect() + cmd = "ip route show" + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') + o = output + client.close() + return o + + def get_ip_addr(self): + client = self.ssh_cli_connect() + cmd = "ip addr show" + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') + o = output + client.close() + return o if __name__ == '__main__': obj = { From 01d6f25e370d27459182eb7ad6b4c8d4b05389e7 Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 17:19:57 +0530 Subject: [PATCH 2/8] Added ifconfig, ip route show and ip addr show commands output to allure before and after config apply Signed-off-by: haricharan-jaka --- tests/fixtures_2x.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index 86df02a42e1..3ed1d81d70a 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -701,6 +701,14 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen output = ap_ssh.get_memory_profile() allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) + #Adding Ifconfig, ip route show and ip addr show commands info before applying config + output = ap_ssh.get_ifconfig() + allure.attach(name="ifconfig before config apply", body=str(output)) + output = ap_ssh.get_ip_route() + allure.attach(name="ip route show before config apply", body=str(output)) + output = ap_ssh.get_ip_addr() + allure.attach(name="ip addr show before config apply", body=str(output)) + time_1 = time.time() # Apply config @@ -833,6 +841,13 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen # Adding memory Profile code after applying config output = ap_ssh.get_memory_profile() allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) + # Adding Ifconfig, ip route show and ip addr show commands info after applying config + output = ap_ssh.get_ifconfig() + allure.attach(name="ifconfig after config apply", body=str(output)) + output = ap_ssh.get_ip_route() + allure.attach(name="ip route show after config apply", body=str(output)) + output = ap_ssh.get_ip_addr() + allure.attach(name="ip addr show after config apply", body=str(output)) def teardown_session(): wifi_status = ap_ssh.get_wifi_status() From a056b9f6b27324aba6df96e025d89b38925451fb Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 17:21:04 +0530 Subject: [PATCH 3/8] Added ifconfig, ip route show and ip addr show commands output to allure in get_ap_logs at teardown phase Signed-off-by: haricharan-jaka --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 8f9ec4b0af2..2dfe965ae2f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -891,6 +891,13 @@ def collect_logs(): # Adding memory Profile code after every test completion output = ap_ssh.get_memory_profile() allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) + # Adding Ifconfig, ip route show and ip addr show commands info after every test completion + output = ap_ssh.get_ifconfig() + allure.attach(name="ifconfig after testcase completion", body=str(output)) + output = ap_ssh.get_ip_route() + allure.attach(name="ip route show after testcase completion", body=str(output)) + output = ap_ssh.get_ip_addr() + allure.attach(name="ip addr show after testcase completion", body=str(output)) request.addfinalizer(collect_logs) From ad408feab70f8b06d0bd1e619e5cf7443a6053a0 Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 22:15:51 +0530 Subject: [PATCH 4/8] removed ifconfig, ip route show and ip addr show command funcs in APnos lib Signed-off-by: haricharan-jaka --- libs/apnos/apnos.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/libs/apnos/apnos.py b/libs/apnos/apnos.py index 6f2d4900af9..c521cbe430f 100644 --- a/libs/apnos/apnos.py +++ b/libs/apnos/apnos.py @@ -687,41 +687,6 @@ def dfs_logread(self): logs = "" return logs - def get_ifconfig(self): - client = self.ssh_cli_connect() - cmd = "ifconfig" - if self.mode: - cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ - f"cmd --value \"{cmd}\" " - stdin, stdout, stderr = client.exec_command(cmd) - output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') - o = output - client.close() - return o - - def get_ip_route(self): - client = self.ssh_cli_connect() - cmd = "ip route show" - if self.mode: - cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ - f"cmd --value \"{cmd}\" " - stdin, stdout, stderr = client.exec_command(cmd) - output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') - o = output - client.close() - return o - - def get_ip_addr(self): - client = self.ssh_cli_connect() - cmd = "ip addr show" - if self.mode: - cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ - f"cmd --value \"{cmd}\" " - stdin, stdout, stderr = client.exec_command(cmd) - output = stdout.read().replace(b":~# ifconfig", b"").decode('utf-8') - o = output - client.close() - return o if __name__ == '__main__': obj = { From 543b30d394690b7b9868feb6fe6b84d44dff031d Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 22:17:52 +0530 Subject: [PATCH 5/8] Using run_generic_command for all the command output Signed-off-by: haricharan-jaka --- tests/fixtures_2x.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index 3ed1d81d70a..067e5815cca 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -702,12 +702,12 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) #Adding Ifconfig, ip route show and ip addr show commands info before applying config - output = ap_ssh.get_ifconfig() - allure.attach(name="ifconfig before config apply", body=str(output)) - output = ap_ssh.get_ip_route() - allure.attach(name="ip route show before config apply", body=str(output)) - output = ap_ssh.get_ip_addr() - allure.attach(name="ip addr show before config apply", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ifconfig") + allure.attach(name="ifconfig after testcase completion", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ip route show") + allure.attach(name="ip route show after testcase completion", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ip addr show") + allure.attach(name="ip addr show after testcase completion", body=str(output)) time_1 = time.time() @@ -842,12 +842,12 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen output = ap_ssh.get_memory_profile() allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) # Adding Ifconfig, ip route show and ip addr show commands info after applying config - output = ap_ssh.get_ifconfig() - allure.attach(name="ifconfig after config apply", body=str(output)) - output = ap_ssh.get_ip_route() - allure.attach(name="ip route show after config apply", body=str(output)) - output = ap_ssh.get_ip_addr() - allure.attach(name="ip addr show after config apply", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ifconfig") + allure.attach(name="ifconfig after testcase completion", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ip route show") + allure.attach(name="ip route show after testcase completion", body=str(output)) + output = ap_ssh.run_generic_command(cmd="ip addr show") + allure.attach(name="ip addr show after testcase completion", body=str(output)) def teardown_session(): wifi_status = ap_ssh.get_wifi_status() From c75d55aec0da770acee5a8eaff6a4dba3e5d0b16 Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 22:18:23 +0530 Subject: [PATCH 6/8] Using run_generic_command for all the command output in conftest also Signed-off-by: haricharan-jaka --- tests/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2dfe965ae2f..18234a3c08e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -892,11 +892,11 @@ def collect_logs(): output = ap_ssh.get_memory_profile() allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) # Adding Ifconfig, ip route show and ip addr show commands info after every test completion - output = ap_ssh.get_ifconfig() + output = ap_ssh.run_generic_command(cmd="ifconfig") allure.attach(name="ifconfig after testcase completion", body=str(output)) - output = ap_ssh.get_ip_route() + output = ap_ssh.run_generic_command(cmd="ip route show") allure.attach(name="ip route show after testcase completion", body=str(output)) - output = ap_ssh.get_ip_addr() + output = ap_ssh.run_generic_command(cmd="ip addr show") allure.attach(name="ip addr show after testcase completion", body=str(output)) request.addfinalizer(collect_logs) From 2fd52f66efa9c7441e52489516a5fd71cb4a5e47 Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Tue, 19 Jul 2022 22:49:31 +0530 Subject: [PATCH 7/8] changed the allure attachment names in fixtures.py file Signed-off-by: haricharan-jaka --- tests/fixtures_2x.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index 067e5815cca..e840ee5e64a 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -703,11 +703,11 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen #Adding Ifconfig, ip route show and ip addr show commands info before applying config output = ap_ssh.run_generic_command(cmd="ifconfig") - allure.attach(name="ifconfig after testcase completion", body=str(output)) + allure.attach(name="ifconfig before applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip route show") - allure.attach(name="ip route show after testcase completion", body=str(output)) + allure.attach(name="ip route show before applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip addr show") - allure.attach(name="ip addr show after testcase completion", body=str(output)) + allure.attach(name="ip addr show before applying config", body=str(output)) time_1 = time.time() @@ -843,11 +843,11 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) # Adding Ifconfig, ip route show and ip addr show commands info after applying config output = ap_ssh.run_generic_command(cmd="ifconfig") - allure.attach(name="ifconfig after testcase completion", body=str(output)) + allure.attach(name="ifconfig after applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip route show") - allure.attach(name="ip route show after testcase completion", body=str(output)) + allure.attach(name="ip route show after applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip addr show") - allure.attach(name="ip addr show after testcase completion", body=str(output)) + allure.attach(name="ip addr show after applying config", body=str(output)) def teardown_session(): wifi_status = ap_ssh.get_wifi_status() From ae407107aacf9e424f0589869233e78c59a04008 Mon Sep 17 00:00:00 2001 From: haricharan-jaka Date: Fri, 22 Jul 2022 13:22:40 +0530 Subject: [PATCH 8/8] Added newline in ifconfig output Signed-off-by: haricharan-jaka --- tests/conftest.py | 10 +++++++--- tests/fixtures_2x.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 18234a3c08e..6449f6426ac 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ Pytest fixtures: High level Resource Management and base setup fixtures """ import datetime +import json import os import random import string @@ -893,11 +894,14 @@ def collect_logs(): allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) # Adding Ifconfig, ip route show and ip addr show commands info after every test completion output = ap_ssh.run_generic_command(cmd="ifconfig") - allure.attach(name="ifconfig after testcase completion", body=str(output)) + output = '\n'.join(output) + allure.attach(name="ifconfig after every test completion", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip route show") - allure.attach(name="ip route show after testcase completion", body=str(output)) + output = '\n'.join(output) + allure.attach(name="ip route show after every test completion", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip addr show") - allure.attach(name="ip addr show after testcase completion", body=str(output)) + output = '\n'.join(output) + allure.attach(name="ip addr show after every test completion", body=str(output)) request.addfinalizer(collect_logs) diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index e840ee5e64a..78620601c18 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -703,10 +703,13 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen #Adding Ifconfig, ip route show and ip addr show commands info before applying config output = ap_ssh.run_generic_command(cmd="ifconfig") + output = '\n'.join(output) allure.attach(name="ifconfig before applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip route show") + output = '\n'.join(output) allure.attach(name="ip route show before applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip addr show") + output = '\n'.join(output) allure.attach(name="ip addr show before applying config", body=str(output)) time_1 = time.time() @@ -843,10 +846,13 @@ def setup_profiles(self, request, param, setup_controller, testbed, get_equipmen allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) # Adding Ifconfig, ip route show and ip addr show commands info after applying config output = ap_ssh.run_generic_command(cmd="ifconfig") + output = '\n'.join(output) allure.attach(name="ifconfig after applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip route show") + output = '\n'.join(output) allure.attach(name="ip route show after applying config", body=str(output)) output = ap_ssh.run_generic_command(cmd="ip addr show") + output = '\n'.join(output) allure.attach(name="ip addr show after applying config", body=str(output)) def teardown_session():