Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
cat ${GITHUB_WORKSPACE}/src/mas/devops/__init__.py
python -m pip install --upgrade pip
pip install .[dev]
python -m pytest
python -m pytest -m "not openshift"
- name: Lint with flake8
run: |
Expand Down
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2026-05-21T00:23:08Z",
"generated_at": "2026-05-21T00:57:00Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -178,15 +178,15 @@
"hashed_secret": "94f5ed592906089c107208b29e178ddf1f9f5143",
"is_secret": false,
"is_verified": false,
"line_number": 35,
"line_number": 42,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "a9410d9785f49750b9f8672794fc288558c1611c",
"is_secret": false,
"is_verified": false,
"line_number": 48,
"line_number": 55,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ requires = [
"setuptools"
]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
markers = [
"openshift: marks tests as requiring an OpenShift cluster (deselect with '-m \"not openshift\"')",
]
27 changes: 17 additions & 10 deletions test/src/test_mas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@
#
# *****************************************************************************

import pytest
from openshift import dynamic
from kubernetes import config
from kubernetes.client import api_client
from kubernetes.dynamic.resource import ResourceInstance

from mas.devops import mas

dynClient = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
pytestmark = pytest.mark.openshift


def test_entitlement():
@pytest.fixture(scope="module")
def dynClient():
"""Create DynamicClient for OpenShift cluster access."""
return dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)


def test_entitlement(dynClient):
icrUsername = "testing-i"
icrPassword = "not-a-real-password-i"

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


def test_entitlement_with_artifactory():
def test_entitlement_with_artifactory(dynClient):
artifactoryUsername = "testing-a"
artifactoryPassword = "not-a-real-password-a"

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


def test_entitlement_alt_name():
def test_entitlement_alt_name(dynClient):
icrUsername = "testing-i"
icrPassword = "not-a-real-password-i"

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


def test_get_channel():
def test_get_channel(dynClient):
channel = mas.getMasChannel(dynClient, "doesnotexist")
assert channel is None


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


def test_get_mas_public_cluster_issuer():
def test_get_mas_public_cluster_issuer(dynClient):
# Test with non-existent instance - should return None
issuer = mas.getMasPublicClusterIssuer(dynClient, "doesnotexist")
assert issuer is None


# def test_is_app_ready():
# def test_is_app_ready(dynClient):
# mas.waitForAppReady(dynClient, "fvtcpd", "iot")
# mas.waitForAppReady(dynClient, "fvtcpd", "iot", "masdev")
27 changes: 17 additions & 10 deletions test/src/test_olm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@
#
# *****************************************************************************

import pytest
from openshift import dynamic
from kubernetes import config
from kubernetes.client import api_client

from mas.devops import olm, ocp

dynClient = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
pytestmark = pytest.mark.openshift


def test_get_manifest():
@pytest.fixture(scope="module")
def dynClient():
"""Create DynamicClient for OpenShift cluster access."""
return dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)


def test_get_manifest(dynClient):
manifest = olm.getPackageManifest(dynClient, "ibm-sls")
assert manifest is not None
assert manifest.metadata.name == "ibm-sls"
Expand All @@ -30,12 +37,12 @@ def test_get_manifest():
assert manifest.status.packageName == "ibm-sls"


def test_get_manifest_none():
def test_get_manifest_none(dynClient):
manifest = olm.getPackageManifest(dynClient, "ibm-sls2")
assert manifest is None


def test_crud():
def test_crud(dynClient):
namespace = "cli-fvt-1"
subscription = olm.applySubscription(dynClient, namespace, "ibm-sls", packageChannel="3.x")
assert subscription.metadata.name == "ibm-sls"
Expand All @@ -62,7 +69,7 @@ def test_crud():
assert failedSubscriptionLookup2 is None


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


def test_crud_with_manual_approval():
def test_crud_with_manual_approval(dynClient):
"""
Test that when installPlanApproval is Manual without a startingCSV,
an OLMException is raised.
Expand All @@ -105,7 +112,7 @@ def test_crud_with_manual_approval():
# Test passed - exception was raised as expected


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


def test_crud_with_manual_approval_and_starting_csv():
def test_crud_with_manual_approval_and_starting_csv(dynClient):
"""
Test that when installPlanApproval is Manual and startingCSV is specified,
the first InstallPlan is automatically approved to reach the startingCSV.
Expand Down
Loading