Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New scripts for adding new release tests #234

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions add-new-release-batch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -e
#
# Add new release support including new bundles, updates to config.yaml,
# charmcraft.yaml, tests.yaml, osci.yaml, and .zuul.yaml using the
# add-new-release-single helper.

charms=$(cd charms && ls -d1 *)
basedir="$(pwd)"
prev_series_bundle=$1
prev_uca_bundle=$2
new_series_bundle=$3
new_uca_bundle=$4
new_ubuntu_version=$5
usage="usage: add-new-release-batch prev-series-bundle prev-uca-bundle new-series-bundle new-uca-bundle new-ubuntu-version"
example="example: add-new-release-batch jammy-yoga.yaml focal-yoga.yaml kinetic-zed.yaml jammy-zed.yaml 22.10"

if [[ -z "$prev_series_bundle" || -z "$prev_uca_bundle" || -z "$new_series_bundle" || -z "$new_uca_bundle" || -z "$new_ubuntu_version" ]]; then
echo $usage
echo $example
exit 1
fi

for charm in $charms; do
echo "===== $charm ====="
cd $basedir/charms/$charm
$basedir/add-new-release-single $prev_series_bundle $prev_uca_bundle $new_series_bundle $new_uca_bundle $new_ubuntu_version
done
172 changes: 172 additions & 0 deletions add-new-release-single
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/bin/bash -e
#
# Add new release support including new bundles, updates to config.yaml,
# charmcraft.yaml, tests.yaml, osci.yaml, and .zuul.yaml.

prev_series_bundle=$1
prev_uca_bundle=$2
new_series_bundle=$3
new_uca_bundle=$4
new_ubuntu_version=$5

charmcraft_yaml=$(find . -name charmcraft.yaml)
config_yaml=$(find . -name config.yaml)
osci_yaml=$(find . -name osci.yaml)
tests_yaml=$(find . -name tests.yaml)
zuul_yaml=$(find . -name .zuul.yaml)

usage="usage: add-new-release-batch prev-series-bundle prev-uca-bundle new-series-bundle new-uca-bundle new-ubuntu-version"
example="example: add-new-release-single jammy-yoga.yaml focal-yoga.yaml kinetic-zed.yaml jammy-zed.yaml 22.10"
if [[ -z "$prev_series_bundle" || -z "$prev_uca_bundle" || -z "$new_series_bundle" || -z "$new_uca_bundle" || -z "$new_ubuntu_version" ]]; then
echo $usage
echo $example
exit 1
fi

function get_series {
local bundle_path=$1
echo $bundle_path | sed 's/.*\/tests\/bundles\/\(.*\)\-.*.yaml/\1/1'
}

function get_release {
local bundle_path=$1
echo $bundle_path | sed 's/.*\/tests\/bundles\/\(.*\).yaml/\1/1'
}

function get_os_codename {
local bundle=$1
echo $bundle | sed 's/.*\-\(.*\)\.yaml/\1/1'
}

function create_new_bundle {
local prev_bundle=$1
local new_bundle=$2
local tests_yaml=$3

local prev_bundle_path=$(find . -name ${prev_bundle})
if [ -z $prev_bundle_path ]; then
echo "Bundle doesn't exist: ${prev_bundle}"
return
fi

local prev_series=$(get_series $prev_bundle_path)
local prev_release=$(get_release $prev_bundle_path)

local new_bundle_path=$(dirname $prev_bundle_path)/${new_bundle}
if [ -f $new_bundle_path ]; then
echo "Bundle already exists: ${new_bundle_path}"
return
fi

local new_series=$(get_series $new_bundle_path)
local new_release=$(get_release $new_bundle_path)

cp $prev_bundle_path $new_bundle_path

sed -i "s/${prev_release}/${new_release}/1" $new_bundle_path
sed -i "s/${prev_series}/${new_series}/1" $new_bundle_path
sed -i "s/\(.*\)${prev_release}\(.*\)/\1${prev_release}\2\n\1${new_release}\2/g" $tests_yaml

git add $new_bundle_path
}

