diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 2ade5b5..0e7979a 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -41,23 +41,29 @@ jobs: run: tox -vve integration - name: Gather logs - if: always() + if: failure() run: | juju-crashdump -m sdcore + juju-crashdump -m ran for pod in $(sudo microk8s.kubectl -n sdcore get pods -o json | jq .items[].metadata.name | tr -d '"'); do - sudo microk8s.kubectl -n sdcore logs $pod --all-containers > pod-$pod.log + sudo microk8s.kubectl -n sdcore logs $pod --all-containers > sdcore-$pod.log + done + for pod in $(sudo microk8s.kubectl -n ran get pods -o json | jq .items[].metadata.name | tr -d '"'); do + sudo microk8s.kubectl -n ran logs $pod --all-containers > ran-$pod.log done - name: Archive juju crashdump - if: always() + if: failure() uses: actions/upload-artifact@v4 with: name: juju-crashdump path: juju-crashdump-*.tar.xz - name: Archive k8s logs - if: always() + if: failure() uses: actions/upload-artifact@v4 with: name: k8s-logs - path: pod-*.log + path: | + sdcore-*.log + ran-*.log diff --git a/terraform/integration_tests.auto.tfvars.j2 b/terraform/integration_tests.auto.tfvars.j2 index d1d1d26..88b3fe5 100644 --- a/terraform/integration_tests.auto.tfvars.j2 +++ b/terraform/integration_tests.auto.tfvars.j2 @@ -1 +1,2 @@ sdcore_model_name = "{{ sdcore_model_name }}" +ran_model_name = "{{ ran_model_name }}" diff --git a/terraform/main.tf b/terraform/main.tf index db073cd..8d80343 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -21,20 +21,15 @@ module "sdcore" { } resource "juju_model" "ran-simulator" { - name = "ran" + name = var.ran_model_name } module "gnbsim" { source = "git::https://github.com/canonical/sdcore-gnbsim-k8s-operator//terraform" model = juju_model.ran-simulator.name - depends_on = [module.sdcore-router] -} -resource "juju_offer" "gnbsim-fiveg-gnb-identity" { - model = juju_model.ran-simulator.name - application_name = module.gnbsim.app_name - endpoint = module.gnbsim.provides.fiveg_gnb_identity + depends_on = [module.sdcore-router] } resource "juju_integration" "gnbsim-amf" { @@ -51,15 +46,15 @@ resource "juju_integration" "gnbsim-amf" { } resource "juju_integration" "gnbsim-nms" { - model = juju_model.sdcore.name + model = juju_model.ran-simulator.name application { - name = module.sdcore.nms_app_name - endpoint = module.sdcore.fiveg_gnb_identity_endpoint + name = module.gnbsim.app_name + endpoint = module.gnbsim.requires.fiveg_core_gnb } application { - offer_url = juju_offer.gnbsim-fiveg-gnb-identity.url + offer_url = module.sdcore.nms_fiveg_core_gnb_offer_url } } diff --git a/terraform/variables.tf b/terraform/variables.tf index 2efa6df..38e007a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -2,7 +2,13 @@ # See LICENSE file for licensing details. variable "sdcore_model_name" { - description = "Name of Juju model to deploy application to." + description = "Name of Juju model to deploy Charmed Aether SD-Core to." type = string default = "sdcore" } + +variable "ran_model_name" { + description = "Name of Juju model to deploy RAN simulator to." + type = string + default = "ran" +} diff --git a/tests/integration/juju_helper.py b/tests/integration/juju_helper.py index 5d4172d..2ab6ed0 100644 --- a/tests/integration/juju_helper.py +++ b/tests/integration/juju_helper.py @@ -44,6 +44,7 @@ def juju_wait_for_active_idle(model_name: str, timeout: int, time_idle: int = 10 logger.info("Deployment is ready!") logger.info(check_output(["juju", "status"]).decode()) return + logger.info(check_output(["juju", "status"]).decode()) raise TimeoutError("Timed out waiting for Juju model to be ready!") diff --git a/tests/integration/nms_helper.py b/tests/integration/nms_helper.py index 3082d66..6004351 100644 --- a/tests/integration/nms_helper.py +++ b/tests/integration/nms_helper.py @@ -51,7 +51,7 @@ "site-info": { "site-name": "demo", "plmn": {"mcc": "001", "mnc": "01"}, - "gNodeBs": [{"name": "demo-gnb1", "tac": 1}], + "gNodeBs": [{"name": "ran-gnbsim-gnbsim", "tac": 1}], "upf": {"upf-name": "upf-external", "upf-port": "8805"}, }, } diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 424c02c..da55929 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -41,8 +41,7 @@ def setup_class(cls): @pytest.mark.abort_on_fail async def test_given_sdcore_terraform_module_when_deploy_then_status_is_active(self): self._deploy_sdcore() - juju_helper.juju_wait_for_active_idle(model_name=SDCORE_MODEL_NAME, timeout=1200) - juju_helper.juju_wait_for_active_idle(model_name=RAN_MODEL_NAME, timeout=1200) + juju_helper.juju_wait_for_active_idle(model_name=SDCORE_MODEL_NAME, timeout=900) @pytest.mark.abort_on_fail async def test_given_sdcore_bundle_and_gnbsim_deployed_when_start_simulation_then_simulation_success_status_is_true( # noqa: E501 @@ -55,20 +54,15 @@ async def test_given_sdcore_bundle_and_gnbsim_deployed_when_start_simulation_the if not username or not password: raise Exception("NMS credentials not found.") configure_sdcore(username, password) - for _ in range(5): - action_output = juju_helper.juju_run_action( - model_name=RAN_MODEL_NAME, - application_name="gnbsim", - unit_number=0, - action_name="start-simulation", - timeout=6 * 60, - ) - try: - assert action_output["success"] == "true" - return - except AssertionError: - continue - assert False + juju_helper.juju_wait_for_active_idle(model_name=RAN_MODEL_NAME, timeout=300) + action_output = juju_helper.juju_run_action( + model_name=RAN_MODEL_NAME, + application_name="gnbsim", + unit_number=0, + action_name="start-simulation", + timeout=6 * 60, + ) + assert action_output["success"] == "true" @pytest.mark.skip( reason="Traefik issue: https://github.com/canonical/traefik-k8s-operator/issues/361" @@ -117,6 +111,7 @@ def _generate_tfvars_file(): template = jinja2_environment.get_template(f"{TFVARS_FILE}.j2") content = template.render( sdcore_model_name=SDCORE_MODEL_NAME, + ran_model_name=RAN_MODEL_NAME, ) with open(f"{TERRAFORM_DIR}/{TFVARS_FILE}", mode="w") as tfvars: tfvars.write(content)