From eaa0869f9fae5421f8274d10419921ca29716e73 Mon Sep 17 00:00:00 2001
From: Myles Penner <myles.penner@canonical.com>
Date: Tue, 3 Sep 2024 21:40:18 +0000
Subject: [PATCH] Add charmcraft 3 support

Summary of changes:
- Update the charmcraft.yaml file to use base and platforms, only
  allowing noble support.
- Update config to default to caracal.
- Update osci.yaml to use the charmcraft 3.x/beta
- Drop non-noble tests
- Update constraints file from -2024.1.txt to -noble.txt
- Add noble and oracular to charmhelpers
- Set env var in tox.ini TEST_JUJU3=1
- Add charmbuild to .zuul.yaml

Change-Id: I4cb7630a5dfe59949c75fe521bf576c294b4d06d
---
 .zuul.yaml                                    |   5 +
 charmcraft.yaml                               |  24 ++-
 .../charmhelpers/core/host_factory/ubuntu.py  |   2 +
 metadata.yaml                                 |   2 -
 osci.yaml                                     |   2 +-
 tests/bundles/jammy-antelope.yaml             | 178 ------------------
 tests/bundles/jammy-bobcat.yaml               | 178 ------------------
 tests/bundles/jammy-caracal.yaml              | 178 ------------------
 tests/bundles/noble-caracal.yaml              |  14 +-
 tests/tests.yaml                              |   6 +-
 tox.ini                                       |   3 +-
 11 files changed, 33 insertions(+), 559 deletions(-)
 delete mode 100644 tests/bundles/jammy-antelope.yaml
 delete mode 100644 tests/bundles/jammy-bobcat.yaml
 delete mode 100644 tests/bundles/jammy-caracal.yaml

diff --git a/.zuul.yaml b/.zuul.yaml
index fd20909..cb78f83 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -2,3 +2,8 @@
     templates:
       - openstack-python3-charm-jobs
       - openstack-cover-jobs
+    check:
+      jobs:
+        - charmbuild
+    vars:
+      charm_build_name: cinder-backup
diff --git a/charmcraft.yaml b/charmcraft.yaml
index 35b6d04..195b5ad 100644
--- a/charmcraft.yaml
+++ b/charmcraft.yaml
@@ -18,13 +18,17 @@ parts:
       - metadata.yaml
       - README.md
 
-bases:
-  - build-on:
-      - name: ubuntu
-        channel: "22.04"
-        architectures:
-          - amd64
-    run-on:
-      - name: ubuntu
-        channel: "22.04"
-        architectures: [amd64, s390x, ppc64el, arm64]
+base: ubuntu@24.04
+platforms:
+ amd64:
+   build-on: amd64
+   build-for: amd64
+ arm64:
+   build-on: arm64
+   build-for: arm64
+ ppc64el:
+   build-on: ppc64el
+   build-for: ppc64el
+ s390x:
+   build-on: s390x
+   build-for: s390x
diff --git a/hooks/charmhelpers/core/host_factory/ubuntu.py b/hooks/charmhelpers/core/host_factory/ubuntu.py
index 732d76c..e87595e 100644
--- a/hooks/charmhelpers/core/host_factory/ubuntu.py
+++ b/hooks/charmhelpers/core/host_factory/ubuntu.py
@@ -33,6 +33,8 @@ UBUNTU_RELEASES = (
     'kinetic',
     'lunar',
     'mantic',
+    'noble',
+    'oracular',
 )
 
 
diff --git a/metadata.yaml b/metadata.yaml
index 8951b6d..7816897 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -7,8 +7,6 @@ description: |
   This subordinate charm configures the Cinder backup service.
 tags:
   - miscellaneous
-series:
-  - jammy
 subordinate: true
 provides:
   backup-backend:
