Skip to content

Commit

Permalink
feat: Updates tests to use fiveg_core_gnb interface (#493)
Browse files Browse the repository at this point in the history
* Updates tests to use fiveg_core_gnb interface

* Fixes e2e tests

* Improves logs archiving

* Testing with gnbsim running latest workload version

* Testing with gnbsim running latest workload version

* Reverts custom version of gnbsim
  • Loading branch information
Gmerold authored Dec 17, 2024
1 parent 99d2375 commit b496244
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 34 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions terraform/integration_tests.auto.tfvars.j2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sdcore_model_name = "{{ sdcore_model_name }}"
ran_model_name = "{{ ran_model_name }}"
17 changes: 6 additions & 11 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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
}
}

Expand Down
8 changes: 7 additions & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions tests/integration/juju_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/nms_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
}
Expand Down
27 changes: 11 additions & 16 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b496244

Please sign in to comment.