function add_new_osci_job {
local osci_yaml=$1
local prev_os_codename=$2
local new_os_codename=$3

local prev_unit_job="charm-${prev_os_codename}-unit-jobs"
local new_unit_job="charm-${new_os_codename}-unit-jobs"
local prev_func_job="charm-${prev_os_codename}-functional-jobs"
local new_func_job="charm-${new_os_codename}-functional-jobs"

if grep -Fq "$new_unit_job" "$osci_yaml"; then
echo "Job $new_unit_job already exists in $osci_yaml"
return
fi

if grep -Fq "$new_func_job" "$osci_yaml"; then
echo "Job $new_func_job already exists in $osci_yaml"
return
fi

if grep -Fq "$prev_unit_job" "$osci_yaml"; then
sed -i "s/\(.*\)${prev_unit_job}\(.*\)/\1${prev_unit_job}\2\n\1${new_unit_job}\2/1" $osci_yaml
else
echo "Job $prev_unit_job doesn't exists in $osci_yaml"
fi

if grep -Fq "$prev_func_job" "$osci_yaml"; then
sed -i "s/\(.*\)${prev_func_job}\(.*\)/\1${prev_func_job}\2\n\1${new_func_job}\2/1" $osci_yaml
else
echo "Job $prev_func_job doesn't exists in $osci_yaml"
fi
}

function add_new_zuul_job {
local zuul_yaml=$1
local prev_os_codename=$2
local new_os_codename=$3

local prev_job="openstack-python3-charm-${prev_os_codename}-jobs"
local new_job="openstack-python3-charm-${new_os_codename}-jobs"

if grep -Fq "$new_job" "$zuul_yaml"; then
echo "Job $new_job already exists in $zuul_yaml"
return
fi

if grep -Fq "$prev_job" "$zuul_yaml"; then
sed -i "s/\(.*\)${prev_job}\(.*\)/\1${prev_job}\2\n\1${new_job}\2/1" $zuul_yaml
else
echo "Job $prev_job doesn't exists in $zuul_yaml"
fi
}

function add_new_config_default {
local config_yaml=$1
local prev_os_codename=$2
local new_os_codename=$3

if [ ! -f $config_yaml ]; then
echo "File doesn't exist: ${config_yaml}"
return
fi

if grep -Fq "$new_os_codename" "$config_yaml"; then
echo "$new_os_codename already exists in $config_yaml"
return
fi

if grep -Fq "$prev_os_codename" "$config_yaml"; then
sed -i "s/default: ${prev_os_codename}/default: ${new_os_codename}/1" $config_yaml
else
echo "Job $prev_os_codename doesn't exists in $config_yaml"
fi
}

function add_new_run_on_base {
local charmcraft_yaml=$1
local new_ubuntu_version=$2

if grep -Fq "$new_ubuntu_version" "$charmcraft_yaml"; then
echo "Version $new_ubuntu_version already exists in $charmcraft_yaml"
return
fi

run_on_text="\
- name: ubuntu
channel: \"$new_ubuntu_version\"
architectures: [amd64, s390x, ppc64el, arm64]"
echo "$run_on_text" >> $charmcraft_yaml
}

prev_os_codename=$(get_os_codename "$prev_series_bundle")
new_os_codename=$(get_os_codename "$new_series_bundle")

create_new_bundle $prev_series_bundle $new_series_bundle $tests_yaml
create_new_bundle $prev_uca_bundle $new_uca_bundle $tests_yaml
add_new_osci_job $osci_yaml $prev_os_codename $new_os_codename
add_new_zuul_job $zuul_yaml $prev_os_codename $new_os_codename
add_new_config_default $config_yaml $prev_os_codename $new_os_codename
add_new_run_on_base $charmcraft_yaml $new_ubuntu_version
30 changes: 30 additions & 0 deletions fetch-charms-for-master
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Fetch the charms using fetch-charms.py in the parent directory
# - log-level is error
# - section is supplied in param1
# - branch fetched is master
# - pushed to the ../charms directory
# - replace - destructive!
# - allow failures
# - any additional params are charms to ignore.

