-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from openshift-kni/left-shift-telco-hub
Dockerfile and test for Hub cluster part
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM registry.ci.openshift.org/ci/telco-runner | ||
|
||
RUN pip3 install --no-cache-dir "pytest==8.2.2" "pytest-shell==0.3.2" "requests==2.32.3" |
45 changes: 45 additions & 0 deletions
45
tests/pytest/ztp-left-shifting/sno-hub/check-hub-installation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import time | ||
import requests | ||
import pytest | ||
|
||
kubeconfig = os.getenv("KUBECONFIG") | ||
ocp_hub_version = os.getenv("OCP_HUB_VERSION") | ||
mch_ns = os.getenv("MCH_NAMESPACE") | ||
|
||
@pytest.mark.parametrize("endpoint", [ | ||
{"cmd": f"oc --kubeconfig {kubeconfig} whoami --show-console", "response": 200}, | ||
{"cmd": f"oc --kubeconfig {kubeconfig} get managedcluster local-cluster -ojsonpath='{{.spec.managedClusterClientConfigs[0].url}}'", "response": 403}, | ||
]) | ||
def test_http_endpoint(bash, endpoint): | ||
if "url" in endpoint: | ||
url = endpoint.url | ||
else: | ||
oc_cmd = endpoint['cmd'] | ||
url = bash.run_script_inline([oc_cmd]) | ||
response = requests.get(url, verify=False) | ||
assert response.status_code == endpoint["response"], f"Endpoint {url} is not accessible. Status code: {response.status_code}" | ||
|
||
def test_cluster_version(bash): | ||
oc_cmd = "oc get clusterversion version -ojsonpath='{.status.desired.version}'" | ||
assert bash.run_script_inline([oc_cmd]).startswith(f"{ocp_hub_version}") | ||
|
||
@pytest.mark.parametrize("namespace", [ | ||
"openshift-local-storage", | ||
f"{mch_ns}", | ||
"multicluster-engine", | ||
"openshift-gitops", | ||
]) | ||
def test_ztp_namespaces(bash, namespace): | ||
oc_cmd = f"oc get ns {namespace} " + "-ojsonpath='{.metadata.name}'" | ||
assert bash.run_script_inline([oc_cmd]) == namespace | ||
|
||
count = 0 | ||
attempts = 10 | ||
while attempts > 0: | ||
oc_cmd = f"oc -n {namespace} get po --no-headers | grep -v -E 'Running|Completed' | wc -l" | ||
if bash.run_script_inline([oc_cmd]) == '0': | ||
break | ||
attempts -= 1 | ||
time.sleep(60) | ||
assert attempts > 0, f"Not all PODs in {namespace} namespace are ready yet" |