Skip to content

Commit

Permalink
Create fiveg_n3 and fiveg_n4 libraries
Browse files Browse the repository at this point in the history
Pin macaroonbakery to 1.3.2
The next protobuf version 4.21.0 has the breaking changes with the existing code
https://protobuf.dev/news/2022-05-06/#python-updates

Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Dec 8, 2023
1 parent b681778 commit e78c1cb
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
with:
filters: |
fiveg_n3:
- 'lib/charms/sdcore_upf/v0/fiveg_n3.py'
- 'lib/charms/sdcore_upf_k8s/v0/fiveg_n3.py'
publish-fiveg-n3-lib:
name: Publish Lib
Expand All @@ -61,7 +61,7 @@ jobs:
if: ${{ github.ref_name == 'main' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main
with:
lib-name: "charms.sdcore_upf.v0.fiveg_n3"
lib-name: "charms.sdcore_upf_k8s.v0.fiveg_n3"
secrets: inherit

fiveg-n4-lib-needs-publishing:
Expand All @@ -75,7 +75,7 @@ jobs:
with:
filters: |
fiveg_n4:
- 'lib/charms/sdcore_upf/v0/fiveg_n4.py'
- 'lib/charms/sdcore_upf_k8s/v0/fiveg_n4.py'
publish-fiveg-n4-lib:
name: Publish Lib
Expand All @@ -85,5 +85,5 @@ jobs:
if: ${{ github.ref_name == 'main' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main
with:
lib-name: "charms.sdcore_upf.v0.fiveg_n4"
lib-name: "charms.sdcore_upf_k8s.v0.fiveg_n4"
secrets: inherit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SD-Core UPF Operator for K8s
# SD-Core UPF Operator (k8s)
[![CharmHub Badge](https://charmhub.io/sdcore-upf-k8s/badge.svg)](https://charmhub.io/sdcore-upf-k8s)

Charmed Operator for SD-Core's User Plane Function (UPF) for K8s. For more information, read [here](https://github.com/omec-project/upf).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
```shell
cd some-charm
charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n3
charmcraft fetch-lib charms.sdcore_upf_k8s.v0.fiveg_n3
```
Add the following libraries to the charm's `requirements.txt` file:
Expand All @@ -23,7 +23,7 @@
```python
...
from charms.sdcore_upf.v0.fiveg_n3 import N3Provides
from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides
...
class SomeProviderCharm(CharmBase):
Expand Down Expand Up @@ -54,7 +54,7 @@ def _on_fiveg_n3_request(self, event):
```python
...
from charms.sdcore_upf.v0.fiveg_n3 import N3Requires
from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Requires
...
class SomeRequirerCharm(CharmBase):
Expand Down Expand Up @@ -86,14 +86,14 @@ def _on_fiveg_n3_available(self, event):
from pydantic import BaseModel, Field, IPvAnyAddress, ValidationError

# The unique Charmhub library identifier, never change it
LIBID = "4b9dbfa97f7849dda91d47f5cb0fa044"
LIBID = "93fa81e7726c4d14ba2b4834866bf30e"

# Increment this major API version when introducing breaking changes
LIBAPI = 0

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2
LIBPATCH = 1

PYDEPS = ["pydantic", "pytest-interface-tester"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
```shell
cd some-charm
charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n4
charmcraft fetch-lib charms.sdcore_upf_k8s.v0.fiveg_n4
```
Add the following libraries to the charm's `requirements.txt` file:
Expand All @@ -26,7 +26,7 @@
```python
...
from charms.sdcore_upf.v0.fiveg_n4 import N4Provides
from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides
...
class SomeProviderCharm(CharmBase):
Expand Down Expand Up @@ -58,7 +58,7 @@ def _on_fiveg_n4_request(self, event):
```python
...
from charms.sdcore_upf.v0.fiveg_n4 import N4Requires
from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Requires
...
class SomeRequirerCharm(CharmBase):
Expand Down Expand Up @@ -91,14 +91,14 @@ def _on_fiveg_n4_available(self, event):
from pydantic import BaseModel, Field, ValidationError

# The unique Charmhub library identifier, never change it
LIBID = "bc6261cf77104d4fb3edfd6d4ea63149"
LIBID = "6c81534a04904d48966ceb7b4f42a850"

# Increment this major API version when introducing breaking changes
LIBAPI = 0

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2
LIBPATCH = 1

PYDEPS = ["pydantic", "pytest-interface-tester"]

Expand Down
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from charms.prometheus_k8s.v0.prometheus_scrape import ( # type: ignore[import]
MetricsEndpointProvider,
)
from charms.sdcore_upf.v0.fiveg_n3 import N3Provides # type: ignore[import]
from charms.sdcore_upf.v0.fiveg_n4 import N4Provides # type: ignore[import]
from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides # type: ignore[import]
from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides # type: ignore[import]
from jinja2 import Environment, FileSystemLoader
from lightkube.core.client import Client
from lightkube.models.core_v1 import ServicePort, ServiceSpec
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ flake8-docstrings
flake8-builtins
isort
juju
macaroonbakery==1.3.2
macaroonbakery==1.3.2 # https://protobuf.dev/news/2022-05-06/#python-updates
mypy
pep8-naming
pyproject-flake8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import logging

from charms.sdcore_upf.v0.fiveg_n3 import N3Provides
from charms.sdcore_upf.v0.fiveg_n4 import N4Provides
from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Provides
from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Provides
from ops.charm import CharmBase
from ops.main import main

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import logging

from charms.sdcore_upf.v0.fiveg_n3 import N3Requires
from charms.sdcore_upf.v0.fiveg_n4 import N4Requires
from charms.sdcore_upf_k8s.v0.fiveg_n3 import N3Requires
from charms.sdcore_upf_k8s.v0.fiveg_n4 import N4Requires
from ops.charm import CharmBase
from ops.main import main
from ops.model import ActiveStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self) -> None:
self.harness.begin()
self.relation_name = "fiveg_n3"

@patch("charms.sdcore_upf.v0.fiveg_n3.N3RequirerCharmEvents.fiveg_n3_available")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3RequirerCharmEvents.fiveg_n3_available")
def test_given_relation_with_n3_provider_when_fiveg_n3_available_event_then_n3_information_is_provided( # noqa: E501
self, patched_fiveg_n3_available_event
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self) -> None:
self.harness.begin()
self.relation_name = "fiveg_n4"

@patch("charms.sdcore_upf.v0.fiveg_n4.N4RequirerCharmEvents.fiveg_n4_available")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4RequirerCharmEvents.fiveg_n4_available")
def test_given_relation_with_n4_provider_when_fiveg_n4_available_event_then_n4_information_is_provided( # noqa: E501
self, patched_fiveg_n4_available_event
):
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def test_given_cant_connect_to_bessd_container_when_pfcp_agent_pebble_ready_then
)

@patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched")
@patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information")
def test_given_fiveg_n3_relation_created_when_fiveg_n3_request_then_upf_ip_address_is_published( # noqa: E501
self,
patched_publish_upf_information,
Expand All @@ -468,7 +468,7 @@ def test_given_fiveg_n3_relation_created_when_fiveg_n3_request_then_upf_ip_addre
relation_id=n3_relation_id, upf_ip_address=test_upf_access_ip_cidr.split("/")[0]
)

@patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information")
def test_given_unit_is_not_leader_when_fiveg_n3_request_then_upf_ip_address_is_not_published(
self, patched_publish_upf_information
):
Expand All @@ -482,7 +482,7 @@ def test_given_unit_is_not_leader_when_fiveg_n3_request_then_upf_ip_address_is_n
patched_publish_upf_information.assert_not_called()

@patch(f"{MULTUS_LIBRARY_PATH}.KubernetesClient", new=Mock)
@patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready")
@patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched")
def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_then_new_upf_ip_address_is_published( # noqa: E501
Expand All @@ -508,7 +508,7 @@ def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_then_new_u

patched_publish_upf_information.assert_has_calls(expected_calls)

@patch("charms.sdcore_upf.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n3.N3Provides.publish_upf_information")
@patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready")
def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_to_invalid_cidr_then_new_upf_ip_address_is_not_published( # noqa: E501
self, patch_multus_is_ready, patched_publish_upf_information
Expand All @@ -527,7 +527,7 @@ def test_given_fiveg_n3_relation_exists_when_access_ip_config_changed_to_invalid
relation_id=n3_relation_id, upf_ip_address="192.168.252.3"
)

@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
def test_given_unit_is_not_leader_when_fiveg_n4_request_then_upf_hostname_is_not_published(
self, patched_publish_upf_n4_information
):
Expand All @@ -543,7 +543,7 @@ def test_given_unit_is_not_leader_when_fiveg_n4_request_then_upf_hostname_is_not
patched_publish_upf_n4_information.assert_not_called()

@patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched")
@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charm.PFCP_PORT", TEST_PFCP_PORT)
def test_given_external_upf_hostname_config_set_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501
self,
Expand All @@ -567,7 +567,7 @@ def test_given_external_upf_hostname_config_set_and_fiveg_n4_relation_created_wh

@patch("lightkube.core.client.GenericSyncClient", new=Mock)
@patch("lightkube.core.client.Client.get")
@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charm.PFCP_PORT", TEST_PFCP_PORT)
def test_given_external_upf_hostname_config_not_set_but_external_upf_service_hostname_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501
self, patched_publish_upf_n4_information, patched_lightkube_client_get
Expand All @@ -593,7 +593,7 @@ def test_given_external_upf_hostname_config_not_set_but_external_upf_service_hos

@patch("lightkube.core.client.GenericSyncClient", new=Mock)
@patch("lightkube.core.client.Client.get")
@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charm.PFCP_PORT", TEST_PFCP_PORT)
def test_given_external_upf_hostname_config_not_set_and_external_upf_service_hostname_not_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501
self, patched_publish_upf_n4_information, patched_lightkube_client_get
Expand All @@ -613,7 +613,7 @@ def test_given_external_upf_hostname_config_not_set_and_external_upf_service_hos

@patch("lightkube.core.client.GenericSyncClient", new=Mock)
@patch("lightkube.core.client.Client.get")
@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charm.PFCP_PORT", TEST_PFCP_PORT)
def test_given_external_upf_hostname_config_not_set_and_metallb_not_available_and_fiveg_n4_relation_created_when_fiveg_n4_request_then_upf_hostname_and_n4_port_is_published( # noqa: E501
self, patched_publish_upf_n4_information, patched_lightkube_client_get
Expand All @@ -631,7 +631,7 @@ def test_given_external_upf_hostname_config_not_set_and_metallb_not_available_an
upf_n4_port=TEST_PFCP_PORT,
)

@patch("charms.sdcore_upf.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch("charms.sdcore_upf_k8s.v0.fiveg_n4.N4Provides.publish_upf_n4_information")
@patch(f"{MULTUS_LIBRARY_PATH}.KubernetesMultusCharmLib.is_ready")
@patch(f"{HUGEPAGES_LIBRARY_PATH}.KubernetesHugePagesPatchCharmLib.is_patched")
@patch("charm.PFCP_PORT", TEST_PFCP_PORT)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envlist = lint, static, unit
src_path = {toxinidir}/src/
unit_test_path = {toxinidir}/tests/unit/
integration_test_path = {toxinidir}/tests/integration/
lib_path = {toxinidir}/lib/charms/sdcore_upf/v0/
lib_path = {toxinidir}/lib/charms/sdcore_upf_k8s/v0/
all_path = {[vars]src_path} {[vars]unit_test_path} {[vars]integration_test_path} {[vars]lib_path}

[testenv]
Expand Down

0 comments on commit e78c1cb

Please sign in to comment.