Skip to content

Commit

Permalink
Test Information
Browse files Browse the repository at this point in the history
Annotate the test information with Rancher/RKE version information. This
helps the test report HTML files to be less ambiguous about the
configuration under test.

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
  • Loading branch information
m-ildefons authored and lanfon72 committed Oct 22, 2024
1 parent 8c3edca commit 2448a02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions apiclient/rancher_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def cluster_version(self):
ver = data['value']
# XXX: fix master-xxx-head to 8.8.8, need the API fix the problem
self._version = parse_version('8.8.8' if 'master' in ver else ver)

self._version.raw = ver
return self._version

def __repr__(self):
Expand Down
23 changes: 16 additions & 7 deletions harvester_e2e_tests/fixtures/rancher_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@pytest.fixture(scope="session")
def rancher_api_client(request):
def rancher_api_client(request, harvester_metadata):
endpoint = request.config.getoption("--rancher-endpoint")
password = request.config.getoption("--rancher-admin-password")
ssl_verify = request.config.getoption("--ssl_verify", False)
Expand All @@ -17,6 +17,9 @@ def rancher_api_client(request):

api.session.verify = ssl_verify

harvester_metadata['Rancher Endpoint'] = endpoint
harvester_metadata['Rancher Version'] = api.cluster_version.raw

return api


Expand All @@ -42,34 +45,40 @@ def _pickup_k8s_version(versions, target_version):


@pytest.fixture(scope='session')
def rke1_version(request, rancher_api_client):
def rke1_version(request, rancher_api_client, harvester_metadata):
target_ver = request.config.getoption("--k8s-version")

code, data = rancher_api_client.settings.get("k8s-versions-current")
assert 200 == code, (code, data)
supported_vers = data["value"].split(",")

return _pickup_k8s_version(supported_vers, target_ver)
ver = _pickup_k8s_version(supported_vers, target_ver)
harvester_metadata['RKE1 Version'] = ver
return ver


@pytest.fixture(scope="session")
def rke2_version(request, api_client, rancher_api_client):
def rke2_version(request, rancher_api_client, harvester_metadata):
target_ver = request.config.getoption("--k8s-version")

# Ref. https://github.com/rancher/dashboard/blob/master/shell/edit/provisioning.cattle.io.cluster/rke2.vue # noqa
resp = rancher_api_client._get("v1-rke2-release/releases")
assert resp.ok
supported_vers = [r['id'] for r in resp.json()['data']]

return _pickup_k8s_version(supported_vers, target_ver)
ver = _pickup_k8s_version(supported_vers, target_ver)
harvester_metadata['RKE2 Version'] = ver
return ver


@pytest.fixture(scope="session")
def k3s_version(request, api_client, rancher_api_client):
def k3s_version(request, rancher_api_client, harvester_metadata):
target_ver = request.config.getoption("--k8s-version")

resp = rancher_api_client._get("v1-k3s-release/releases")
assert resp.ok
supported_vers = [r['id'] for r in resp.json()['data']]

return _pickup_k8s_version(supported_vers, target_ver)
ver = _pickup_k8s_version(supported_vers, target_ver)
harvester_metadata['K3S Version'] = ver
return ver

0 comments on commit 2448a02

Please sign in to comment.