diff --git a/harvester_e2e_tests/fixtures/api_client.py b/harvester_e2e_tests/fixtures/api_client.py index 9f9d55327..a4c05eba9 100644 --- a/harvester_e2e_tests/fixtures/api_client.py +++ b/harvester_e2e_tests/fixtures/api_client.py @@ -214,12 +214,21 @@ def reconnect(self, ipaddr, port=22, **kwargs): kws.update(kwargs) cli.connect(ipaddr, port, **kws) - def login(self, ipaddr, port=22, jumphost=False, **kwargs): + def login(self, ipaddr, port=22, jumphost=False, allow_agent=False, + look_for_keys=False, **kwargs): if not self.client: cli = SSHClient() cli.set_missing_host_key_policy(MissingHostKeyPolicy()) kws = dict(username=self.username, password=self.password, pkey=self.pkey) kws.update(kwargs) + + # in case we're using a password to log into the host, this + # prevents paramiko from getting confused by ssh keys in the ssh + # agent: + if self.password and not self.pkey: + kws.update(dict(allow_agent=allow_agent, + look_for_keys=look_for_keys)) + cli.connect(ipaddr, port, **kws) self._client = cli diff --git a/harvester_e2e_tests/fixtures/networks.py b/harvester_e2e_tests/fixtures/networks.py new file mode 100644 index 000000000..5d25b4eb1 --- /dev/null +++ b/harvester_e2e_tests/fixtures/networks.py @@ -0,0 +1,15 @@ +import pytest + + +@pytest.fixture(scope="session") +def vlan_id(request): + vlan_id = request.config.getoption('--vlan-id') + assert 0 < vlan_id < 4095, f"VLAN ID should be in range 1-4094, not {vlan_id}" + return vlan_id + + +@pytest.fixture(scope="session") +def vlan_nic(request): + vlan_nic = request.config.getoption('--vlan-nic') + assert vlan_nic, f"VLAN NIC {vlan_nic} not configured correctly." + return vlan_nic diff --git a/harvester_e2e_tests/integration/test_0_storage_network.py b/harvester_e2e_tests/integration/test_0_storage_network.py index c72cea1c7..498221030 100644 --- a/harvester_e2e_tests/integration/test_0_storage_network.py +++ b/harvester_e2e_tests/integration/test_0_storage_network.py @@ -8,7 +8,8 @@ import pytest pytest_plugins = [ - "harvester_e2e_tests.fixtures.api_client" + "harvester_e2e_tests.fixtures.api_client", + "harvester_e2e_tests.fixtures.networks" ] @@ -73,14 +74,6 @@ def cluster_network(request, api_client, unique_name): assert 200 == code, (code, data) -@pytest.fixture(scope='module') -def vlan_id(request): - vlan_id = request.config.getoption('--vlan-id') - assert 4095 > vlan_id > 0, (f"VLAN ID should in range 1-4094, not {vlan_id}") - - return vlan_id - - @pytest.mark.p0 @pytest.mark.settings @pytest.mark.networks diff --git a/harvester_e2e_tests/integration/test_networks.py b/harvester_e2e_tests/integration/test_networks.py index 756fcd602..07ae1f0d5 100644 --- a/harvester_e2e_tests/integration/test_networks.py +++ b/harvester_e2e_tests/integration/test_networks.py @@ -12,6 +12,7 @@ pytest_plugins = [ "harvester_e2e_tests.fixtures.api_client", + "harvester_e2e_tests.fixtures.networks", "harvester_e2e_tests.fixtures.virtualmachines" ] @@ -51,22 +52,6 @@ def client(): client.close() -@pytest.fixture(scope='session') -def vlan_id(request): - vlan_id = request.config.getoption('--vlan-id') - assert 4095 > vlan_id > 0, f"VLAN ID should in range 1-4094, not {vlan_id}" - - return vlan_id - - -@pytest.fixture(scope="session") -def vlan_nic(request): - vlan_nic = request.config.getoption('--vlan-nic') - assert vlan_nic, f"VLAN NIC {vlan_nic} not configured correctly." - - return vlan_nic - - @pytest.fixture(scope='module') def cluster_network(vlan_nic, api_client, unique_name): code, data = api_client.clusternetworks.get_config() diff --git a/harvester_e2e_tests/integration/test_vm_networks.py b/harvester_e2e_tests/integration/test_vm_networks.py index 51144ba0e..44e7da793 100644 --- a/harvester_e2e_tests/integration/test_vm_networks.py +++ b/harvester_e2e_tests/integration/test_vm_networks.py @@ -12,26 +12,11 @@ pytest_plugins = [ "harvester_e2e_tests.fixtures.api_client", "harvester_e2e_tests.fixtures.images", + "harvester_e2e_tests.fixtures.networks", "harvester_e2e_tests.fixtures.virtualmachines" ] -@pytest.fixture(scope='session') -def vlan_id(request): - vlan_id = request.config.getoption('--vlan-id') - assert 4095 > vlan_id > 0, (f"VLAN ID should in range 1-4094, not {vlan_id}") - - return vlan_id - - -@pytest.fixture(scope="session") -def vlan_nic(request): - vlan_nic = request.config.getoption('--vlan-nic') - assert vlan_nic, f"VLAN NIC {vlan_nic} not configured correctly." - - return vlan_nic - - @pytest.fixture(scope="session") def gen_ifconfig(): # eth/eno/ens(idx) | enp(idx)s[0-9]