script_dir="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
repo_dir="$script_dir"

section=$1
shift
ignores=""
while (( "$#" )); do
ignores="$ignores -i $1"
shift
done

# now fetch the charms.
$repo_dir/fetch-charms.py --log error \
--section $section \
--branch master
--dir "$repo_dir/charms" \
--replace \
--ignore-failure \
$ignores
2 changes: 1 addition & 1 deletion global/classic-zaza/.zuul.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- project:
templates:
- openstack-python3-charm-yoga-jobs
- openstack-python3-charm-zed-jobs
- openstack-cover-jobs
7 changes: 3 additions & 4 deletions global/classic-zaza/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ parts:
source: .
prime:
- actions/*
- charmhelpers/*
- files/*
- hooks/*
- lib/*
- scripts/*
- templates/*
- actions.yaml
- config.yaml
Expand All @@ -23,13 +25,10 @@ parts:
bases:
- build-on:
- name: ubuntu
channel: "20.04"
channel: "22.04"
architectures:
- amd64
run-on:
- name: ubuntu
channel: "20.04"
architectures: [amd64, s390x, ppc64el, arm64]
- name: ubuntu
channel: "22.04"
architectures: [amd64, s390x, ppc64el, arm64]
7 changes: 1 addition & 6 deletions global/classic-zaza/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ pbr==5.6.0
simplejson>=2.2.0
netifaces>=0.10.4

# Build requirements
cffi==1.14.6; python_version < '3.6' # cffi 1.15.0 drops support for py35.

# NOTE: newer versions of cryptography require a Rust compiler to build,
# see
# * https://github.com/openstack-charmers/zaza/issues/421
Expand All @@ -27,8 +24,6 @@ netaddr>0.7.16,<0.8.0
Jinja2>=2.6 # BSD License (3 clause)
six>=1.9.0

# dnspython 2.0.0 dropped py3.5 support
dnspython<2.0.0; python_version < '3.6'
dnspython; python_version >= '3.6'
dnspython

psutil>=1.1.1,<2.0.0
17 changes: 1 addition & 16 deletions global/classic-zaza/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# all of its own requirements and if it doesn't, fix it there.
#
pyparsing<3.0.0 # aodhclient is pinned in zaza and needs pyparsing < 3.0.0, but cffi also needs it, so pin here.
cffi==1.14.6; python_version < '3.6' # cffi 1.15.0 drops support for py35.
setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85

requests>=2.18.4
Expand All @@ -19,26 +18,12 @@ stestr>=2.2.0
# https://github.com/mtreinish/stestr/issues/145
cliff<3.0.0

# Dependencies of stestr. Newer versions use keywords that didn't exist in
# python 3.5 yet (e.g. "ModuleNotFoundError")
importlib-metadata<3.0.0; python_version < '3.6'
importlib-resources<3.0.0; python_version < '3.6'

# Some Zuul nodes sometimes pull newer versions of these dependencies which
# dropped support for python 3.5:
osprofiler<2.7.0;python_version<'3.6'
stevedore<1.31.0;python_version<'3.6'
debtcollector<1.22.0;python_version<'3.6'
oslo.utils<=3.41.0;python_version<'3.6'

coverage>=4.5.2
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack

# Needed for charm-glance:
git+https://opendev.org/openstack/tempest.git#egg=tempest;python_version>='3.8'
tempest<31.0.0;python_version<'3.8'
tempest<24.0.0;python_version<'3.6'
git+https://opendev.org/openstack/tempest.git#egg=tempest

croniter # needed for charm-rabbitmq-server unit tests
24 changes: 2 additions & 22 deletions global/classic-zaza/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,8 @@ commands =
charmcraft -v pack
{toxinidir}/rename.sh

[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt

[testenv:py36]
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

[testenv:py38]
basepython = python3.8
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt

[testenv:py39]
basepython = python3.9
[testenv:py310]
basepython = python3.10
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion global/source-zaza/.zuul.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- project:
templates:
- openstack-python3-charm-yoga-jobs
- openstack-python3-charm-zed-jobs
- openstack-cover-jobs
Loading