diff --git a/osci.yaml b/osci.yaml
index 8d7181e..7dde6d9 100644
--- a/osci.yaml
+++ b/osci.yaml
@@ -6,4 +6,4 @@
       needs_charm_build: true
       charm_build_name: cinder-backup
       build_type: charmcraft
-      charmcraft_channel: 2.x/stable
+      charmcraft_channel: 3.x/stable
diff --git a/tests/bundles/jammy-antelope.yaml b/tests/bundles/jammy-antelope.yaml
deleted file mode 100644
index b28efce..0000000
--- a/tests/bundles/jammy-antelope.yaml
+++ /dev/null
@@ -1,178 +0,0 @@
-variables:
-  openstack-origin: &openstack-origin cloud:jammy-antelope
-
-series: jammy
-
-comment:
-- 'machines section to decide order of deployment. database sooner = faster'
-machines:
-  '0':
-    constraints: mem=3072M
-  '1':
-    constraints: mem=3072M
-  '2':
-    constraints: mem=3072M
-  '3':
-  '4':
-  '5':
-  '6':
-  '7':
-  '8':
-  '9':
-  '10':
-  '11':
-  '12':
-  '13':
-
-applications:
-
-  keystone-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  cinder-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  glance-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-
-  mysql-innodb-cluster:
-    charm: ch:mysql-innodb-cluster
-    num_units: 3
-    to:
-      - '0'
-      - '1'
-      - '2'
-    channel: latest/edge
-
-  keystone:
-    charm: ch:keystone
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '3'
-    channel: 2024.1/edge
-
-  rabbitmq-server:
-    charm: ch:rabbitmq-server
-    num_units: 1
-    to:
-      - '4'
-    channel: latest/edge
-
-  ceph-mon:
-    charm: ch:ceph-mon
-    num_units: 3
-    options:
-      monitor-count: '3'
-      source: *openstack-origin
-    to:
-      - '5'
-      - '6'
-      - '7'
-    channel: reef/edge
-
-  ceph-osd:
-    charm: ch:ceph-osd
-    num_units: 3
-    storage:
-      osd-devices: 'cinder,10G'
-    options:
-      osd-devices: '/dev/test-non-existent'
-      source: *openstack-origin
-    to:
-      - '8'
-      - '9'
-      - '10'
-    channel: reef/edge
-
-  cinder:
-    charm: ch:cinder
-    num_units: 1
-    options:
-      block-device: 'None'
-      glance-api-version: '2'
-      openstack-origin: *openstack-origin
-    to:
-      - '11'
-    channel: 2024.1/edge
-
-  cinder-backup:
-    charm: ../../cinder-backup.charm
-    options:
-      ceph-osd-replication-count: 3
-
-  cinder-ceph:
-    charm: ch:cinder-ceph
-    options:
-      ceph-osd-replication-count: 3
-    channel: 2024.1/edge
-
-  glance:
-    charm: ch:glance
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '12'
-    channel: 2024.1/edge
-
-  nova-compute:
-    charm: ch:nova-compute
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '13'
-    channel: 2024.1/edge
-
-relations:
-
-  - - 'cinder-backup:ceph'
-    - 'ceph-mon:client'
-
-  - - 'cinder-ceph:ceph'
-    - 'ceph-mon:client'
-
-  - - 'ceph-osd:mon'
-    - 'ceph-mon:osd'
-
-  - - 'cinder:storage-backend'
-    - 'cinder-ceph:storage-backend'
-
-  - - 'cinder:backup-backend'
-    - 'cinder-backup:backup-backend'
-
-  - - 'keystone:shared-db'
-    - 'keystone-mysql-router:shared-db'
-  - - 'keystone-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:shared-db'
-    - 'cinder-mysql-router:shared-db'
-  - - 'cinder-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'cinder:amqp'
-    - 'rabbitmq-server:amqp'
-
-  - - 'glance:image-service'
-    - 'nova-compute:image-service'
-
-  - - 'glance:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'glance:shared-db'
-    - 'glance-mysql-router:shared-db'
-  - - 'glance-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'nova-compute:ceph-access'
-    - 'cinder-ceph:ceph-access'
-
-  - - 'nova-compute:amqp'
-    - 'rabbitmq-server:amqp'
diff --git a/tests/bundles/jammy-bobcat.yaml b/tests/bundles/jammy-bobcat.yaml
deleted file mode 100644
index 475b41a..0000000
--- a/tests/bundles/jammy-bobcat.yaml
+++ /dev/null
@@ -1,178 +0,0 @@
-variables:
-  openstack-origin: &openstack-origin cloud:jammy-bobcat
-
-series: jammy
-
-comment:
-- 'machines section to decide order of deployment. database sooner = faster'
-machines:
-  '0':
-    constraints: mem=3072M
-  '1':
-    constraints: mem=3072M
-  '2':
-    constraints: mem=3072M
-  '3':
-  '4':
-  '5':
-  '6':
-  '7':
-  '8':
-  '9':
-  '10':
-  '11':
-  '12':
-  '13':
-
-applications:
-
-  keystone-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  cinder-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  glance-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-
-  mysql-innodb-cluster:
-    charm: ch:mysql-innodb-cluster
-    num_units: 3
-    to:
-      - '0'
-      - '1'
-      - '2'
-    channel: latest/edge
-
-  keystone:
-    charm: ch:keystone
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '3'
-    channel: 2024.1/edge
-
-  rabbitmq-server:
-    charm: ch:rabbitmq-server
-    num_units: 1
-    to:
-      - '4'
-    channel: latest/edge
-
-  ceph-mon:
-    charm: ch:ceph-mon
-    num_units: 3
-    options:
-      monitor-count: '3'
-      source: *openstack-origin
-    to:
-      - '5'
-      - '6'
-      - '7'
-    channel: reef/edge
-
-  ceph-osd:
-    charm: ch:ceph-osd
-    num_units: 3
-    storage:
-      osd-devices: 'cinder,10G'
-    options:
-      osd-devices: '/dev/test-non-existent'
-      source: *openstack-origin
-    to:
-      - '8'
-      - '9'
-      - '10'
-    channel: reef/edge
-
-  cinder:
-    charm: ch:cinder
-    num_units: 1
-    options:
-      block-device: 'None'
-      glance-api-version: '2'
-      openstack-origin: *openstack-origin
-    to:
-      - '11'
-    channel: 2024.1/edge
-
-  cinder-backup:
-    charm: ../../cinder-backup.charm
-    options:
-      ceph-osd-replication-count: 3
-
-  cinder-ceph:
-    charm: ch:cinder-ceph
-    options:
-      ceph-osd-replication-count: 3
-    channel: 2024.1/edge
-
-  glance:
-    charm: ch:glance
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '12'
-    channel: 2024.1/edge
-
-  nova-compute:
-    charm: ch:nova-compute
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '13'
-    channel: 2024.1/edge
-
-relations:
-
-  - - 'cinder-backup:ceph'
-    - 'ceph-mon:client'
-
-  - - 'cinder-ceph:ceph'
-    - 'ceph-mon:client'
-
-  - - 'ceph-osd:mon'
-    - 'ceph-mon:osd'
-
-  - - 'cinder:storage-backend'
-    - 'cinder-ceph:storage-backend'
-
-  - - 'cinder:backup-backend'
-    - 'cinder-backup:backup-backend'
-
-  - - 'keystone:shared-db'
-    - 'keystone-mysql-router:shared-db'
-  - - 'keystone-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:shared-db'
-    - 'cinder-mysql-router:shared-db'
-  - - 'cinder-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'cinder:amqp'
-    - 'rabbitmq-server:amqp'
-
-  - - 'glance:image-service'
-    - 'nova-compute:image-service'
-
-  - - 'glance:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'glance:shared-db'
-    - 'glance-mysql-router:shared-db'
-  - - 'glance-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'nova-compute:ceph-access'
-    - 'cinder-ceph:ceph-access'
-
-  - - 'nova-compute:amqp'
-    - 'rabbitmq-server:amqp'
diff --git a/tests/bundles/jammy-caracal.yaml b/tests/bundles/jammy-caracal.yaml
deleted file mode 100644
index 6889bf7..0000000
--- a/tests/bundles/jammy-caracal.yaml
+++ /dev/null
@@ -1,178 +0,0 @@
-variables:
-  openstack-origin: &openstack-origin cloud:jammy-caracal
-
-series: jammy
-
-comment:
-- 'machines section to decide order of deployment. database sooner = faster'
-machines:
-  '0':
-    constraints: mem=3072M
-  '1':
-    constraints: mem=3072M
-  '2':
-    constraints: mem=3072M
-  '3':
-  '4':
-  '5':
-  '6':
-  '7':
-  '8':
-  '9':
-  '10':
-  '11':
-  '12':
-  '13':
-
-applications:
-
-  keystone-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  cinder-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-  glance-mysql-router:
-    charm: ch:mysql-router
-    channel: latest/edge
-
-  mysql-innodb-cluster:
-    charm: ch:mysql-innodb-cluster
-    num_units: 3
-    to:
-      - '0'
-      - '1'
-      - '2'
-    channel: latest/edge
-
-  keystone:
-    charm: ch:keystone
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '3'
-    channel: 2024.1/edge
-
-  rabbitmq-server:
-    charm: ch:rabbitmq-server
-    num_units: 1
-    to:
-      - '4'
-    channel: latest/edge
-
-  ceph-mon:
-    charm: ch:ceph-mon
-    num_units: 3
-    options:
-      monitor-count: '3'
-      source: *openstack-origin
-    to:
-      - '5'
-      - '6'
-      - '7'
-    channel: reef/edge
-
-  ceph-osd:
-    charm: ch:ceph-osd
-    num_units: 3
-    storage:
-      osd-devices: 'cinder,10G'
-    options:
-      osd-devices: '/dev/test-non-existent'
-      source: *openstack-origin
-    to:
-      - '8'
-      - '9'
-      - '10'
-    channel: reef/edge
-
-  cinder:
-    charm: ch:cinder
-    num_units: 1
-    options:
-      block-device: 'None'
-      glance-api-version: '2'
-      openstack-origin: *openstack-origin
-    to:
-      - '11'
-    channel: 2024.1/edge
-
-  cinder-backup:
-    charm: ../../cinder-backup.charm
-    options:
-      ceph-osd-replication-count: 3
-
-  cinder-ceph:
-    charm: ch:cinder-ceph
-    options:
-      ceph-osd-replication-count: 3
-    channel: 2024.1/edge
-
-  glance:
-    charm: ch:glance
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '12'
-    channel: 2024.1/edge
-
-  nova-compute:
-    charm: ch:nova-compute
-    num_units: 1
-    options:
-      openstack-origin: *openstack-origin
-    to:
-      - '13'
-    channel: 2024.1/edge
-
-relations:
-
-  - - 'cinder-backup:ceph'
-    - 'ceph-mon:client'
-
-  - - 'cinder-ceph:ceph'
-    - 'ceph-mon:client'
-
-  - - 'ceph-osd:mon'
-    - 'ceph-mon:osd'
-
-  - - 'cinder:storage-backend'
-    - 'cinder-ceph:storage-backend'
-
-  - - 'cinder:backup-backend'
-    - 'cinder-backup:backup-backend'
-
-  - - 'keystone:shared-db'
-    - 'keystone-mysql-router:shared-db'
-  - - 'keystone-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:shared-db'
-    - 'cinder-mysql-router:shared-db'
-  - - 'cinder-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'cinder:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'cinder:amqp'
-    - 'rabbitmq-server:amqp'
-
-  - - 'glance:image-service'
-    - 'nova-compute:image-service'
-
-  - - 'glance:identity-service'
-    - 'keystone:identity-service'
-
-  - - 'glance:shared-db'
-    - 'glance-mysql-router:shared-db'
-  - - 'glance-mysql-router:db-router'
-    - 'mysql-innodb-cluster:db-router'
-
-  - - 'nova-compute:ceph-access'
-    - 'cinder-ceph:ceph-access'
-
-  - - 'nova-compute:amqp'
-    - 'rabbitmq-server:amqp'
diff --git a/tests/bundles/noble-caracal.yaml b/tests/bundles/noble-caracal.yaml
index acb6032..f81ce94 100644
--- a/tests/bundles/noble-caracal.yaml
+++ b/tests/bundles/noble-caracal.yaml
@@ -52,7 +52,7 @@ applications:
       openstack-origin: *openstack-origin
     to:
       - '3'
