Skip to content

Commit 9108c04

Browse files
authored
must gather minimal crds test case (#10972)
* add test_must_gather_minimal_crds Signed-off-by: fbalak <[email protected]> * update mg command Signed-off-by: fbalak <[email protected]> * add brown squad marker Signed-off-by: fbalak <[email protected]> * cover all modular parameters Signed-off-by: fbalak <[email protected]> * check minimal_resources path Signed-off-by: fbalak <[email protected]> * incorporate Petr's suggestion Signed-off-by: fbalak <[email protected]> --------- Signed-off-by: fbalak <[email protected]>
1 parent 07623ef commit 9108c04

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed

ocs_ci/ocs/must_gather/const_must_gather.py

+5
Original file line numberDiff line numberDiff line change
@@ -1085,3 +1085,8 @@
10851085
"/noobaa/logs/openshift-storage",
10861086
]
10871087
DR_ONLY = ["/namespaces/openshift-dr-system/"]
1088+
MINIMAL = [
1089+
"/minimal_resources/cluster-scoped-resources/",
1090+
"/minimal_resources/namespaces/",
1091+
"/minimal_resources/oc_output/",
1092+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import logging
2+
import pytest
3+
4+
from ocs_ci.framework.testlib import ManageTest
5+
from ocs_ci.framework.pytest_customization.marks import (
6+
brown_squad,
7+
tier1,
8+
tier2,
9+
skipif_external_mode,
10+
skipif_ms_consumer,
11+
skipif_hci_client,
12+
stretchcluster_required_skipif,
13+
)
14+
from ocs_ci.ocs.must_gather.must_gather import MustGather
15+
from ocs_ci.ocs.must_gather import const_must_gather
16+
17+
logger = logging.getLogger(__name__)
18+
19+
20+
@brown_squad
21+
class TestMustGather(ManageTest):
22+
@pytest.mark.parametrize(
23+
argnames=[
24+
"ceph",
25+
"ceph_logs",
26+
"namespaced",
27+
"clusterscoped",
28+
"noobaa",
29+
"dr",
30+
],
31+
argvalues=[
32+
pytest.param(
33+
*[False, False, False, False, False, False],
34+
marks=[
35+
pytest.mark.polarion_id("OCS-6307"),
36+
skipif_external_mode,
37+
skipif_ms_consumer,
38+
skipif_hci_client,
39+
tier1,
40+
],
41+
),
42+
pytest.param(
43+
*[True, False, False, True, False, False],
44+
marks=[
45+
pytest.mark.polarion_id("OCS-6312"),
46+
skipif_external_mode,
47+
skipif_ms_consumer,
48+
skipif_hci_client,
49+
tier2,
50+
],
51+
),
52+
pytest.param(
53+
*[False, True, False, False, False, False],
54+
marks=[
55+
pytest.mark.polarion_id("OCS-6313"),
56+
skipif_external_mode,
57+
skipif_ms_consumer,
58+
skipif_hci_client,
59+
tier2,
60+
],
61+
),
62+
pytest.param(
63+
*[False, False, True, False, False, False],
64+
marks=[
65+
pytest.mark.polarion_id("OCS-6314"),
66+
skipif_external_mode,
67+
skipif_ms_consumer,
68+
skipif_hci_client,
69+
tier2,
70+
],
71+
),
72+
pytest.param(
73+
*[False, False, False, True, False, False],
74+
marks=[
75+
pytest.mark.polarion_id("OCS-6315"),
76+
skipif_external_mode,
77+
skipif_ms_consumer,
78+
skipif_hci_client,
79+
tier2,
80+
],
81+
),
82+
pytest.param(
83+
*[False, False, False, False, True, False],
84+
marks=[
85+
pytest.mark.polarion_id("OCS-6311"),
86+
skipif_external_mode,
87+
skipif_ms_consumer,
88+
skipif_hci_client,
89+
tier2,
90+
],
91+
),
92+
pytest.param(
93+
*[False, False, False, False, False, True],
94+
marks=[
95+
pytest.mark.polarion_id("OCS-6310"),
96+
skipif_external_mode,
97+
skipif_ms_consumer,
98+
skipif_hci_client,
99+
tier2,
100+
stretchcluster_required_skipif,
101+
],
102+
),
103+
],
104+
)
105+
def test_must_gather_minimal_crd_modular(
106+
self, ceph, ceph_logs, namespaced, clusterscoped, noobaa, dr
107+
):
108+
"""
109+
Tests OCS must gather with --minimal-crd flag and modular flags
110+
111+
Test Process:
112+
1.Collect mg with relevant flags for example
113+
oc adm must-gather --image=quay.io/rhceph-dev/ocs-must-gather:latest-4.15 -- /usr/bin/gather -c -cl -n
114+
2.Calculate the paths that should be included in the ocs mg dir
115+
3.Calculate the paths that should not be included in the ocs mg dir
116+
4.Verify paths exist in must gather directory
117+
5.Verify paths do not exist in must gather directory
118+
"""
119+
120+
flags_cmd = "/usr/bin/gather --minimal "
121+
paths_exist = list()
122+
paths_not_exist = list()
123+
paths_exist += const_must_gather.MINIMAL
124+
125+
options = [
126+
(ceph, const_must_gather.CEPH_ONLY, "-c "),
127+
(ceph_logs, const_must_gather.CEPH_LOGS_ONLY, "-cl "),
128+
(namespaced, const_must_gather.NAMESPACED_ONLY, "-ns "),
129+
(clusterscoped, const_must_gather.CLUSTERSCOPED_ONLY, "-cs "),
130+
(noobaa, const_must_gather.NOOBAA_ONLY, "-n "),
131+
(dr, const_must_gather.DR_ONLY, "-d "),
132+
]
133+
134+
for flag, paths, param_value in options:
135+
if flag:
136+
paths_exist += paths
137+
flags_cmd += param_value
138+
else:
139+
paths_not_exist += paths
140+
mustgather_obj = MustGather()
141+
mustgather_obj.collect_must_gather(ocs_flags=flags_cmd)
142+
mustgather_obj.get_all_paths()
143+
folders_exist = mustgather_obj.verify_paths_in_dir(paths_exist)
144+
folders_not_exist = mustgather_obj.verify_paths_not_in_dir(paths_not_exist)
145+
assert len(folders_not_exist) + len(folders_exist) == 0, (
146+
f"\nMode: {flags_cmd}"
147+
f"\nThe folders don't exist [should exist]: {folders_exist} "
148+
f"\nThe folders exist [should not exist]: {folders_not_exist}"
149+
)

0 commit comments

Comments
 (0)