From f5e6b577873ba904f64c106b9e4fc45159b3ae98 Mon Sep 17 00:00:00 2001 From: Peter Sabaini Date: Tue, 3 Oct 2023 12:38:12 +0200 Subject: [PATCH] Add reef functests to CI Via the jammy-bobcat UCA Don't rely on feature branch, vendor in context adapter instead Change-Id: Ifc5f04ce2259d19cb120a1434a2f80b178bd4dc3 --- osci.yaml | 8 ++++++ requirements.txt | 2 +- src/charm.py | 47 +++++++++++++++++++++++++++++++- tests/bundles/jammy-reef.yaml | 50 +++++++++++++++++++++++++++++++++++ tests/tests.yaml | 3 ++- 5 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 tests/bundles/jammy-reef.yaml diff --git a/osci.yaml b/osci.yaml index 7500386..c3ff84e 100644 --- a/osci.yaml +++ b/osci.yaml @@ -7,6 +7,7 @@ - focal-pacific - focal-quincy - jammy-quincy + - jammy-reef - lunar-quincy - mantic-quincy vars: @@ -41,6 +42,13 @@ - focal-quincy vars: tox_extra_args: -- jammy-quincy +- job: + name: jammy-reef + parent: func-target + dependencies: + - focal-quincy + vars: + tox_extra_args: -- jammy-reef - job: name: lunar-quincy parent: func-target diff --git a/requirements.txt b/requirements.txt index 6e7ef1d..1a8dbfa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ ops <= 1.6.0 git+https://github.com/juju/charm-helpers.git#egg=charmhelpers git+https://opendev.org/openstack/charm-ops-interface-ceph-client#egg=interface_ceph_client -git+https://github.com/ChrisMacNaughton/charm-ops-openstack.git@feature/charm-instance-to-relation-adapter#egg=ops_openstack +git+https://opendev.org/openstack/charm-ops-openstack#egg=ops_openstack git+https://opendev.org/openstack/charm-interface-hacluster#egg=interface_hacluster diff --git a/src/charm.py b/src/charm.py index 01caa84..1006125 100755 --- a/src/charm.py +++ b/src/charm.py @@ -101,8 +101,53 @@ class CephNFSContext(object): return socket.gethostname() -class CephNFSAdapters( +class OpenStackContextAdapters( ops_openstack.adapters.OpenStackRelationAdapters): + """ + Augmentation of OpenStackRelationAdapters that also includes contexts. + Proposed for upstreaming + https://review.opendev.org/c/openstack/charm-ops-openstack/+/897238 + """ + + relation_adapters = {} + + def __init__(self, relations, charm_instance, + options_instance=None, contexts=None): + """ + :param relations: List of instances of relation classes + :param options: Configuration class to use (DEPRECATED) + :param options_instance: Instance of Configuration class to use + :param charm_instance: optional charm_instance that is captured as a + weakref for use on the adapter. + :param contexts: Optional list of contexts + """ + super().__init__( + relations, charm_instance, + options_instance=options_instance + ) + if contexts is None: + contexts = () + self._contexts = set() + for context in contexts: + self.add_context(context) + + def __iter__(self): + """ + Iterate over the relations and contexts presented to the charm. + """ + for ref in self._relations.union(self._contexts): + yield ref, getattr(self, ref) + + def add_context(self, context): + """Add the context to this adapters instance. + + :param relation: a RAW context + """ + setattr(self, context.name, context) + self._contexts.add(context.name) + + +class CephNFSAdapters(OpenStackContextAdapters): """Collection of relation adapters.""" relation_adapters = { diff --git a/tests/bundles/jammy-reef.yaml b/tests/bundles/jammy-reef.yaml new file mode 100644 index 0000000..e0c186c --- /dev/null +++ b/tests/bundles/jammy-reef.yaml @@ -0,0 +1,50 @@ +options: + source: &source cloud:jammy-bobcat + +local_overlay_enabled: False +series: jammy +applications: + ubuntu: + charm: cs:ubuntu + num_units: 2 + ceph-nfs: + charm: ../../ceph-nfs.charm + num_units: 2 + options: + source: *source + ceph-osd: + charm: ch:ceph-osd + channel: latest/edge + num_units: 3 + storage: + osd-devices: '2,10G' + options: + source: *source + ceph-mon: + charm: ch:ceph-mon + channel: latest/edge + num_units: 3 + options: + monitor-count: '3' + expected-osd-count: 6 + source: *source + ceph-fs: + charm: ch:ceph-fs + channel: latest/edge + num_units: 2 + options: + source: *source + hacluster: + charm: ch:hacluster + channel: 2.4/edge + options: + cluster_count: 2 +relations: + - - 'ceph-mon:client' + - 'ceph-nfs:ceph-client' + - - 'ceph-osd:mon' + - 'ceph-mon:osd' + - - 'ceph-fs' + - 'ceph-mon' + - - 'ceph-nfs:ha' + - 'hacluster:ha' diff --git a/tests/tests.yaml b/tests/tests.yaml index cd8f59e..4660722 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -2,7 +2,8 @@ charm_name: ceph-nfs gate_bundles: - focal-quincy - focal-pacific - - jammy-pacific + - jammy-quincy + - jammy-reef - mantic-quincy smoke_bundles: - focal-pacific