From fb4dfe98c7299c77fee8724f312430a71406ff92 Mon Sep 17 00:00:00 2001 From: jitendracandela <78074038+jitendracandela@users.noreply.github.com> Date: Wed, 5 Oct 2022 01:47:59 +0530 Subject: [PATCH] Wifi 10974 (#707) * Added pytest fail if config exception happening Signed-off-by: jitendracandela * Added get_lf_logs Signed-off-by: jitendracandela * Modified error message and added get_lf_logs Signed-off-by: jitendracandela * Removed get_lf_logs Signed-off-by: jitendracandela * Added get_lf_logs Signed-off-by: jitendracandela * Removed get_lf_logs Signed-off-by: jitendracandela * Added retry logic in config push and Added teardown lf logs if config push failing Signed-off-by: jitendracandela * Adjusted teardown logic for collect_logs_lf Signed-off-by: jitendracandela * Added sleep Signed-off-by: jitendracandela Signed-off-by: jitendracandela --- libs/lanforge/lf_tools.py | 1 + .../dfs_80MHz/test_dfs_80_bridge.py | 6 +-- .../vlan_mode/fiveg_radio/test_vlan_fiveg.py | 12 +++--- .../vlan_mode/twog_radio/test_vlan_twog.py | 12 +++--- tests/fixtures_2x.py | 41 +++++++++++++++++-- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/libs/lanforge/lf_tools.py b/libs/lanforge/lf_tools.py index e1b5a86da..5d25bd500 100755 --- a/libs/lanforge/lf_tools.py +++ b/libs/lanforge/lf_tools.py @@ -313,6 +313,7 @@ class ChamberView: time.sleep(2) self.CreateChamberview.show_text_blob(None, None, True) # Show changes on GUI self.CreateChamberview.sync_cv() + time.sleep(5) return self.CreateChamberview, self.scenario_name def add_vlan(self, vlan_ids=[]): diff --git a/tests/e2e/basic/dfs_test/wpa2_personal/dfs_80MHz/test_dfs_80_bridge.py b/tests/e2e/basic/dfs_test/wpa2_personal/dfs_80MHz/test_dfs_80_bridge.py index 957e053fe..876a88bb5 100644 --- a/tests/e2e/basic/dfs_test/wpa2_personal/dfs_80MHz/test_dfs_80_bridge.py +++ b/tests/e2e/basic/dfs_test/wpa2_personal/dfs_80MHz/test_dfs_80_bridge.py @@ -42,7 +42,7 @@ class TestDFSChannel52Bw80(object): @pytest.mark.wpa2_personal @pytest.mark.fiveg @pytest.mark.dfs_channel_52_bw_80 - def test_dfs_channel_52_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start): + def test_dfs_channel_52_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start, get_lf_logs): lf_tools.reset_scenario() profile_data = setup_params_general1["ssid_modes"]["wpa2_personal"][0] ssid_name = profile_data["ssid_name"] @@ -130,7 +130,7 @@ class TestDFSChannel100Bw80(object): @pytest.mark.wpa2_personal @pytest.mark.fiveg @pytest.mark.dfs_channel_100_bw_80 - def test_dfs_channel_100_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start): + def test_dfs_channel_100_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start, get_lf_logs): lf_tools.reset_scenario() profile_data = setup_params_general2["ssid_modes"]["wpa2_personal"][0] ssid_name = profile_data["ssid_name"] @@ -810,7 +810,7 @@ class TestDFSChannel132Bw80(object): @pytest.mark.wpa2_personal @pytest.mark.fiveg @pytest.mark.dfs_channel_132_bw_80 - def test_dfs_channel_132_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start): + def test_dfs_channel_132_bw_80(self, get_ap_logs, lf_test, lf_tools, station_names_fiveg, dfs_start, get_lf_logs): lf_tools.reset_scenario() profile_data = setup_params_general11["ssid_modes"]["wpa2_personal"][0] ssid_name = profile_data["ssid_name"] diff --git a/tests/e2e/basic/validation_of_operating_modes/vlan_mode/fiveg_radio/test_vlan_fiveg.py b/tests/e2e/basic/validation_of_operating_modes/vlan_mode/fiveg_radio/test_vlan_fiveg.py index 7843b9816..c08bcb4a7 100644 --- a/tests/e2e/basic/validation_of_operating_modes/vlan_mode/fiveg_radio/test_vlan_fiveg.py +++ b/tests/e2e/basic/validation_of_operating_modes/vlan_mode/fiveg_radio/test_vlan_fiveg.py @@ -50,7 +50,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2169") def test_station_ip_wpa_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa, fiveg pytest -m valid_client_ip_wpa_fiveg @@ -107,7 +107,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2157") def test_station_ip_wpa2_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa2, fiveg pytest -m valid_client_ip_wpa2_fiveg @@ -156,7 +156,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2174") def test_disable_vlan_wpa2_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration): + test_cases, get_configuration, get_lf_logs): """ Client connectivity using vlan, wpa2, fiveg pytest -m disable_vlan_fiveg @@ -214,7 +214,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2161") def test_station_ip_open_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, open, fiveg pytest -m valid_client_ip_open_fiveg @@ -269,7 +269,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2167") def test_station_ip_wpa_wpa2_personal_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa, wpa2, fiveg pytest -m test_station_ip_wpa_wpa2_ssid_5g @@ -326,7 +326,7 @@ class TestVlanConfigFivegRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2172") def test_enable_vlan_wpa2_ssid_5g(self, lf_test, lf_tools, station_names_fiveg, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa2, fiveg pytest -m enable_vlan_fiveg diff --git a/tests/e2e/basic/validation_of_operating_modes/vlan_mode/twog_radio/test_vlan_twog.py b/tests/e2e/basic/validation_of_operating_modes/vlan_mode/twog_radio/test_vlan_twog.py index 5d6a33d6e..f8f8a50b8 100644 --- a/tests/e2e/basic/validation_of_operating_modes/vlan_mode/twog_radio/test_vlan_twog.py +++ b/tests/e2e/basic/validation_of_operating_modes/vlan_mode/twog_radio/test_vlan_twog.py @@ -47,7 +47,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2168") def test_station_ip_wpa_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa, twog pytest -m valid_client_ip_twog_wpa @@ -101,7 +101,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2156") def test_station_ip_wpa2_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa2, twog pytest -m valid_client_ip_twog_wpa2 @@ -148,7 +148,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2158") def test_disable_vlan_wpa2_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa2, twog pytest -m disable_vlan_twog @@ -206,7 +206,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2160") def test_station_ip_open_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, open, twog pytest -m valid_client_ip_twog_open @@ -261,7 +261,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2166") def test_station_ip_wpa_wpa2_personal_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa, wpa2, twog pytest -m test_station_ip_twog_wpa_wpa2 @@ -318,7 +318,7 @@ class TestVlanConfigTwogRadio(object): url="https://telecominfraproject.atlassian.net/browse/WIFI-2172") def test_enable_vlan_wpa2_ssid_2g(self, lf_test, lf_tools, station_names_twog, - test_cases, get_configuration, get_ap_logs): + test_cases, get_configuration, get_ap_logs, get_lf_logs): """ Client connectivity using vlan, wpa2, twog pytest -m enable_vlan_twog diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index 4459fc472..f31250b86 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -39,6 +39,7 @@ from controller.controller_2x.controller import ProvUtils from configuration import CONFIGURATION from configuration import RADIUS_SERVER_DATA from configuration import RADIUS_ACCOUNTING_DATA +from lanforge.scp_util import SCP_File class Fixtures_2x: @@ -701,7 +702,7 @@ class Fixtures_2x: allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) time_1 = time.time() - + push_config_exception_variable = False # Apply config try: ap_logs = ap_ssh.get_logread() @@ -711,9 +712,22 @@ class Fixtures_2x: #print(instantiate_profile_obj.base_profile_config) except Exception as e: ap_logs = ap_ssh.get_logread() - allure.attach(body=ap_logs, name="Failure while pushing- AP Logs: ") - allure.attach(body=str(e), name="Exception data after config push: ") + allure.attach(body=ap_logs, name="1st time Failure while pushing- AP Logs: ") + allure.attach(body=str(e), name="1st time Exception data after config push: ") print(e) + time.sleep(30) + print("Second time applying config") + try: + instantiate_profile_obj.push_config(serial_number=get_equipment_ref[0]) + except Exception as e: + push_config_exception_variable = True + ap_logs = ap_ssh.get_logread() + allure.attach(body=ap_logs, name="2nd time Failure while pushing- AP Logs: ") + allure.attach(body=str(e), name="2nd time Exception data after config push: ") + print(e) + + + config = json.loads(str(instantiate_profile_obj.base_profile_config).replace(" ", "").replace("'", '"').replace("True", "true")) @@ -852,6 +866,27 @@ class Fixtures_2x: print("\nTeardown") request.addfinalizer(teardown_session) + + def collect_logs_lf(): + ip = get_configuration["traffic_generator"]["details"]["ip"] + port = get_configuration["traffic_generator"]["details"]["ssh_port"] + log_0 = "/home/lanforge/lanforge_log_0.txt" + log_1 = "/home/lanforge/lanforge_log_1.txt" + obj = SCP_File(ip=ip, port=port, username="root", password="lanforge", remote_path=log_0, + local_path=".") + obj.pull_file() + allure.attach.file(source="lanforge_log_0.txt", + name="lanforge_log_0") + obj = SCP_File(ip=ip, port=port, username="root", password="lanforge", remote_path=log_1, + local_path=".") + obj.pull_file() + allure.attach.file(source="lanforge_log_1.txt", + name="lanforge_log_1") + + request.addfinalizer(collect_logs_lf) + if push_config_exception_variable: + pytest.fail("Command Timed Out") + return test_cases def setup_mesh_profile(self, request, param, get_apnos, get_configuration, setup_controller, instantiate_profile,