From 879d059c34b3cf08357967140ec0734246d0d325 Mon Sep 17 00:00:00 2001 From: Hemanth Nakkina Date: Thu, 8 Sep 2022 16:29:26 +0530 Subject: [PATCH] Add osci yaml Add project templates and variables to osci.yaml Add rename script to change built charm name to charm_build_name defined in osci.yaml Change-Id: I74f7099b480e003db6a2b54581e7ad224da2a718 --- charms/neutron-k8s/osci.yaml | 12 ++++++++++++ charms/neutron-k8s/rename.sh | 13 +++++++++++++ .../tests/unit/test_neutron_charm.py | 17 +++++++++++++++++ charms/neutron-k8s/tox.ini | 2 ++ 4 files changed, 44 insertions(+) create mode 100644 charms/neutron-k8s/osci.yaml create mode 100755 charms/neutron-k8s/rename.sh diff --git a/charms/neutron-k8s/osci.yaml b/charms/neutron-k8s/osci.yaml new file mode 100644 index 00000000..6fcaeb8b --- /dev/null +++ b/charms/neutron-k8s/osci.yaml @@ -0,0 +1,12 @@ +- project: + templates: + - charm-unit-jobs-py38 + - charm-unit-jobs-py310 + - charm-publish-jobs + vars: + needs_charm_build: true + charm_build_name: neutron-k8s + build_type: charmcraft + publish_charm: true + charmcraft_channel: 2.0/stable + publish_channel: latest/edge diff --git a/charms/neutron-k8s/rename.sh b/charms/neutron-k8s/rename.sh new file mode 100755 index 00000000..d0c35c97 --- /dev/null +++ b/charms/neutron-k8s/rename.sh @@ -0,0 +1,13 @@ +#!/bin/bash +charm=$(grep "charm_build_name" osci.yaml | awk '{print $2}') +echo "renaming ${charm}_*.charm to ${charm}.charm" +echo -n "pwd: " +pwd +ls -al +echo "Removing bad downloaded charm maybe?" +if [[ -e "${charm}.charm" ]]; +then + rm "${charm}.charm" +fi +echo "Renaming charm here." +mv ${charm}_*.charm ${charm}.charm diff --git a/charms/neutron-k8s/tests/unit/test_neutron_charm.py b/charms/neutron-k8s/tests/unit/test_neutron_charm.py index 04009ef9..a6b8a471 100644 --- a/charms/neutron-k8s/tests/unit/test_neutron_charm.py +++ b/charms/neutron-k8s/tests/unit/test_neutron_charm.py @@ -50,6 +50,23 @@ class TestNeutronOperatorCharm(test_utils.CharmTestCase): self.harness = test_utils.get_harness( _NeutronOVNXenaOperatorCharm, container_calls=self.container_calls) + + # clean up events that were dynamically defined, + # otherwise we get issues because they'll be redefined, + # which is not allowed. + from charms.data_platform_libs.v0.database_requires import ( + DatabaseEvents + ) + for attr in ( + "database_database_created", + "database_endpoints_changed", + "database_read_only_endpoints_changed", + ): + try: + delattr(DatabaseEvents, attr) + except AttributeError: + pass + self.addCleanup(self.harness.cleanup) test_utils.add_complete_ingress_relation(self.harness) self.harness.begin() diff --git a/charms/neutron-k8s/tox.ini b/charms/neutron-k8s/tox.ini index de6c5d5b..ca8b7454 100644 --- a/charms/neutron-k8s/tox.ini +++ b/charms/neutron-k8s/tox.ini @@ -29,6 +29,7 @@ allowlist_externals = git charmcraft fetch-libs.sh + rename.sh deps = -r{toxinidir}/test-requirements.txt @@ -37,6 +38,7 @@ basepython = python3 deps = commands = charmcraft -v pack + {toxinidir}/rename.sh [testenv:fetch] basepython = python3