-    channel: 2024.1/edge
+    channel: latest/edge
 
   rabbitmq-server:
     charm: ch:rabbitmq-server
@@ -71,7 +71,7 @@ applications:
       - '5'
       - '6'
       - '7'
-    channel: reef/edge
+    channel: latest/edge
 
   ceph-osd:
     charm: ch:ceph-osd
@@ -85,7 +85,7 @@ applications:
       - '8'
       - '9'
       - '10'
-    channel: reef/edge
+    channel: latest/edge
 
   cinder:
     charm: ch:cinder
@@ -96,7 +96,7 @@ applications:
       openstack-origin: *openstack-origin
     to:
       - '11'
-    channel: 2024.1/edge
+    channel: latest/edge
 
   cinder-backup:
     charm: ../../cinder-backup.charm
@@ -107,7 +107,7 @@ applications:
     charm: ch:cinder-ceph
     options:
       ceph-osd-replication-count: 3
-    channel: 2024.1/edge
+    channel: latest/edge
 
   glance:
     charm: ch:glance
@@ -116,7 +116,7 @@ applications:
       openstack-origin: *openstack-origin
     to:
       - '12'
-    channel: 2024.1/edge
+    channel: latest/edge
 
   nova-compute:
     charm: ch:nova-compute
@@ -125,7 +125,7 @@ applications:
       openstack-origin: *openstack-origin
     to:
       - '13'
