Skip to content

Commit

Permalink
pin integration test dependencies, refactor constants in tests for ma…
Browse files Browse the repository at this point in the history
…in (#146)

Pins dependencies in the integration tests to their corresponding channels for this development branch.

Ref: canonical/bundle-kubeflow#866
  • Loading branch information
ca-scribner authored Apr 15, 2024
1 parent 7f7e82f commit 535eaf8
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@

METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
APP_NAME = METADATA["name"]
PREVIOUS_RELEASE = "ckf-1.8/stable"
PREVIOUS_RELEASE_TRUST = True
OIDC_CONFIG = {
"client-name": "Ambassador Auth OIDC",
"client-secret": "oidc-client-secret",
}

ISTIO_PILOT = "istio-pilot"
ISTIO_PILOT_CHANNEL = "latest/edge"
ISTIO_PILOT_TRUST = True

DEX_AUTH = "dex-auth"
DEX_AUTH_CHANNEL = "latest/edge"
DEX_AUTH_TRUST = True
PUBLIC_URL = "test-url"

image_path = METADATA["resources"]["oci-image"]["upstream-source"]
RESOURCES = {"oci-image": image_path}

Expand All @@ -37,7 +46,10 @@ async def test_deploy(self, ops_test: OpsTest):
Assert on the unit status.
"""
await ops_test.model.deploy(
pytest.charm_under_test, resources=RESOURCES, trust=True, config=OIDC_CONFIG
pytest.charm_under_test,
resources=RESOURCES,
trust=True,
config=OIDC_CONFIG,
)

await ops_test.model.applications[APP_NAME].set_config({"public-url": PUBLIC_URL})
Expand All @@ -49,8 +61,12 @@ async def test_deploy(self, ops_test: OpsTest):

@pytest.mark.abort_on_fail
async def test_relations(self, ops_test: OpsTest):
await ops_test.model.deploy(ISTIO_PILOT, channel="1.16/stable", trust=True)
await ops_test.model.deploy(DEX_AUTH, channel="2.31/stable", trust=True)
await ops_test.model.deploy(
ISTIO_PILOT,
channel=ISTIO_PILOT_CHANNEL,
trust=ISTIO_PILOT_TRUST,
)
await ops_test.model.deploy(DEX_AUTH, channel=DEX_AUTH_CHANNEL, trust=DEX_AUTH_TRUST)
await ops_test.model.add_relation(ISTIO_PILOT, DEX_AUTH)
await ops_test.model.add_relation(f"{ISTIO_PILOT}:ingress", f"{APP_NAME}:ingress")
await ops_test.model.add_relation(
Expand Down Expand Up @@ -80,15 +96,18 @@ async def test_remove_application(self, ops_test: OpsTest):
async def test_upgrade(self, ops_test: OpsTest):
"""Test that charm can be upgraded from podspec to sidecar.
For this test we use 1.7/stable channel as the source for podspec charm.
For this test we use APP_PREV_VERSION channel as the source for podspec charm.
Note: juju has a bug due to which you have to first scale podspec charm to 0,
then refresh, then scale up newly deployed app.
See https://github.com/juju/juju/pull/15701 for more info.
"""
print(f"Deploy {APP_NAME} from stable channel")
await ops_test.model.deploy(
APP_NAME, channel="ckf-1.7/stable", trust=True, config=OIDC_CONFIG
APP_NAME,
channel=PREVIOUS_RELEASE,
trust=PREVIOUS_RELEASE_TRUST,
config=OIDC_CONFIG,
)
await ops_test.model.add_relation(f"{ISTIO_PILOT}:ingress", f"{APP_NAME}:ingress")
await ops_test.model.add_relation(
Expand Down

0 comments on commit 535eaf8

Please sign in to comment.