From dc2171c0b285d39bdb8253cefb71fa38a6c5a970 Mon Sep 17 00:00:00 2001 From: Aurelien Lourot Date: Mon, 7 Feb 2022 15:24:07 +0100 Subject: [PATCH] Migrate to charmhub Change-Id: I2caffbca2b6a1a6661831c6771fe4b7d45deddd3 --- build-requirements.txt | 8 +++++- charmcraft.yaml | 27 +++++++++++++++++++ osci.yaml | 8 +++--- rename.sh | 13 +++++++++ tests/README.md | 19 +++++++++++++ tests/bundles/focal-ec.yaml | 17 ++++++++---- tests/bundles/focal.yaml | 17 ++++++++---- .../overlays/local-charm-overlay.yaml.j2 | 3 --- tests/tests.yaml | 4 +-- tox.ini | 17 ++++++++++-- unit_tests/test_ceph_iscsi_charm.py | 14 +++------- 11 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 charmcraft.yaml create mode 100755 rename.sh create mode 100644 tests/README.md delete mode 100644 tests/bundles/overlays/local-charm-overlay.yaml.j2 diff --git a/build-requirements.txt b/build-requirements.txt index 271d895..b6d2452 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1 +1,7 @@ -git+https://github.com/canonical/charmcraft.git@0.10.2#egg=charmcraft +# NOTES(lourot): +# * We don't install charmcraft via pip anymore because it anyway spins up a +# container and scp the system's charmcraft snap inside it. So the charmcraft +# snap is necessary on the system anyway. +# * `tox -e build` successfully validated with charmcraft 1.2.1 + +cffi==1.14.6; python_version < '3.6' # cffi 1.15.0 drops support for py35. diff --git a/charmcraft.yaml b/charmcraft.yaml new file mode 100644 index 0000000..7293321 --- /dev/null +++ b/charmcraft.yaml @@ -0,0 +1,27 @@ +type: charm + +parts: + charm: + after: + - update-certificates + charm-python-packages: + # NOTE(lourot): see + # * https://github.com/canonical/charmcraft/issues/551 + # * https://github.com/canonical/charmcraft/issues/632 + - setuptools < 58 + build-packages: + - git + + update-certificates: + plugin: nil + # See https://github.com/canonical/charmcraft/issues/658 + override-build: | + apt update + apt install -y ca-certificates + update-ca-certificates + +bases: + - name: ubuntu + channel: "20.04" + architectures: + - amd64 diff --git a/osci.yaml b/osci.yaml index d55a58f..04fd9c7 100644 --- a/osci.yaml +++ b/osci.yaml @@ -1,6 +1,7 @@ - project: templates: - - charm-unit-jobs + - charm-unit-jobs-py38 + - charm-unit-jobs-py39 check: jobs: - ceph-iscsi-focal-octopus @@ -13,11 +14,10 @@ name: ceph-iscsi-focal-octopus parent: func-target dependencies: + - charm-build - osci-lint - - tox-py35 - - tox-py36 - - tox-py37 - tox-py38 + - tox-py39 vars: tox_extra_args: focal - job: diff --git a/rename.sh b/rename.sh new file mode 100755 index 0000000..d0c35c9 --- /dev/null +++ b/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/tests/README.md b/tests/README.md new file mode 100644 index 0000000..31363ee --- /dev/null +++ b/tests/README.md @@ -0,0 +1,19 @@ +# Overview + +This directory provides Zaza test definitions and bundles to verify basic +deployment functionality from the perspective of this charm, its requirements +and its features, as exercised in a subset of the full OpenStack deployment +test bundle topology. + +Run the smoke tests with: + +```bash +cd ../ +tox -e build +cd tests/ +tox -e func-smoke +``` + +For full details on functional testing of OpenStack charms please refer to +the [functional testing](https://docs.openstack.org/charm-guide/latest/reference/testing.html#functional-testing) +section of the OpenStack Charm Guide. diff --git a/tests/bundles/focal-ec.yaml b/tests/bundles/focal-ec.yaml index 1dc9b33..a381c85 100644 --- a/tests/bundles/focal-ec.yaml +++ b/tests/bundles/focal-ec.yaml @@ -36,11 +36,13 @@ applications: pool-type: erasure-coded ec-profile-k: 4 ec-profile-m: 2 + # Use proposed until fix for #1883112 is backported + source: distro-proposed to: - '0' - '1' ceph-osd: - charm: cs:~openstack-charmers-next/ceph-osd + charm: ch:ceph-osd num_units: 6 storage: osd-devices: 'cinder,10G' @@ -53,8 +55,9 @@ applications: - '11' - '12' - '13' + channel: latest/edge ceph-mon: - charm: cs:~openstack-charmers-next/ceph-mon + charm: ch:ceph-mon num_units: 3 options: monitor-count: '3' @@ -62,20 +65,24 @@ applications: - '3' - '4' - '5' + channel: latest/edge vault: num_units: 1 - charm: cs:~openstack-charmers-next/vault + charm: ch:vault to: - '6' + channel: latest/edge mysql-innodb-cluster: - charm: cs:~openstack-charmers-next/mysql-innodb-cluster + charm: ch:mysql-innodb-cluster num_units: 3 to: - '8' - '9' - '10' + channel: latest/edge vault-mysql-router: - charm: cs:~openstack-charmers-next/mysql-router + charm: ch:mysql-router + channel: latest/edge relations: - - 'ceph-mon:client' - 'ceph-iscsi:ceph-client' diff --git a/tests/bundles/focal.yaml b/tests/bundles/focal.yaml index 2ee6e3c..ee42dbf 100644 --- a/tests/bundles/focal.yaml +++ b/tests/bundles/focal.yaml @@ -35,13 +35,15 @@ applications: num_units: 4 options: gateway-metadata-pool: iscsi-foo-metadata + # Use proposed until fix for #1883112 is backported + source: distro-proposed to: - '0' - '1' - '16' - '17' ceph-osd: - charm: cs:~openstack-charmers-next/ceph-osd + charm: ch:ceph-osd num_units: 6 storage: osd-devices: 'cinder,10G' @@ -54,8 +56,9 @@ applications: - '11' - '12' - '13' + channel: latest/edge ceph-mon: - charm: cs:~openstack-charmers-next/ceph-mon + charm: ch:ceph-mon num_units: 3 options: monitor-count: '3' @@ -63,20 +66,24 @@ applications: - '3' - '4' - '5' + channel: latest/edge vault: num_units: 1 - charm: cs:~openstack-charmers-next/vault + charm: ch:vault to: - '6' + channel: latest/edge mysql-innodb-cluster: - charm: cs:~openstack-charmers-next/mysql-innodb-cluster + charm: ch:mysql-innodb-cluster num_units: 3 to: - '8' - '9' - '10' + channel: latest/edge vault-mysql-router: - charm: cs:~openstack-charmers-next/mysql-router + charm: ch:mysql-router + channel: latest/edge relations: - - 'ceph-mon:client' - 'ceph-iscsi:ceph-client' diff --git a/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/tests/bundles/overlays/local-charm-overlay.yaml.j2 deleted file mode 100644 index 5cbfaf2..0000000 --- a/tests/bundles/overlays/local-charm-overlay.yaml.j2 +++ /dev/null @@ -1,3 +0,0 @@ -applications: - ceph-iscsi: - charm: ../../ceph-iscsi.charm diff --git a/tests/tests.yaml b/tests/tests.yaml index d44445d..8ab33a0 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -13,7 +13,7 @@ tests: target_deploy_status: ubuntu: workload-status: active - workload-status-message: '' + workload-status-message-prefix: '' vault: workload-status: blocked - workload-status-message: Vault needs to be initialized + workload-status-message-prefix: Vault needs to be initialized diff --git a/tox.ini b/tox.ini index 775ea57..6081150 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,12 @@ skip_missing_interpreters = False # * It is also necessary to pin virtualenv as a newer virtualenv would still # lead to fetching the latest pip in the func* tox targets, see # https://stackoverflow.com/a/38133283 +# * It is necessary to declare setuptools as a dependency otherwise tox will +# fail very early at not being able to load it. The version pinning is in +# line with `pip.sh`. requires = pip < 20.3 virtualenv < 20.0 + setuptools < 50.0.0 # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci minversion = 3.2.0 @@ -27,10 +31,12 @@ setenv = VIRTUAL_ENV={envdir} install_command = pip install {opts} {packages} commands = stestr run --slowest {posargs} -whitelist_externals = +allowlist_externals = git add-to-archive.py bash + charmcraft + rename.sh passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt @@ -54,6 +60,11 @@ basepython = python3.8 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +[testenv:py39] +basepython = python3.9 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + [testenv:py3] basepython = python3 deps = -r{toxinidir}/requirements.txt @@ -101,7 +112,9 @@ commands = {posargs} basepython = python3 deps = -r{toxinidir}/build-requirements.txt commands = - charmcraft build + charmcraft clean + charmcraft -v build + {toxinidir}/rename.sh [testenv:func-noop] basepython = python3 diff --git a/unit_tests/test_ceph_iscsi_charm.py b/unit_tests/test_ceph_iscsi_charm.py index 9a37bac..850e999 100644 --- a/unit_tests/test_ceph_iscsi_charm.py +++ b/unit_tests/test_ceph_iscsi_charm.py @@ -195,14 +195,6 @@ class TestCephISCSIGatewayCharmBase(CharmTestCase): self.harness.add_relation_unit( rel_id, 'ceph-iscsi/1') - self.harness.update_relation_data( - rel_id, - 'ceph-iscsi/1', - { - 'ingress-address': '10.0.0.2', - 'gateway_ready': 'True', - 'gateway_fqdn': 'ceph-iscsi-1.example' - }) return rel_id def complete_cluster_relation(self, rel_id): @@ -231,7 +223,8 @@ class TestCephISCSIGatewayCharmBase(CharmTestCase): @patch('socket.getfqdn') def test_on_create_target_action(self, _getfqdn): _getfqdn.return_value = 'ceph-iscsi-0.example' - self.add_base_cluster_relation() + cluster_rel_id = self.add_base_cluster_relation() + self.complete_cluster_relation(cluster_rel_id) self.harness.begin() action_event = MagicMock() action_event.params = { @@ -276,7 +269,8 @@ class TestCephISCSIGatewayCharmBase(CharmTestCase): @patch('socket.getfqdn') def test_on_create_target_action_ec(self, _getfqdn): _getfqdn.return_value = 'ceph-iscsi-0.example' - self.add_base_cluster_relation() + cluster_rel_id = self.add_base_cluster_relation() + self.complete_cluster_relation(cluster_rel_id) self.harness.begin() action_event = MagicMock() action_event.params = {