Migrate percona-cluster to charmcraft build

- add *.charm  to .gitignore
- add build-requirements.txt
- add charmcraft.yaml (build on 18.04, run on 18.04)
- modify osci.yaml to do build
- add rename.sh to clean-up naming of charms
- modify bundles to work with *.charm and use the charmhub
- modify tox.ini to include the build target

Note that this charm doesn't officially support xenial, but the bundle
has been left in the tests for debugging/test purposes.  It Launchpad it
will be build on bionic to run on bionic.

This patch adds *.charm to the .gitignore to ensure that any built
artifacts are ignored.

Change-Id: Icd4942262a8dfcd3a194684571861121d92f8ed2
This commit is contained in:
Alex Kavanagh 2022-04-18 20:59:55 +01:00 committed by Billy Olsen
parent 6ff8acbd6a
commit 6751832bb6
10 changed files with 91 additions and 25 deletions

3
.gitignore vendored
View File

@ -11,3 +11,6 @@ __pycache__
.stestr
.unit-state.db
func-results.json
*.charm

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.

33
charmcraft.yaml Normal file
View File

@ -0,0 +1,33 @@
type: charm
parts:
charm:
plugin: dump
source: .
prime:
- actions/*
- charmhelpers/*
- files/*
- hooks/*
- lib/*
- ocf/*
- scripts/*
- templates/*
- actions.yaml
- config.yaml
- copyright
- hardening.yaml
- Makefile
- metadata.yaml
- README.md
bases:
- build-on:
- name: ubuntu
channel: "18.04"
architectures:
- amd64
run-on:
- name: ubuntu
channel: "18.04"
architectures: [amd64, s390x, ppc64el, arm64]

View File

@ -1,9 +1,13 @@
- project:
templates:
- charm-yoga-unit-jobs
- charm-unit-jobs-py36
check:
jobs:
- bionic_model-bionic-ha
vars:
needs_charm_build: true
charm_build_name: percona-cluster
build_type: charmcraft
- job:
name: bionic_model-bionic-ha
@ -11,7 +15,5 @@
dependencies:
- osci-lint
- tox-py36
- tox-py38
- tox-py39
vars:
tox_extra_args: bionic_model:bionic-ha

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

@ -3,19 +3,20 @@ series: bionic
applications:
percona-cluster:
series: bionic
charm: ../../../percona-cluster
charm: ../../percona-cluster.charm
num_units: 1
keystone:
charm: cs:~openstack-charmers-next/keystone
charm: ch:keystone
channel: queens/edge
num_units: 1
options:
token-expiration: 60
nagios:
charm: cs:nagios
charm: ch:nagios
series: bionic
num_units: 1
nrpe:
charm: cs:nrpe
charm: ch:nrpe
relations:
- - keystone:shared-db

View File

@ -5,10 +5,11 @@ relations:
applications:
percona-cluster:
series: bionic
charm: ../../../percona-cluster
charm: ../../percona-cluster.charm
num_units: 1
keystone:
charm: cs:~openstack-charmers-next/keystone
charm: ch:keystone
channel: queens/edge
num_units: 1
options:
token-expiration: 60

View File

@ -9,7 +9,8 @@ applications:
vip: {{ TEST_VIP00 }}
min-cluster-size: 3
hacluster:
charm: cs:~openstack-charmers-next/hacluster
charm: ch:hacluster
channel: 1.1.18/edge
num_units: 0
options:
cluster_count: 3

View File

@ -5,10 +5,12 @@ relations:
applications:
percona-cluster:
series: xenial
charm: ../../../percona-cluster
charm: ../../percona-cluster.charm
num_units: 1
keystone:
charm: cs:~openstack-charmers-next/keystone
charm: ch:keystone
channel: queens/edge
series: xenial
num_units: 1
options:
openstack-origin: cloud:xenial-queens

29
tox.ini
View File

@ -37,12 +37,22 @@ setenv = VIRTUAL_ENV={envdir}
install_command =
{toxinidir}/pip.sh install {opts} {packages}
commands = stestr run --slowest {posargs}
allowlist_externals = juju
allowlist_externals =
charmcraft
rename.sh
passenv = HOME TERM CS_* OS_* TEST_*
deps = -r{toxinidir}/test-requirements.txt
[testenv:py35]
basepython = python3.5
[testenv:build]
basepython = python3
deps = -r{toxinidir}/build-requirements.txt
commands =
charmcraft clean
charmcraft -v build
{toxinidir}/rename.sh
[testenv:py3]
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
@ -50,26 +60,19 @@ deps = -r{toxinidir}/requirements.txt
basepython = python3.6
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:py37]
basepython = python3.7
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py38]
basepython = python3.8
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py39]
basepython = python3.9
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:py3]
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:pep8]
basepython = python3