Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

networking tests: fix ssh auth, clean up code #1060

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion harvester_e2e_tests/fixtures/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions harvester_e2e_tests/fixtures/networks.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 2 additions & 9 deletions harvester_e2e_tests/integration/test_0_storage_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]


Expand Down Expand Up @@ -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
Expand Down
17 changes: 1 addition & 16 deletions harvester_e2e_tests/integration/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

pytest_plugins = [
"harvester_e2e_tests.fixtures.api_client",
"harvester_e2e_tests.fixtures.networks",
"harvester_e2e_tests.fixtures.virtualmachines"
]

Expand Down Expand Up @@ -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()
Expand Down
17 changes: 1 addition & 16 deletions harvester_e2e_tests/integration/test_vm_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading