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>.charm artifact in tests.
  and fix deprecation warning re: prefix
- tox inception to enable tox -e func-test in the CI

Change-Id: Id14cd0d06f6c98c02d1cffb30c2cd4fe73ed5691
This commit is contained in:
Alex Kavanagh 2022-02-01 20:13:54 +00:00
parent 1f2aea2399
commit 1399f22e66
12 changed files with 92 additions and 17 deletions

7
build-requirements.txt Normal file
View File

@ -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.

View File

@ -2,9 +2,21 @@ type: charm
parts: parts:
charm: charm:
source: src/ build-packages:
plugin: reactive - tox
build-snaps: [charm] - 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: bases:
- name: ubuntu - name: ubuntu

View File

@ -7,3 +7,4 @@
vars: vars:
needs_charm_build: true needs_charm_build: true
charm_build_name: keystone-saml-mellon charm_build_name: keystone-saml-mellon
build_type: charmcraft

13
rename.sh Executable file
View File

@ -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

View File

@ -4,6 +4,9 @@
# https://github.com/openstack-charmers/release-tools # 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!) # 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.git#egg=zaza
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack

View File

@ -1,6 +1,8 @@
variables: variables:
openstack-origin: &openstack-origin cloud:focal-xena openstack-origin: &openstack-origin cloud:focal-xena
local_overlay_enabled: False
series: focal series: focal
comment: comment:
@ -192,7 +194,7 @@ applications:
keystone-saml-mellon1: keystone-saml-mellon1:
series: focal series: focal
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp1' idp-name: 'test-saml-idp1'
@ -212,7 +214,7 @@ applications:
keystone-saml-mellon2: keystone-saml-mellon2:
series: focal series: focal
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp2' idp-name: 'test-saml-idp2'

View File

@ -1,6 +1,8 @@
variables: variables:
openstack-origin: &openstack-origin cloud:focal-yoga openstack-origin: &openstack-origin cloud:focal-yoga
local_overlay_enabled: False
series: focal series: focal
comment: comment:
@ -192,7 +194,7 @@ applications:
keystone-saml-mellon1: keystone-saml-mellon1:
series: focal series: focal
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp1' idp-name: 'test-saml-idp1'
@ -212,7 +214,7 @@ applications:
keystone-saml-mellon2: keystone-saml-mellon2:
series: focal series: focal
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp2' idp-name: 'test-saml-idp2'

View File

@ -1,6 +1,8 @@
variables: variables:
openstack-origin: &openstack-origin distro openstack-origin: &openstack-origin distro
local_overlay_enabled: False
series: impish series: impish
comment: comment:
@ -193,7 +195,7 @@ applications:
keystone-saml-mellon1: keystone-saml-mellon1:
series: groovy series: groovy
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp1' idp-name: 'test-saml-idp1'
@ -214,7 +216,7 @@ applications:
keystone-saml-mellon2: keystone-saml-mellon2:
series: groovy series: groovy
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp2' idp-name: 'test-saml-idp2'

View File

@ -1,6 +1,8 @@
variables: variables:
openstack-origin: &openstack-origin distro openstack-origin: &openstack-origin distro
local_overlay_enabled: False
series: jammy series: jammy
comment: comment:
@ -193,7 +195,7 @@ applications:
keystone-saml-mellon1: keystone-saml-mellon1:
series: groovy series: groovy
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp1' idp-name: 'test-saml-idp1'
@ -214,7 +216,7 @@ applications:
keystone-saml-mellon2: keystone-saml-mellon2:
series: groovy series: groovy
charm: ../../../keystone-saml-mellon charm: ../../../keystone-saml-mellon.charm
num_units: 0 num_units: 0
options: options:
idp-name: 'test-saml-idp2' idp-name: 'test-saml-idp2'

View File

@ -31,10 +31,10 @@ tests:
target_deploy_status: target_deploy_status:
ntp: ntp:
workload-status: active workload-status: active
workload-status-message: "chrony: Ready" workload-status-message-prefix: "chrony: Ready"
vault: vault:
workload-status: blocked workload-status: blocked
workload-status-message: Vault needs to be initialized workload-status-message-prefix: Vault needs to be initialized
keystone-saml-mellon: keystone-saml-mellon:
# NOTE(lourot): because this is the charm name, Zaza automatically # NOTE(lourot): because this is the charm name, Zaza automatically
# deploys this application with no unit, although we don't mention it in # deploys this application with no unit, although we don't mention it in
@ -42,16 +42,16 @@ target_deploy_status:
num-expected-units: 0 num-expected-units: 0
keystone-saml-mellon1: keystone-saml-mellon1:
workload-status: blocked workload-status: blocked
workload-status-message: "Configuration is incomplete. idp-metadata: idp-metadata resource has not been provided,sp-signing-keyinfo: sp-signing-keyinfo resource has not been provided,sp-private-key: sp-private-key resource has not been provided" workload-status-message-prefix: "Configuration is incomplete. idp-metadata: idp-metadata resource has not been provided,sp-signing-keyinfo: sp-signing-keyinfo resource has not been provided,sp-private-key: sp-private-key resource has not been provided"
test-saml-idp1: test-saml-idp1:
workload-status: blocked workload-status: blocked
workload-status-message: "sp-metadata resource is not a well-formed xml file" workload-status-message-prefix: "sp-metadata resource is not a well-formed xml file"
keystone-saml-mellon2: keystone-saml-mellon2:
workload-status: blocked workload-status: blocked
workload-status-message: "Configuration is incomplete. idp-metadata: idp-metadata resource has not been provided,sp-signing-keyinfo: sp-signing-keyinfo resource has not been provided,sp-private-key: sp-private-key resource has not been provided" workload-status-message-prefix: "Configuration is incomplete. idp-metadata: idp-metadata resource has not been provided,sp-signing-keyinfo: sp-signing-keyinfo resource has not been provided,sp-private-key: sp-private-key resource has not been provided"
test-saml-idp2: test-saml-idp2:
workload-status: blocked workload-status: blocked
workload-status-message: "sp-metadata resource is not a well-formed xml file" workload-status-message-prefix: "sp-metadata resource is not a well-formed xml file"
tests_options: tests_options:
force_deploy: force_deploy:

View File

@ -28,6 +28,11 @@ oslo.utils<=3.41.0;python_version<'3.6'
requests>=2.18.4 requests>=2.18.4
charms.reactive 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 nose>=1.3.7
coverage>=3.6 coverage>=3.6
git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack 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 cryptography<3.4 # vault, keystone-saml-mellon
lxml # keystone-saml-mellon lxml # keystone-saml-mellon
hvac # vault, barbican-vault hvac # vault, barbican-vault
psutil # cinder-lvm

25
tox.ini
View File

@ -37,11 +37,24 @@ setenv = VIRTUAL_ENV={envdir}
passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY
install_command = install_command =
{toxinidir}/pip.sh install {opts} {packages} {toxinidir}/pip.sh install {opts} {packages}
allowlist_externals =
charmcraft
bash
tox
rename.sh
deps = deps =
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
[testenv:build] [testenv:build]
basepython = python3 basepython = python3
deps = -r{toxinidir}/build-requirements.txt
commands =
charmcraft clean
charmcraft -v build
{toxinidir}/rename.sh
[testenv:build-reactive]
basepython = python3
commands = commands =
charm-build --log-level DEBUG --use-lock-file-branches -o {toxinidir}/build/builds src {posargs} 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 charm-tools==2.8.3
commands = flake8 {posargs} src unit_tests 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] [testenv:cover]
# Technique based heavily upon # Technique based heavily upon
# https://github.com/openstack/nova/blob/master/tox.ini # https://github.com/openstack/nova/blob/master/tox.ini