Skip to content

Commit

Permalink
use NMS charm instead of webui
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciareinoso committed Aug 5, 2024
1 parent 1742679 commit 2ba8f86
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 41 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# SD-Core PCF Operator (k8s)
# Aether SD-Core PCF Operator (k8s)
[![CharmHub Badge](https://charmhub.io/sdcore-pcf-k8s/badge.svg)](https://charmhub.io/sdcore-pcf-k8s)

A Charmed Operator for SD-Core's Policy Control Function (PCF) component for K8s.
A Charmed Operator for Aether SD-Core's Policy Control Function (PCF) component for K8s.

## Usage

```bash
juju deploy mongodb-k8s --channel=6/beta --trust
juju deploy sdcore-nrf-k8s --channel=1.5/edge
juju deploy sdcore-pcf-k8s --channel=1.5/edge
juju deploy sdcore-webui-k8s --channel=1.5/edge
juju deploy sdcore-nms-k8s --channel=1.5/edge
juju deploy self-signed-certificates --channel=stable

juju integrate sdcore-webui-k8s:common_database mongodb-k8s:database
juju integrate sdcore-webui-k8s:auth_database mongodb-k8s:database
juju integrate sdcore-nms-k8s:common_database mongodb-k8s:database
juju integrate sdcore-nms-k8s:auth_database mongodb-k8s:database
juju integrate sdcore-nrf-k8s self-signed-certificates:certificates
juju integrate sdcore-nrf-k8s:database mongodb-k8s
juju integrate sdcore-pcf-k8s:fiveg_nrf sdcore-nrf-k8s:fiveg_nrf
juju integrate sdcore-pcf-k8s:certificates self-signed-certificates:certificates
juju integrate sdcore-pcf-k8s:sdcore_config sdcore-webui-k8s:sdcore-config
juju integrate sdcore-pcf-k8s:sdcore-config sdcore-nms-k8s:sdcore-config
```

## Image
Expand Down
2 changes: 1 addition & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ requires:
interface: tls-certificates
logging:
interface: loki_push_api
sdcore_config:
sdcore-config:
interface: sdcore_config

provides:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _on_sdcore_config_relation_joined(self, event: RelationJoinedEvent):
from pydantic import BaseModel, Field, ValidationError

# The unique Charmhub library identifier, never change it
LIBID = "e2f454cc121f449bbaa8fb0fd5a9867b"
LIBID = "87b8ff625f5544ad9985552df3fb6b6b"

# Increment this major API version when introducing breaking changes
LIBAPI = 0
Expand Down
6 changes: 3 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from charms.prometheus_k8s.v0.prometheus_scrape import ( # type: ignore[import]
MetricsEndpointProvider,
)
from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFRequires # type: ignore[import]
from charms.sdcore_webui_k8s.v0.sdcore_config import ( # type: ignore[import]
from charms.sdcore_nms_k8s.v0.sdcore_config import ( # type: ignore[import]
SdcoreConfigRequires,
)
from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFRequires # type: ignore[import]
from charms.tls_certificates_interface.v3.tls_certificates import ( # type: ignore[import]
CertificateExpiringEvent,
TLSCertificatesRequiresV3,
Expand Down Expand Up @@ -51,7 +51,7 @@
CERTIFICATE_NAME = "pcf.pem"
CERTIFICATE_COMMON_NAME = "pcf.sdcore"
LOGGING_RELATION_NAME = "logging"
SDCORE_CONFIG_RELATION_NAME = "sdcore_config"
SDCORE_CONFIG_RELATION_NAME = "sdcore-config"
WORKLOAD_VERSION_FILE_NAME = "/etc/workload-version"


Expand Down
4 changes: 2 additions & 2 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ output "logging_endpoint" {
}

output "sdcore_config_endpoint" {
description = "Name of the endpoint used to integrate with the Webui."
value = "sdcore_config"
description = "Name of the endpoint used to integrate with the NMS."
value = "sdcore-config"
}

# Provided integration endpoints
Expand Down
36 changes: 18 additions & 18 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
APPLICATION_NAME = METADATA["name"]
NRF_CHARM_NAME = "sdcore-nrf-k8s"
NRF_CHARM_CHANNEL = "1.5/edge"
WEBUI_CHARM_NAME = "sdcore-webui-k8s"
WEBUI_CHARM_CHANNEL = "1.5/edge"
NMS_CHARM_NAME = "sdcore-nms-k8s"
NMS_CHARM_CHANNEL = "1.5/edge"
DATABASE_CHARM_NAME = "mongodb-k8s"
DATABASE_CHARM_CHANNEL = "6/beta"
TLS_CHARM_NAME = "self-signed-certificates"
Expand All @@ -43,7 +43,7 @@ async def deploy(ops_test: OpsTest, request):
await _deploy_database(ops_test)
await _deploy_tls_provider(ops_test)
await _deploy_grafana_agent(ops_test)
await _deploy_webui(ops_test)
await _deploy_nms(ops_test)
await _deploy_nrf(ops_test)


Expand All @@ -66,8 +66,8 @@ async def test_relate_and_wait_for_active_status(ops_test: OpsTest, deploy):
)
await ops_test.model.integrate(relation1=APPLICATION_NAME, relation2=TLS_CHARM_NAME)
await ops_test.model.integrate(
relation1=f"{APPLICATION_NAME}:sdcore_config",
relation2=f"{WEBUI_CHARM_NAME}:sdcore-config",
relation1=f"{APPLICATION_NAME}:sdcore-config",
relation2=f"{NMS_CHARM_NAME}:sdcore-config",
)
await ops_test.model.integrate(
relation1=f"{APPLICATION_NAME}:logging",
Expand Down Expand Up @@ -99,19 +99,19 @@ async def test_restore_nrf_and_wait_for_active_status(ops_test: OpsTest, deploy)
await ops_test.model.wait_for_idle(apps=[APPLICATION_NAME], status="active", timeout=1000)

@pytest.mark.abort_on_fail
async def test_remove_webui_and_wait_for_blocked_status(ops_test: OpsTest, deploy):
async def test_remove_nms_and_wait_for_blocked_status(ops_test: OpsTest, deploy):
assert ops_test.model
await ops_test.model.remove_application(WEBUI_CHARM_NAME, block_until_done=True)
await ops_test.model.remove_application(NMS_CHARM_NAME, block_until_done=True)
await ops_test.model.wait_for_idle(apps=[APPLICATION_NAME], status="blocked", timeout=1000)


@pytest.mark.abort_on_fail
async def test_restore_webui_and_wait_for_active_status(ops_test: OpsTest, deploy):
async def test_restore_nms_and_wait_for_active_status(ops_test: OpsTest, deploy):
assert ops_test.model
await _deploy_webui(ops_test)
await _deploy_nms(ops_test)
await ops_test.model.integrate(
relation1=f"{APPLICATION_NAME}:sdcore_config",
relation2=f"{WEBUI_CHARM_NAME}:sdcore-config",
relation1=f"{APPLICATION_NAME}:sdcore-config",
relation2=f"{NMS_CHARM_NAME}:sdcore-config",
)
await ops_test.model.wait_for_idle(apps=[APPLICATION_NAME], status="active", timeout=1000)

Expand Down Expand Up @@ -142,18 +142,18 @@ async def _deploy_database(ops_test: OpsTest):
)


async def _deploy_webui(ops_test: OpsTest):
async def _deploy_nms(ops_test: OpsTest):
assert ops_test.model
await ops_test.model.deploy(
WEBUI_CHARM_NAME,
application_name=WEBUI_CHARM_NAME,
channel=WEBUI_CHARM_CHANNEL,
NMS_CHARM_NAME,
application_name=NMS_CHARM_NAME,
channel=NMS_CHARM_CHANNEL,
)
await ops_test.model.integrate(
relation1=f"{WEBUI_CHARM_NAME}:common_database", relation2=f"{DATABASE_CHARM_NAME}"
relation1=f"{NMS_CHARM_NAME}:common_database", relation2=f"{DATABASE_CHARM_NAME}"
)
await ops_test.model.integrate(
relation1=f"{WEBUI_CHARM_NAME}:auth_database", relation2=f"{DATABASE_CHARM_NAME}"
relation1=f"{NMS_CHARM_NAME}:auth_database", relation2=f"{DATABASE_CHARM_NAME}"
)


Expand All @@ -167,7 +167,7 @@ async def _deploy_nrf(ops_test: OpsTest):
)
await ops_test.model.integrate(relation1=NRF_CHARM_NAME, relation2=DATABASE_CHARM_NAME)
await ops_test.model.integrate(relation1=NRF_CHARM_NAME, relation2=TLS_CHARM_NAME)
await ops_test.model.integrate(relation1=NRF_CHARM_NAME, relation2=WEBUI_CHARM_NAME)
await ops_test.model.integrate(relation1=NRF_CHARM_NAME, relation2=NMS_CHARM_NAME)


async def _deploy_tls_provider(ops_test: OpsTest):
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
PRIVATE_KEY_PATH = "support/TLS/pcf.key"
VALID_NRF_URL = "https://nrf:443"
WEBUI_URL = "sdcore-webui:9876"
SDCORE_CONFIG_RELATION_NAME = "sdcore_config"
WEBUI_APPLICATION_NAME = "sdcore-webui-operator"
SDCORE_CONFIG_RELATION_NAME = "sdcore-config"
NMS_APPLICATION_NAME = "sdcore-nms-operator"


class PCFUnitTestFixtures:
Expand All @@ -44,7 +44,7 @@ class PCFUnitTestFixtures:
patcher_request_certificate = patch(f"{CERTIFICATES_LIB}.request_certificate_creation")
patcher_restart_container = patch("ops.model.Container.restart")
patcher_webui_url = patch(
"charms.sdcore_webui_k8s.v0.sdcore_config.SdcoreConfigRequires.webui_url",
"charms.sdcore_nms_k8s.v0.sdcore_config.SdcoreConfigRequires.webui_url",
new_callable=PropertyMock
)

Expand Down Expand Up @@ -114,14 +114,14 @@ def _get_metadata() -> dict:
def sdcore_config_relation_id(self) -> Generator[int, None, None]:
sdcore_config_relation_id = self.harness.add_relation( # type:ignore
relation_name=SDCORE_CONFIG_RELATION_NAME,
remote_app=WEBUI_APPLICATION_NAME,
remote_app=NMS_APPLICATION_NAME,
)
self.harness.add_relation_unit( # type:ignore
relation_id=sdcore_config_relation_id, remote_unit_name=f"{WEBUI_APPLICATION_NAME}/0"
relation_id=sdcore_config_relation_id, remote_unit_name=f"{NMS_APPLICATION_NAME}/0"
)
self.harness.update_relation_data( # type:ignore
relation_id=sdcore_config_relation_id,
app_or_unit=WEBUI_APPLICATION_NAME,
app_or_unit=NMS_APPLICATION_NAME,
key_values={
"webui_url": WEBUI_URL,
},
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
PRIVATE_KEY_PATH = "support/TLS/pcf.key"
VALID_NRF_URL = "https://nrf:443"
WEBUI_URL = "sdcore-webui:9876"
SDCORE_CONFIG_RELATION_NAME = "sdcore_config"
WEBUI_APPLICATION_NAME = "sdcore-webui-operator"
SDCORE_CONFIG_RELATION_NAME = "sdcore-config"


class TestCharm(PCFUnitTestFixtures):
Expand Down Expand Up @@ -86,7 +85,7 @@ def test_given_container_can_connect_and_sdcore_config_relation_is_not_created_w
self.harness.evaluate_status()

assert self.harness.model.unit.status == BlockedStatus(
"Waiting for sdcore_config relation(s)"
"Waiting for sdcore-config relation(s)"
)

def test_given_pcf_charm_in_active_state_when_nrf_relation_breaks_then_status_is_blocked(
Expand Down Expand Up @@ -116,7 +115,7 @@ def test_given_pcf_charm_in_active_state_when_sdcore_config_relation_breaks_then
self.harness.evaluate_status()

assert self.harness.model.unit.status == BlockedStatus(
"Waiting for sdcore_config relation(s)"
"Waiting for sdcore-config relation(s)"
)

def test_given_container_can_connect_and_fiveg_nrf_relation_is_not_available_when_collect_status_then_status_is_waiting( # noqa: E501
Expand Down

0 comments on commit 2ba8f86

Please sign in to comment.