From 619369c3ce9d9adb2ff411426aefc874cab3f452 Mon Sep 17 00:00:00 2001 From: selldinesh Date: Fri, 22 Mar 2024 16:30:02 +0000 Subject: [PATCH 1/4] passing non default password from snappi-sonic.yml file --- tests/common/snappi_tests/snappi_fixtures.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/common/snappi_tests/snappi_fixtures.py b/tests/common/snappi_tests/snappi_fixtures.py index 1d3e43a27c0..cccb0b40987 100644 --- a/tests/common/snappi_tests/snappi_fixtures.py +++ b/tests/common/snappi_tests/snappi_fixtures.py @@ -47,26 +47,30 @@ def snappi_api_serv_port(duthosts, rand_one_dut_hostname): @pytest.fixture(scope='module') -def snappi_api(snappi_api_serv_ip, +def snappi_api(duthosts, + rand_one_dut_hostname, + snappi_api_serv_ip, snappi_api_serv_port): """ Fixture for session handle, for creating snappi objects and making API calls. Args: + duthost (pytest fixture): The duthost fixture. snappi_api_serv_ip (pytest fixture): snappi_api_serv_ip fixture snappi_api_serv_port (pytest fixture): snappi_api_serv_port fixture. """ + duthost = duthosts[rand_one_dut_hostname] location = "https://" + snappi_api_serv_ip + ":" + str(snappi_api_serv_port) # TODO: Currently extension is defaulted to ixnetwork. # Going forward, we should be able to specify extension # from command line while running pytest. api = snappi.api(location=location, ext="ixnetwork") - + api._username = duthost.host.options['variable_manager'].\ + _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['user'] + api._password = duthost.host.options['variable_manager'].\ + _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['password'] yield api - if getattr(api, 'assistant', None) is not None: - api.assistant.Session.remove() - def __gen_mac(id): """ From 1f908e204c97815f33c3fcc0b6729a360ad44296 Mon Sep 17 00:00:00 2001 From: selldinesh Date: Fri, 22 Mar 2024 16:32:07 +0000 Subject: [PATCH 2/4] passing non default password from snappi-sonic.yml file --- tests/common/snappi_tests/snappi_fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/common/snappi_tests/snappi_fixtures.py b/tests/common/snappi_tests/snappi_fixtures.py index cccb0b40987..7c06ea2a9d0 100644 --- a/tests/common/snappi_tests/snappi_fixtures.py +++ b/tests/common/snappi_tests/snappi_fixtures.py @@ -48,7 +48,7 @@ def snappi_api_serv_port(duthosts, rand_one_dut_hostname): @pytest.fixture(scope='module') def snappi_api(duthosts, - rand_one_dut_hostname, + rand_one_dut_hostname, snappi_api_serv_ip, snappi_api_serv_port): """ @@ -66,9 +66,9 @@ def snappi_api(duthosts, # from command line while running pytest. api = snappi.api(location=location, ext="ixnetwork") api._username = duthost.host.options['variable_manager'].\ - _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['user'] + _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['user'] api._password = duthost.host.options['variable_manager'].\ - _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['password'] + _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['password'] yield api From 131e81345f0de3865cd3e2be1754c70078caee84 Mon Sep 17 00:00:00 2001 From: selldinesh Date: Fri, 31 May 2024 14:46:13 +0000 Subject: [PATCH 3/4] commenting the username and paswword block --- tests/common/snappi_tests/snappi_fixtures.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/common/snappi_tests/snappi_fixtures.py b/tests/common/snappi_tests/snappi_fixtures.py index 7c06ea2a9d0..84ddca7ebd6 100644 --- a/tests/common/snappi_tests/snappi_fixtures.py +++ b/tests/common/snappi_tests/snappi_fixtures.py @@ -65,12 +65,14 @@ def snappi_api(duthosts, # Going forward, we should be able to specify extension # from command line while running pytest. api = snappi.api(location=location, ext="ixnetwork") - api._username = duthost.host.options['variable_manager'].\ - _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['user'] - api._password = duthost.host.options['variable_manager'].\ - _hostvars[duthost.hostname]['secret_group_vars']['snappi_api_server']['password'] + # TODO - Uncomment to use. Prefer to use environment vars to retrieve this information + # api._username = "" + # api._password = "" yield api + if getattr(api, 'assistant', None) is not None: + api.assistant.Session.remove() + def __gen_mac(id): """ From f4661f77f5e025ec1f6f58867deb842e79e6bf63 Mon Sep 17 00:00:00 2001 From: selldinesh Date: Fri, 31 May 2024 14:53:29 +0000 Subject: [PATCH 4/4] removing duthost --- tests/common/snappi_tests/snappi_fixtures.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/common/snappi_tests/snappi_fixtures.py b/tests/common/snappi_tests/snappi_fixtures.py index 84ddca7ebd6..7c298234191 100644 --- a/tests/common/snappi_tests/snappi_fixtures.py +++ b/tests/common/snappi_tests/snappi_fixtures.py @@ -47,19 +47,15 @@ def snappi_api_serv_port(duthosts, rand_one_dut_hostname): @pytest.fixture(scope='module') -def snappi_api(duthosts, - rand_one_dut_hostname, - snappi_api_serv_ip, +def snappi_api(snappi_api_serv_ip, snappi_api_serv_port): """ Fixture for session handle, for creating snappi objects and making API calls. Args: - duthost (pytest fixture): The duthost fixture. snappi_api_serv_ip (pytest fixture): snappi_api_serv_ip fixture snappi_api_serv_port (pytest fixture): snappi_api_serv_port fixture. """ - duthost = duthosts[rand_one_dut_hostname] location = "https://" + snappi_api_serv_ip + ":" + str(snappi_api_serv_port) # TODO: Currently extension is defaulted to ixnetwork. # Going forward, we should be able to specify extension