-    channel: 2024.1/edge
+    channel: latest/edge
 
 relations:
 
diff --git a/tests/tests.yaml b/tests/tests.yaml
index f7e7fdf..3909763 100644
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -1,11 +1,9 @@
 charm_name: cinder-backup
 
 smoke_bundles:
-  - jammy-caracal
+  - noble-caracal
 gate_bundles:
-  - jammy-antelope
-  - jammy-bobcat
-  - jammy-caracal
+  - noble-caracal
 dev_bundles:
   - noble-caracal
 tests:
diff --git a/tox.ini b/tox.ini
index 1c768a8..1b9c23d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -34,6 +34,7 @@ minversion = 3.18.0
 setenv = VIRTUAL_ENV={envdir}
          PYTHONHASHSEED=0
          CHARM_DIR={envdir}
+	 TEST_JUJU3=1  # Note(mylesjp): Force Juju 3
 commands = stestr run --slowest {posargs}
 allowlist_externals =
     charmcraft
@@ -45,7 +46,7 @@ passenv =
     OS_*
     TEST_*
 deps =
-    -c {env:TEST_CONSTRAINTS_FILE:https://raw.githubusercontent.com/openstack-charmers/zaza-openstack-tests/master/constraints/constraints-2024.1.txt}
+    -c {env:TEST_CONSTRAINTS_FILE:https://raw.githubusercontent.com/openstack-charmers/zaza-openstack-tests/master/constraints/constraints-noble.txt}
     -r{toxinidir}/test-requirements.txt
 
 [testenv:build]