Skip to content

Commit 09b97a3

Browse files
committed
Update QE tests
1 parent 817d884 commit 09b97a3

4 files changed

+28
-424
lines changed

tests/interop/test_subscription_status_edge.py

-37
This file was deleted.
+7-97
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import difflib
21
import logging
3-
import os
4-
import re
5-
import subprocess
62

73
import pytest
84
from validatedpatterns_tests.interop import subscription
@@ -19,102 +15,16 @@ def test_subscription_status_hub(openshift_dyn_client):
1915
"openshift-gitops-operator": ["openshift-operators"],
2016
"advanced-cluster-management": ["open-cluster-management"],
2117
"multicluster-engine": ["multicluster-engine"],
18+
"openshift-cert-manager-operator": ["cert-manager-operator"],
19+
"sandboxed-containers-operator": ["openshift-sandboxed-containers-operator"],
20+
"trustee-operator": ["trustee-operator-system"],
2221
}
2322

24-
(
25-
operator_versions,
26-
missing_subs,
27-
unhealthy_subs,
28-
missing_installplans,
29-
upgrades_pending,
30-
) = subscription.subscription_status(openshift_dyn_client, expected_subs)
31-
32-
if missing_subs:
33-
logger.error(f"FAIL: The following subscriptions are missing: {missing_subs}")
34-
if unhealthy_subs:
35-
logger.error(
36-
f"FAIL: The following subscriptions are unhealthy: {unhealthy_subs}"
37-
)
38-
if missing_installplans:
39-
logger.error(
40-
f"FAIL: The install plan for the following subscriptions is missing: {missing_installplans}"
41-
)
42-
if upgrades_pending:
43-
logger.error(
44-
f"FAIL: The following subscriptions are in UpgradePending state: {upgrades_pending}"
45-
)
46-
47-
cluster_version = subscription.openshift_version(openshift_dyn_client)
48-
logger.info(f"Openshift version:\n{cluster_version.instance.status.history}")
49-
50-
if os.getenv("EXTERNAL_TEST") != "true":
51-
shortversion = re.sub("(.[0-9]+$)", "", os.getenv("OPENSHIFT_VER"))
52-
currentfile = os.getcwd() + "/operators_hub_current"
53-
sourceFile = open(currentfile, "w")
54-
for line in operator_versions:
55-
logger.info(line)
56-
print(line, file=sourceFile)
57-
sourceFile.close()
58-
59-
logger.info("Clone operator-versions repo")
60-
try:
61-
operator_versions_repo = (
62-
"[email protected]:mpqe/mps/vp/operator-versions.git"
63-
)
64-
clone = subprocess.run(
65-
["git", "clone", operator_versions_repo], capture_output=True, text=True
66-
)
67-
logger.info(clone.stdout)
68-
logger.info(clone.stderr)
69-
except Exception:
70-
pass
71-
72-
previouspath = os.getcwd() + f"/operator-versions/mcgitops_hub_{shortversion}"
73-
previousfile = f"mcgitops_hub_{shortversion}"
74-
75-
logger.info("Ensure previous file exists")
76-
checkpath = os.path.exists(previouspath)
77-
logger.info(checkpath)
78-
79-
if checkpath is True:
80-
logger.info("Diff current operator list with previous file")
81-
diff = opdiff(open(previouspath).readlines(), open(currentfile).readlines())
82-
diffstring = "".join(diff)
83-
logger.info(diffstring)
84-
85-
logger.info("Write diff to file")
86-
sourceFile = open("operator_diffs_hub.log", "w")
87-
print(diffstring, file=sourceFile)
88-
sourceFile.close()
89-
else:
90-
logger.info("Skipping operator diff - previous file not found")
91-
92-
if missing_subs or unhealthy_subs or missing_installplans or upgrades_pending:
93-
err_msg = "Subscription status check failed"
23+
err_msg = subscription.subscription_status(
24+
openshift_dyn_client, expected_subs, diff=True
25+
)
26+
if err_msg:
9427
logger.error(f"FAIL: {err_msg}")
9528
assert False, err_msg
9629
else:
97-
# Only push the new operarator list if the test passed
98-
# and we are not testing a pre-release operator nor
99-
# running externally
100-
if os.getenv("EXTERNAL_TEST") != "true":
101-
if checkpath is True and not os.environ["INDEX_IMAGE"]:
102-
os.remove(previouspath)
103-
os.rename(currentfile, previouspath)
104-
105-
cwd = os.getcwd() + "/operator-versions"
106-
logger.info(f"CWD: {cwd}")
107-
108-
logger.info("Push new operator list")
109-
subprocess.run(["git", "add", previousfile], cwd=cwd)
110-
subprocess.run(
111-
["git", "commit", "-m", "Update operator versions list"],
112-
cwd=cwd,
113-
)
114-
subprocess.run(["git", "push"], cwd=cwd)
115-
11630
logger.info("PASS: Subscription status check passed")
117-
118-
119-
def opdiff(*args):
120-
return filter(lambda x: not x.startswith(" "), difflib.ndiff(*args))

tests/interop/test_validate_edge_site_components.py

-187
This file was deleted.

0 commit comments

Comments
 (0)