Skip to content

Commit 184bf9b

Browse files
authored
[patch] Mark and temp disable tests that need OCP (#340)
1 parent 0f81ab3 commit 184bf9b

5 files changed

Lines changed: 43 additions & 24 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
cat ${GITHUB_WORKSPACE}/src/mas/devops/__init__.py
4747
python -m pip install --upgrade pip
4848
pip install .[dev]
49-
python -m pytest
49+
python -m pytest -m "not openshift"
5050
5151
- name: Lint with flake8
5252
run: |

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2026-05-21T00:23:08Z",
6+
"generated_at": "2026-05-21T00:57:00Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -178,15 +178,15 @@
178178
"hashed_secret": "94f5ed592906089c107208b29e178ddf1f9f5143",
179179
"is_secret": false,
180180
"is_verified": false,
181-
"line_number": 35,
181+
"line_number": 42,
182182
"type": "Secret Keyword",
183183
"verified_result": null
184184
},
185185
{
186186
"hashed_secret": "a9410d9785f49750b9f8672794fc288558c1611c",
187187
"is_secret": false,
188188
"is_verified": false,
189-
"line_number": 48,
189+
"line_number": 55,
190190
"type": "Secret Keyword",
191191
"verified_result": null
192192
}

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ requires = [
33
"setuptools"
44
]
55
build-backend = "setuptools.build_meta"
6+
7+
[tool.pytest.ini_options]
8+
markers = [
9+
"openshift: marks tests as requiring an OpenShift cluster (deselect with '-m \"not openshift\"')",
10+
]

test/src/test_mas.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@
88
#
99
# *****************************************************************************
1010

11+
import pytest
1112
from openshift import dynamic
1213
from kubernetes import config
1314
from kubernetes.client import api_client
1415
from kubernetes.dynamic.resource import ResourceInstance
1516

1617
from mas.devops import mas
1718

18-
dynClient = dynamic.DynamicClient(
19-
api_client.ApiClient(configuration=config.load_kube_config())
20-
)
19+
pytestmark = pytest.mark.openshift
2120

2221

23-
def test_entitlement():
22+
@pytest.fixture(scope="module")
23+
def dynClient():
24+
"""Create DynamicClient for OpenShift cluster access."""
25+
return dynamic.DynamicClient(
26+
api_client.ApiClient(configuration=config.load_kube_config())
27+
)
28+
29+
30+
def test_entitlement(dynClient):
2431
icrUsername = "testing-i"
2532
icrPassword = "not-a-real-password-i"
2633

@@ -30,7 +37,7 @@ def test_entitlement():
3037
assert secret.metadata.name == "ibm-entitlement"
3138

3239

33-
def test_entitlement_with_artifactory():
40+
def test_entitlement_with_artifactory(dynClient):
3441
artifactoryUsername = "testing-a"
3542
artifactoryPassword = "not-a-real-password-a"
3643

@@ -43,7 +50,7 @@ def test_entitlement_with_artifactory():
4350
assert secret.metadata.name == "ibm-entitlement"
4451

4552

46-
def test_entitlement_alt_name():
53+
def test_entitlement_alt_name(dynClient):
4754
icrUsername = "testing-i"
4855
icrPassword = "not-a-real-password-i"
4956

@@ -53,23 +60,23 @@ def test_entitlement_alt_name():
5360
assert secret.metadata.name == "ibm-entitlement-key"
5461

5562

56-
def test_get_channel():
63+
def test_get_channel(dynClient):
5764
channel = mas.getMasChannel(dynClient, "doesnotexist")
5865
assert channel is None
5966

6067

61-
def test_is_airgap_install():
68+
def test_is_airgap_install(dynClient):
6269
# The cluster we are using to test with does not have the MAS ICSP or IDMS installed
6370
assert mas.isAirgapInstall(dynClient) is False
6471
assert mas.isAirgapInstall(dynClient, checkICSP=False) is False
6572

6673

67-
def test_get_mas_public_cluster_issuer():
74+
def test_get_mas_public_cluster_issuer(dynClient):
6875
# Test with non-existent instance - should return None
6976
issuer = mas.getMasPublicClusterIssuer(dynClient, "doesnotexist")
7077
assert issuer is None
7178

7279

73-
# def test_is_app_ready():
80+
# def test_is_app_ready(dynClient):
7481
# mas.waitForAppReady(dynClient, "fvtcpd", "iot")
7582
# mas.waitForAppReady(dynClient, "fvtcpd", "iot", "masdev")

test/src/test_olm.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,25 @@
88
#
99
# *****************************************************************************
1010

11+
import pytest
1112
from openshift import dynamic
1213
from kubernetes import config
1314
from kubernetes.client import api_client
1415

1516
from mas.devops import olm, ocp
1617

17-
dynClient = dynamic.DynamicClient(
18-
api_client.ApiClient(configuration=config.load_kube_config())
19-
)
18+
pytestmark = pytest.mark.openshift
2019

2120

22-
def test_get_manifest():
21+
@pytest.fixture(scope="module")
22+
def dynClient():
23+
"""Create DynamicClient for OpenShift cluster access."""
24+
return dynamic.DynamicClient(
25+
api_client.ApiClient(configuration=config.load_kube_config())
26+
)
27+
28+
29+
def test_get_manifest(dynClient):
2330
manifest = olm.getPackageManifest(dynClient, "ibm-sls")
2431
assert manifest is not None
2532
assert manifest.metadata.name == "ibm-sls"
@@ -30,12 +37,12 @@ def test_get_manifest():
3037
assert manifest.status.packageName == "ibm-sls"
3138

3239

33-
def test_get_manifest_none():
40+
def test_get_manifest_none(dynClient):
3441
manifest = olm.getPackageManifest(dynClient, "ibm-sls2")
3542
assert manifest is None
3643

3744

38-
def test_crud():
45+
def test_crud(dynClient):
3946
namespace = "cli-fvt-1"
4047
subscription = olm.applySubscription(dynClient, namespace, "ibm-sls", packageChannel="3.x")
4148
assert subscription.metadata.name == "ibm-sls"
@@ -62,7 +69,7 @@ def test_crud():
6269
assert failedSubscriptionLookup2 is None
6370

6471

65-
def test_crud_with_config():
72+
def test_crud_with_config(dynClient):
6673
namespace = "cli-fvt-2"
6774
# We don't need this, just want to test that it works
6875
testConfig = {
@@ -81,7 +88,7 @@ def test_crud_with_config():
8188
ocp.deleteNamespace(dynClient, namespace)
8289

8390

84-
def test_crud_with_manual_approval():
91+
def test_crud_with_manual_approval(dynClient):
8592
"""
8693
Test that when installPlanApproval is Manual without a startingCSV,
8794
an OLMException is raised.
@@ -105,7 +112,7 @@ def test_crud_with_manual_approval():
105112
# Test passed - exception was raised as expected
106113

107114

108-
def test_crud_with_starting_csv():
115+
def test_crud_with_starting_csv(dynClient):
109116
namespace = "cli-fvt-4"
110117
# Note: This test assumes a specific CSV version exists in the catalog
111118
# You may need to adjust the version based on what's available
@@ -127,7 +134,7 @@ def test_crud_with_starting_csv():
127134
ocp.deleteNamespace(dynClient, namespace)
128135

129136

130-
def test_crud_with_manual_approval_and_starting_csv():
137+
def test_crud_with_manual_approval_and_starting_csv(dynClient):
131138
"""
132139
Test that when installPlanApproval is Manual and startingCSV is specified,
133140
the first InstallPlan is automatically approved to reach the startingCSV.

0 commit comments

Comments
 (0)