From 2ad16a568070ff9a8adf9f05fc38d7bcd1bdd866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20R=C3=B6hrich?= Date: Fri, 13 Sep 2024 15:57:43 +0200 Subject: [PATCH] Test Information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apiclient/rancher_api/api.py | 10 ++++++-- .../fixtures/rancher_api_client.py | 23 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apiclient/rancher_api/api.py b/apiclient/rancher_api/api.py index 489ed2457..2751455fd 100644 --- a/apiclient/rancher_api/api.py +++ b/apiclient/rancher_api/api.py @@ -56,8 +56,14 @@ def cluster_version(self): if not self._version: code, data = self.settings.get('server-version') 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) + + # Rancher versions look like v2.9.2, or v2.9.2-something + parts = ver.split('-') + self._version = parse_version(parts[0]) + if len(parts) > 1: + self._version.suffix = '-'.join(parts[1:]) + # store the raw version string for reference + self._version.raw = ver return self._version def __repr__(self): diff --git a/harvester_e2e_tests/fixtures/rancher_api_client.py b/harvester_e2e_tests/fixtures/rancher_api_client.py index fcc5ff1c9..64a4b03ba 100644 --- a/harvester_e2e_tests/fixtures/rancher_api_client.py +++ b/harvester_e2e_tests/fixtures/rancher_api_client.py @@ -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) @@ -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 @@ -42,18 +45,20 @@ 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 @@ -61,15 +66,19 @@ def rke2_version(request, api_client, rancher_api_client): 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