Skip to content

Commit

Permalink
fix: Updates integration tests after changes in Terraform (#448)
Browse files Browse the repository at this point in the history
* Fixes integration tests

* Fixes integration tests

* Fixes integration tests
  • Loading branch information
Gmerold authored Oct 16, 2024
1 parent 1d07eba commit 9fb737f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
69 changes: 56 additions & 13 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,94 @@ resource "juju_model" "sdcore" {
module "sdcore-router" {
source = "git::https://github.com/canonical/sdcore-router-k8s-operator//terraform"

model_name = juju_model.sdcore.name
model = juju_model.sdcore.name
depends_on = [juju_model.sdcore]
}

module "sdcore" {
source = "git::https://github.com/canonical/terraform-juju-sdcore-k8s//modules/sdcore-k8s"

model_name = juju_model.sdcore.name
create_model = false
deploy_cos = true
model = juju_model.sdcore.name

depends_on = [module.sdcore-router]
}

resource "juju_model" "ran-simulator" {
name = "ran"
}

module "gnbsim" {
source = "git::https://github.com/canonical/sdcore-gnbsim-k8s-operator//terraform"

model_name = juju_model.sdcore.name
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
}

resource "juju_integration" "gnbsim-amf" {
model = juju_model.sdcore.name
model = juju_model.ran-simulator.name

application {
name = module.gnbsim.app_name
endpoint = module.gnbsim.fiveg_n2_endpoint
endpoint = module.gnbsim.requires.fiveg_n2
}

application {
name = module.sdcore.amf_app_name
endpoint = module.sdcore.fiveg_n2_endpoint
offer_url = module.sdcore.amf_fiveg_n2_offer_url
}
}

resource "juju_integration" "gnbsim-nms" {
model = juju_model.sdcore.name

application {
name = module.gnbsim.app_name
endpoint = module.gnbsim.fiveg_gnb_identity_endpoint
name = module.sdcore.nms_app_name
endpoint = module.sdcore.fiveg_gnb_identity_endpoint
}

application {
name = module.sdcore.nms_app_name
endpoint = module.sdcore.fiveg_gnb_identity_endpoint
offer_url = juju_offer.gnbsim-fiveg-gnb-identity.url
}
}

module "cos" {
source = "git::https://github.com/canonical/terraform-juju-sdcore//modules/external/cos-lite"
model_name = "cos-lite"
deploy_cos_configuration = true
cos_configuration_config = {
git_repo = "https://github.com/canonical/sdcore-cos-configuration"
git_branch = "main"
grafana_dashboards_path = "grafana_dashboards/sdcore/"
}
}

resource "juju_integration" "prometheus-remote-write" {
model = juju_model.sdcore.name

application {
name = module.sdcore.grafana_agent_app_name
endpoint = module.sdcore.send_remote_write_endpoint
}

application {
offer_url = module.cos.prometheus_remote_write_offer_url
}
}

resource "juju_integration" "loki-logging" {
model = juju_model.sdcore.name

application {
name = module.sdcore.grafana_agent_app_name
endpoint = module.sdcore.logging_consumer_endpoint
}

application {
offer_url = module.cos.loki_logging_offer_url
}
}
2 changes: 1 addition & 1 deletion terraform/terraform.tf → terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
required_providers {
juju = {
source = "juju/juju"
version = ">= 0.11.0"
version = ">= 0.12.0"
}
}
}
5 changes: 3 additions & 2 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
logger = logging.getLogger(__name__)

SDCORE_MODEL_NAME = "sdcore"
RAN_MODEL_NAME = "ran"
COS_MODEL_NAME = "cos-lite"
TERRAFORM_DIR = "terraform"
TFVARS_FILE = "integration_tests.auto.tfvars"
Expand All @@ -40,14 +41,15 @@ def setup_class(cls):
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)

@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
self, configure_sdcore
):
for _ in range(5):
action_output = juju_helper.juju_run_action(
model_name=SDCORE_MODEL_NAME,
model_name=RAN_MODEL_NAME,
application_name="gnbsim",
unit_number=0,
action_name="start-simulation",
Expand Down Expand Up @@ -107,7 +109,6 @@ def _generate_tfvars_file():
template = jinja2_environment.get_template(f"{TFVARS_FILE}.j2")
content = template.render(
sdcore_model_name=SDCORE_MODEL_NAME,
cos_model_name=COS_MODEL_NAME,
)
with open(f"{TERRAFORM_DIR}/{TFVARS_FILE}", mode="w") as tfvars:
tfvars.write(content)
Expand Down

0 comments on commit 9fb737f

Please sign in to comment.