From a8d8eb51229ad6471ba732e5368a9fc5fbb6ddfa Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Tue, 1 Feb 2022 20:33:57 +0000 Subject: [PATCH] Update to build using charmcraft Due to a build problem with the reactive plugin, this change falls back on overriding the steps and doing a manual build, but it also ensures the CI system builds the charm using charmcraft. Changes: - add a build-requirements.txt - modify charmcraft.yaml - modify osci.yaml -> indicate build with charmcraft - modify tox.ini -> tox -e build does charmcraft build/rename -> tox -e build-reactive does the reactive build - modify bundles to use the .charm artifact in tests. and fix deprecation warning re: prefix - tox inception to enable tox -e func-test in the CI Change-Id: Ida2665d20845e20b51f3270870ad9cf55a824921 --- build-requirements.txt | 7 +++++++ charmcraft.yaml | 18 ++++++++++++++--- osci.yaml | 1 + rename.sh | 13 ++++++++++++ src/test-requirements.txt | 3 +++ src/tests/bundles/focal-xena.yaml | 32 ++++++++++++++++-------------- src/tests/bundles/focal-yoga.yaml | 32 ++++++++++++++++-------------- src/tests/bundles/impish-xena.yaml | 32 ++++++++++++++++-------------- src/tests/bundles/jammy-yoga.yaml | 32 ++++++++++++++++-------------- src/tests/tests.yaml | 12 +++++------ test-requirements.txt | 6 ++++++ tox.ini | 25 +++++++++++++++++++++++ 12 files changed, 144 insertions(+), 69 deletions(-) create mode 100644 build-requirements.txt create mode 100755 rename.sh diff --git a/build-requirements.txt b/build-requirements.txt new file mode 100644 index 0000000..b6d2452 --- /dev/null +++ b/build-requirements.txt @@ -0,0 +1,7 @@ +# 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 index a850351..4968216 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -2,9 +2,21 @@ type: charm parts: charm: - source: src/ - plugin: reactive - build-snaps: [charm] + build-packages: + - tox + - git + - python3-dev + override-build: | + apt-get install ca-certificates -y + tox -e build-reactive + override-stage: | + echo "Copying charm to staging area: $CHARMCRAFT_STAGE" + NAME=$(ls $CHARMCRAFT_PART_BUILD/build/builds) + cp -r $CHARMCRAFT_PART_BUILD/build/builds/$NAME/* $CHARMCRAFT_STAGE/ + override-prime: | + # For some reason, the normal priming chokes on the fact that there's a + # hooks directory. + cp -r $CHARMCRAFT_STAGE/* . bases: - name: ubuntu diff --git a/osci.yaml b/osci.yaml index 7c8351c..128ed93 100644 --- a/osci.yaml +++ b/osci.yaml @@ -7,3 +7,4 @@ vars: needs_charm_build: true charm_build_name: masakari-monitors + build_type: charmcraft 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/src/test-requirements.txt b/src/test-requirements.txt index e771023..9c7afb7 100644 --- a/src/test-requirements.txt +++ b/src/test-requirements.txt @@ -4,6 +4,9 @@ # https://github.com/openstack-charmers/release-tools # +# Need tox to be available from tox... inception yes, but its a workaround for now +tox + # Functional Test Requirements (let Zaza's dependencies solve all dependencies here!) git+https://github.com/openstack-charmers/zaza.git#egg=zaza git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack diff --git a/src/tests/bundles/focal-xena.yaml b/src/tests/bundles/focal-xena.yaml index 8b25ae0..7640735 100644 --- a/src/tests/bundles/focal-xena.yaml +++ b/src/tests/bundles/focal-xena.yaml @@ -1,6 +1,8 @@ variables: openstack-origin: &openstack-origin cloud:focal-xena +local_overlay_enabled: False + series: focal comment: @@ -83,7 +85,7 @@ applications: worker-multiplier: 0.25 to: - '3' - channel: latest/edge + channel: yoga/edge cinder: charm: ch:cinder @@ -94,7 +96,7 @@ applications: glance-api-version: 2 to: - '4' - channel: latest/edge + channel: yoga/edge keystone: charm: ch:keystone @@ -105,7 +107,7 @@ applications: worker-multiplier: 0.25 to: - '5' - channel: latest/edge + channel: yoga/edge neutron-api: charm: ch:neutron-api @@ -118,7 +120,7 @@ applications: worker-multiplier: 0.25 to: - '6' - channel: latest/edge + channel: yoga/edge neutron-gateway: charm: ch:neutron-gateway @@ -129,12 +131,12 @@ applications: worker-multiplier: 0.25 to: - '7' - channel: latest/edge + channel: yoga/edge neutron-openvswitch: charm: ch:neutron-openvswitch num_units: 0 - channel: latest/edge + channel: yoga/edge nova-cloud-controller: charm: ch:nova-cloud-controller @@ -146,7 +148,7 @@ applications: debug: true to: - '23' - channel: latest/edge + channel: yoga/edge nova-compute: charm: ch:nova-compute @@ -167,7 +169,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: yoga/edge rabbitmq-server: charm: ch:rabbitmq-server @@ -185,7 +187,7 @@ applications: - '12' - '13' - '14' - channel: latest/edge + channel: yoga/edge ceph-mon: charm: ch:ceph-mon @@ -197,7 +199,7 @@ applications: - '15' - '16' - '17' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -211,14 +213,14 @@ applications: - '18' - '19' - '20' - channel: latest/edge + channel: quincy/edge cinder-ceph: charm: ch:cinder-ceph - channel: latest/edge + channel: yoga/edge masakari-monitors: - charm: ../../masakari-monitors + charm: ../../../masakari-monitors.charm hacluster: charm: ch:hacluster @@ -228,7 +230,7 @@ applications: channel: latest/edge pacemaker-remote: - charm: cs:~openstack-charmers-next/pacemaker-remote + charm: ch:pacemaker-remote options: enable-stonith: False enable-resources: False @@ -247,7 +249,7 @@ applications: openstack-origin: *openstack-origin to: - '22' - channel: latest/edge + channel: yoga/edge relations: diff --git a/src/tests/bundles/focal-yoga.yaml b/src/tests/bundles/focal-yoga.yaml index 776c22a..6ff7db9 100644 --- a/src/tests/bundles/focal-yoga.yaml +++ b/src/tests/bundles/focal-yoga.yaml @@ -1,6 +1,8 @@ variables: openstack-origin: &openstack-origin cloud:focal-yoga +local_overlay_enabled: False + series: focal comment: @@ -83,7 +85,7 @@ applications: worker-multiplier: 0.25 to: - '3' - channel: latest/edge + channel: yoga/edge cinder: charm: ch:cinder @@ -94,7 +96,7 @@ applications: glance-api-version: 2 to: - '4' - channel: latest/edge + channel: yoga/edge keystone: charm: ch:keystone @@ -105,7 +107,7 @@ applications: worker-multiplier: 0.25 to: - '5' - channel: latest/edge + channel: yoga/edge neutron-api: charm: ch:neutron-api @@ -118,7 +120,7 @@ applications: worker-multiplier: 0.25 to: - '6' - channel: latest/edge + channel: yoga/edge neutron-gateway: charm: ch:neutron-gateway @@ -129,12 +131,12 @@ applications: worker-multiplier: 0.25 to: - '7' - channel: latest/edge + channel: yoga/edge neutron-openvswitch: charm: ch:neutron-openvswitch num_units: 0 - channel: latest/edge + channel: yoga/edge nova-cloud-controller: charm: ch:nova-cloud-controller @@ -146,7 +148,7 @@ applications: debug: true to: - '23' - channel: latest/edge + channel: yoga/edge nova-compute: charm: ch:nova-compute @@ -167,7 +169,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: yoga/edge rabbitmq-server: charm: ch:rabbitmq-server @@ -185,7 +187,7 @@ applications: - '12' - '13' - '14' - channel: latest/edge + channel: yoga/edge ceph-mon: charm: ch:ceph-mon @@ -197,7 +199,7 @@ applications: - '15' - '16' - '17' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -211,14 +213,14 @@ applications: - '18' - '19' - '20' - channel: latest/edge + channel: quincy/edge cinder-ceph: charm: ch:cinder-ceph - channel: latest/edge + channel: yoga/edge masakari-monitors: - charm: ../../masakari-monitors + charm: ../../../masakari-monitors.charm hacluster: charm: ch:hacluster @@ -228,7 +230,7 @@ applications: channel: latest/edge pacemaker-remote: - charm: cs:~openstack-charmers-next/pacemaker-remote + charm: ch:pacemaker-remote options: enable-stonith: False enable-resources: False @@ -247,7 +249,7 @@ applications: openstack-origin: *openstack-origin to: - '22' - channel: latest/edge + channel: yoga/edge relations: diff --git a/src/tests/bundles/impish-xena.yaml b/src/tests/bundles/impish-xena.yaml index 9d921ad..23c063a 100644 --- a/src/tests/bundles/impish-xena.yaml +++ b/src/tests/bundles/impish-xena.yaml @@ -1,6 +1,8 @@ variables: openstack-origin: &openstack-origin distro +local_overlay_enabled: False + series: impish comment: @@ -83,7 +85,7 @@ applications: worker-multiplier: 0.25 to: - '3' - channel: latest/edge + channel: yoga/edge cinder: charm: ch:cinder @@ -94,7 +96,7 @@ applications: glance-api-version: 2 to: - '4' - channel: latest/edge + channel: yoga/edge keystone: charm: ch:keystone @@ -105,7 +107,7 @@ applications: worker-multiplier: 0.25 to: - '5' - channel: latest/edge + channel: yoga/edge neutron-api: charm: ch:neutron-api @@ -118,7 +120,7 @@ applications: worker-multiplier: 0.25 to: - '6' - channel: latest/edge + channel: yoga/edge neutron-gateway: charm: ch:neutron-gateway @@ -129,12 +131,12 @@ applications: worker-multiplier: 0.25 to: - '7' - channel: latest/edge + channel: yoga/edge neutron-openvswitch: charm: ch:neutron-openvswitch num_units: 0 - channel: latest/edge + channel: yoga/edge nova-cloud-controller: charm: ch:nova-cloud-controller @@ -146,7 +148,7 @@ applications: debug: true to: - '23' - channel: latest/edge + channel: yoga/edge nova-compute: charm: ch:nova-compute @@ -167,7 +169,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: yoga/edge rabbitmq-server: charm: ch:rabbitmq-server @@ -185,7 +187,7 @@ applications: - '12' - '13' - '14' - channel: latest/edge + channel: yoga/edge ceph-mon: charm: ch:ceph-mon @@ -197,7 +199,7 @@ applications: - '15' - '16' - '17' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -211,14 +213,14 @@ applications: - '18' - '19' - '20' - channel: latest/edge + channel: quincy/edge cinder-ceph: charm: ch:cinder-ceph - channel: latest/edge + channel: yoga/edge masakari-monitors: - charm: ../../masakari-monitors + charm: ../../../masakari-monitors.charm hacluster: charm: ch:hacluster @@ -228,7 +230,7 @@ applications: channel: latest/edge pacemaker-remote: - charm: cs:~openstack-charmers-next/pacemaker-remote + charm: ch:pacemaker-remote options: enable-stonith: False enable-resources: False @@ -247,7 +249,7 @@ applications: openstack-origin: *openstack-origin to: - '22' - channel: latest/edge + channel: yoga/edge relations: diff --git a/src/tests/bundles/jammy-yoga.yaml b/src/tests/bundles/jammy-yoga.yaml index 621dceb..910ade9 100644 --- a/src/tests/bundles/jammy-yoga.yaml +++ b/src/tests/bundles/jammy-yoga.yaml @@ -1,6 +1,8 @@ variables: openstack-origin: &openstack-origin distro +local_overlay_enabled: False + series: jammy comment: @@ -83,7 +85,7 @@ applications: worker-multiplier: 0.25 to: - '3' - channel: latest/edge + channel: yoga/edge cinder: charm: ch:cinder @@ -94,7 +96,7 @@ applications: glance-api-version: 2 to: - '4' - channel: latest/edge + channel: yoga/edge keystone: charm: ch:keystone @@ -105,7 +107,7 @@ applications: worker-multiplier: 0.25 to: - '5' - channel: latest/edge + channel: yoga/edge neutron-api: charm: ch:neutron-api @@ -118,7 +120,7 @@ applications: worker-multiplier: 0.25 to: - '6' - channel: latest/edge + channel: yoga/edge neutron-gateway: charm: ch:neutron-gateway @@ -129,12 +131,12 @@ applications: worker-multiplier: 0.25 to: - '7' - channel: latest/edge + channel: yoga/edge neutron-openvswitch: charm: ch:neutron-openvswitch num_units: 0 - channel: latest/edge + channel: yoga/edge nova-cloud-controller: charm: ch:nova-cloud-controller @@ -146,7 +148,7 @@ applications: debug: true to: - '23' - channel: latest/edge + channel: yoga/edge nova-compute: charm: ch:nova-compute @@ -167,7 +169,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: yoga/edge rabbitmq-server: charm: ch:rabbitmq-server @@ -185,7 +187,7 @@ applications: - '12' - '13' - '14' - channel: latest/edge + channel: yoga/edge ceph-mon: charm: ch:ceph-mon @@ -197,7 +199,7 @@ applications: - '15' - '16' - '17' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -211,14 +213,14 @@ applications: - '18' - '19' - '20' - channel: latest/edge + channel: quincy/edge cinder-ceph: charm: ch:cinder-ceph - channel: latest/edge + channel: yoga/edge masakari-monitors: - charm: ../../masakari-monitors + charm: ../../../masakari-monitors.charm hacluster: charm: ch:hacluster @@ -228,7 +230,7 @@ applications: channel: latest/edge pacemaker-remote: - charm: cs:~openstack-charmers-next/pacemaker-remote + charm: ch:pacemaker-remote options: enable-stonith: False enable-resources: False @@ -247,7 +249,7 @@ applications: openstack-origin: *openstack-origin to: - '22' - channel: latest/edge + channel: yoga/edge relations: diff --git a/src/tests/tests.yaml b/src/tests/tests.yaml index a418888..c0187df 100644 --- a/src/tests/tests.yaml +++ b/src/tests/tests.yaml @@ -27,20 +27,20 @@ smoke_bundles: target_deploy_status: easyrsa: - workload-status-message: Certificate Authority connected. + workload-status-message-prefix: Certificate Authority connected. etcd: - workload-status-message: Healthy + workload-status-message-prefix: Healthy postgresql: - workload-status-message: Live + workload-status-message-prefix: Live vault: workload-status: blocked - workload-status-message: Vault needs to be initialized + workload-status-message-prefix: Vault needs to be initialized ceph-osd: workload-status: waiting - workload-status-message: "Incomplete relation: vault" + workload-status-message-prefix: "Incomplete relation: vault" ceph-mon: workload-status: waiting - workload-status-message: "Monitor bootstrapped but waiting for number of OSDs to reach expected-osd-count (3)" + workload-status-message-prefix: "Monitor bootstrapped but waiting for number of OSDs to reach expected-osd-count (3)" tests_options: force_deploy: diff --git a/test-requirements.txt b/test-requirements.txt index 208032f..a11a7d0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -28,6 +28,11 @@ oslo.utils<=3.41.0;python_version<'3.6' requests>=2.18.4 charms.reactive +# Newer mock seems to have some syntax which is newer than python3.5 (e.g. +# f'{something}' +mock>=1.2,<4.0.0; python_version < '3.6' +mock>=1.2; python_version >= '3.6' + nose>=1.3.7 coverage>=3.6 git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack @@ -46,3 +51,4 @@ pbr==5.6.0 # vault cryptography<3.4 # vault, keystone-saml-mellon lxml # keystone-saml-mellon hvac # vault, barbican-vault +psutil # cinder-lvm diff --git a/tox.ini b/tox.ini index faf6092..2d60b8a 100644 --- a/tox.ini +++ b/tox.ini @@ -37,11 +37,24 @@ setenv = VIRTUAL_ENV={envdir} passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY install_command = {toxinidir}/pip.sh install {opts} {packages} +allowlist_externals = + charmcraft + bash + tox + rename.sh deps = -r{toxinidir}/requirements.txt [testenv:build] basepython = python3 +deps = -r{toxinidir}/build-requirements.txt +commands = + charmcraft clean + charmcraft -v build + {toxinidir}/rename.sh + +[testenv:build-reactive] +basepython = python3 commands = charm-build --log-level DEBUG --use-lock-file-branches -o {toxinidir}/build/builds src {posargs} @@ -86,6 +99,18 @@ deps = flake8==3.9.2 charm-tools==2.8.3 commands = flake8 {posargs} src unit_tests +[testenv:func-target] +# Hack to get functional tests working in the charmcraft +# world. We should fix this. +basepython = python3 +passenv = HOME TERM CS_* OS_* TEST_* +deps = -r{toxinidir}/src/test-requirements.txt +changedir = {toxinidir}/src +commands = + bash -c "if [ ! -f ../*.charm ]; then echo 'Charm does not exist. Run tox -e build'; exit 1; fi" + tox --version + tox -e func-target {posargs} + [testenv:cover] # Technique based heavily upon # https://github.com/openstack/nova/blob/master/tox.ini