diff --git a/charms/kfp-api/tests/integration/test_charm.py b/charms/kfp-api/tests/integration/test_charm.py index 81f91300..b39a66dc 100644 --- a/charms/kfp-api/tests/integration/test_charm.py +++ b/charms/kfp-api/tests/integration/test_charm.py @@ -43,7 +43,7 @@ class TestCharm: """Integration test charm""" @pytest.mark.abort_on_fail - async def test_build_and_deploy(self, ops_test: OpsTest): + async def test_build_and_deploy(self, ops_test: OpsTest, request): """Deploy kfp-api with required charms and relations.""" image_path = METADATA["resources"]["oci-image"]["upstream-source"] diff --git a/charms/kfp-metadata-writer/tests/integration/conftest.py b/charms/kfp-metadata-writer/tests/integration/conftest.py new file mode 100644 index 00000000..943b6694 --- /dev/null +++ b/charms/kfp-metadata-writer/tests/integration/conftest.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +from _pytest.config.argparsing import Parser + + +def pytest_addoption(parser: Parser): + parser.addoption( + "--charm-path", + help="Path to charm file when downloaded as artefact as a result of build_charm.yaml" + ) diff --git a/charms/kfp-metadata-writer/tests/integration/test_charm.py b/charms/kfp-metadata-writer/tests/integration/test_charm.py index 0f0d5d77..41595687 100644 --- a/charms/kfp-metadata-writer/tests/integration/test_charm.py +++ b/charms/kfp-metadata-writer/tests/integration/test_charm.py @@ -26,16 +26,32 @@ @pytest.mark.abort_on_fail -async def test_build_and_deploy_with_relations(ops_test: OpsTest): +async def test_build_and_deploy_with_relations(ops_test: OpsTest, request): built_charm_path = await ops_test.build_charm(CHARM_ROOT) log.info(f"Built charm {built_charm_path}") image_path = METADATA["resources"]["oci-image"]["upstream-source"] resources = {"oci-image": image_path} - await ops_test.model.deploy( - entity_url=built_charm_path, application_name=APP_NAME, resources=resources, trust=True - ) + if entity_url := request.config.getoption("--charm-path"): + await ops_test.model.deploy( + entity_url=entity_url, + application_name=APP_NAME, + resources=resources, + trust=True, + ) + else: + # Keep the option to run the integration tests locally + # by building the charm and then deploying + built_charm_path = await ops_test.build_charm("./") + logger.info(f"Built charm {built_charm_path}") + await ops_test.model.deploy( + entity_url=built_charm_path, + application_name=APP_NAME, + resources=resources, + trust=True, + ) + await ops_test.model.deploy(entity_url=MLMD, channel=MLMD_CHANNEL, trust=True) await ops_test.model.integrate(f"{MLMD}:grpc", f"{APP_NAME}:grpc") await ops_test.model.wait_for_idle(apps=[APP_NAME, MLMD], status="active", timeout=10 * 60)