diff --git a/apiclient/rancher_api/api.py b/apiclient/rancher_api/api.py index 489ed2457..da36de401 100644 --- a/apiclient/rancher_api/api.py +++ b/apiclient/rancher_api/api.py @@ -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): 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