Add simple upgrade tests
This change adds a tox targets that run upgrade testing. The two jobs have been chosen for gate testing, but other can be later added for local testing. Change-Id: I7d06847243fd3be4e8cd381205d6c21bcd087f30
This commit is contained in:
parent
97a0bddc7b
commit
bd142765da
|
@ -0,0 +1,30 @@
|
||||||
|
From 7bcd2a259be0a35d9387a24329f55250efde3aec Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mehdi Abaakouk <sileht@redhat.com>
|
||||||
|
Date: Mon, 12 Sep 2016 19:54:03 +0200
|
||||||
|
Subject: [PATCH] ceph: Fix metricd start
|
||||||
|
|
||||||
|
metricd can be started before api, in that case
|
||||||
|
metricd fail because the measure object don't yet exists.
|
||||||
|
|
||||||
|
Change-Id: Id7822f16718e31d6a8916cec8a6b77194071a31e
|
||||||
|
---
|
||||||
|
|
||||||
|
diff --git a/gnocchi/storage/ceph.py b/gnocchi/storage/ceph.py
|
||||||
|
index 15e1dad..d2ea4f8 100644
|
||||||
|
--- a/gnocchi/storage/ceph.py
|
||||||
|
+++ b/gnocchi/storage/ceph.py
|
||||||
|
@@ -167,8 +167,12 @@
|
||||||
|
def _list_object_names_to_process(self, prefix=""):
|
||||||
|
with rados.ReadOpCtx() as op:
|
||||||
|
omaps, ret = self.ioctx.get_omap_vals(op, "", prefix, -1)
|
||||||
|
- self.ioctx.operate_read_op(
|
||||||
|
- op, self.MEASURE_PREFIX, flag=self.OMAP_READ_FLAGS)
|
||||||
|
+ try:
|
||||||
|
+ self.ioctx.operate_read_op(
|
||||||
|
+ op, self.MEASURE_PREFIX, flag=self.OMAP_READ_FLAGS)
|
||||||
|
+ except rados.ObjectNotFound:
|
||||||
|
+ # API have still written nothing
|
||||||
|
+ return ()
|
||||||
|
# NOTE(sileht): after reading the libradospy, I'm
|
||||||
|
# not sure that ret will have the correct value
|
||||||
|
# get_omap_vals transforms the C int to python int
|
|
@ -4,3 +4,5 @@ mysql-client [platform:dpkg]
|
||||||
mysql-server [platform:dpkg]
|
mysql-server [platform:dpkg]
|
||||||
build-essential [platform:dpkg]
|
build-essential [platform:dpkg]
|
||||||
libffi-dev [platform:dpkg]
|
libffi-dev [platform:dpkg]
|
||||||
|
librados-dev [platform:dpkg]
|
||||||
|
ceph [platform:dpkg]
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export OS_AUTH_PLUGIN=gnocchi-noauth
|
||||||
|
export GNOCCHI_ENDPOINT=http://localhost:8041
|
||||||
|
export GNOCCHI_USER_ID=99aae-4dc2-4fbc-b5b8-9688c470d9cc
|
||||||
|
export GNOCCHI_PROJECT_ID=c8d27445-48af-457c-8e0d-1de7103eae1f
|
||||||
|
export GNOCCHI_DATA=$(mktemp -d -t gnocchi.XXXX)
|
||||||
|
|
||||||
|
RESOURCE_IDS=(
|
||||||
|
"5a301761-aaaa-46e2-8900-8b4f6fe6675a"
|
||||||
|
"5a301761-bbbb-46e2-8900-8b4f6fe6675a"
|
||||||
|
"5a301761-cccc-46e2-8900-8b4f6fe6675a"
|
||||||
|
)
|
||||||
|
|
||||||
|
GDATE=$((which gdate >/dev/null && echo gdate) || echo date)
|
||||||
|
|
||||||
|
dump_data(){
|
||||||
|
dir="$1"
|
||||||
|
mkdir -p $dir
|
||||||
|
echo "* Dumping measures aggregations to $dir"
|
||||||
|
for resource_id in $RESOURCE_IDS; do
|
||||||
|
for agg in min max mean sum ; do
|
||||||
|
gnocchi measures show --aggregation $agg --resource-id $resource_id metric > $dir/${agg}.txt
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
inject_data() {
|
||||||
|
echo "* Injecting measures in Gnocchi"
|
||||||
|
# TODO(sileht): Generate better data that ensure we have enought split that cover all
|
||||||
|
# situation
|
||||||
|
for resource_id in $RESOURCE_IDS; do
|
||||||
|
gnocchi resource create generic --attribute id:$resource_id -n metric:high >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
{
|
||||||
|
echo -n '{'
|
||||||
|
resource_sep=""
|
||||||
|
for resource_id in $RESOURCE_IDS; do
|
||||||
|
echo -n "$resource_sep \"$resource_id\": { \"metric\": [ "
|
||||||
|
measures_sep=""
|
||||||
|
for i in $(seq 0 10 288000); do
|
||||||
|
now=$($GDATE --iso-8601=s -d "-${i}minute") ; value=$((RANDOM % 13 + 52))
|
||||||
|
echo -n "$measures_sep {\"timestamp\": \"$now\", \"value\": $value }"
|
||||||
|
measures_sep=","
|
||||||
|
done
|
||||||
|
echo -n "] }"
|
||||||
|
resource_sep=","
|
||||||
|
done
|
||||||
|
echo -n '}'
|
||||||
|
} | gnocchi measures batch-resources-metrics -
|
||||||
|
|
||||||
|
echo "* Waiting for measures computation"
|
||||||
|
while [ $(gnocchi status -f value -c "storage/total number of measures to process") -gt 0 ]; do sleep 1 ; done
|
||||||
|
}
|
||||||
|
|
||||||
|
pifpaf_stop(){
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup(){
|
||||||
|
pifpaf_stop
|
||||||
|
rm -rf $GNOCCHI_DATA
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$STORAGE_DAEMON" == "ceph" ]; then
|
||||||
|
rados -c $STORAGE_CEPH_CONF mkpool gnocchi
|
||||||
|
STORAGE_URL=ceph://$STORAGE_CEPH_CONF
|
||||||
|
else
|
||||||
|
STORAGE_URL=file://$GNOCCHI_DATA
|
||||||
|
fi
|
||||||
|
|
||||||
|
# NOTE(sileht): temporary fix a gnocchi 2.2 bug
|
||||||
|
# https://review.openstack.org/#/c/369011/
|
||||||
|
patch -p2 -d $VIRTUAL_ENV/lib/python*/site-packages/gnocchi < 7bcd2a25.diff
|
||||||
|
|
||||||
|
eval $(pifpaf run gnocchi --indexer-url $INDEXER_URL --storage-url $STORAGE_URL)
|
||||||
|
inject_data $GNOCCHI_DATA
|
||||||
|
dump_data $GNOCCHI_DATA/old
|
||||||
|
pifpaf_stop
|
||||||
|
|
||||||
|
old_version=$(pip freeze | sed -n '/gnocchi==/s/.*==\(.*\)/\1/p')
|
||||||
|
new_version=$(python setup.py --version)
|
||||||
|
echo "* Upgrading Gnocchi from $old_version to $new_version"
|
||||||
|
pip install -q -U .[${GNOCCHI_VARIANT}]
|
||||||
|
|
||||||
|
|
||||||
|
eval $(pifpaf run gnocchi --indexer-url $INDEXER_URL --storage-url $STORAGE_URL)
|
||||||
|
dump_data $GNOCCHI_DATA/new
|
||||||
|
|
||||||
|
echo "* Checking output difference between Gnocchi $old_version and $new_version"
|
||||||
|
diff -uNr $GNOCCHI_DATA/old $GNOCCHI_DATA/new
|
28
tox.ini
28
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 1.8
|
minversion = 1.8
|
||||||
envlist = py{34,35,27},py{34,35,27}-{postgresql,mysql}{,-file,-swift,-ceph},pep8,bashate
|
envlist = py{34,35,27},py{34,35,27}-{postgresql,mysql}{,-file,-swift,-ceph},pep8,bashate,py35-postgresql-file-upgrade-from-2.2,py27-mysql-ceph-upgrade-from-2.2
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
|
@ -24,6 +24,32 @@ commands =
|
||||||
oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf
|
oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf
|
||||||
{toxinidir}/run-tests.sh {posargs}
|
{toxinidir}/run-tests.sh {posargs}
|
||||||
|
|
||||||
|
[testenv:py35-postgresql-file-upgrade-from-2.2]
|
||||||
|
# We should always recreate since the script upgrade
|
||||||
|
# Gnocchi we can't reuse the virtualenv
|
||||||
|
recreate = True
|
||||||
|
skip_install = True
|
||||||
|
usedevelop = False
|
||||||
|
setenv = GNOCCHI_VARIANT=test,postgresql,file
|
||||||
|
deps = gnocchi[{env:GNOCCHI_VARIANT}]>=2.2,<2.3
|
||||||
|
pifpaf>=0.13
|
||||||
|
gnocchiclient
|
||||||
|
commands = pifpaf --env-prefix INDEXER run postgresql {toxinidir}/run-upgrade-tests.sh {posargs}
|
||||||
|
|
||||||
|
[testenv:py27-mysql-ceph-upgrade-from-2.2]
|
||||||
|
# We should always recreate since the script upgrade
|
||||||
|
# Gnocchi we can't reuse the virtualenv
|
||||||
|
recreate = True
|
||||||
|
skip_install = True
|
||||||
|
usedevelop = False
|
||||||
|
setenv = GNOCCHI_VARIANT=test,mysql,ceph,ceph_recommended_lib
|
||||||
|
deps = gnocchi[{env:GNOCCHI_VARIANT}]>=2.2,<2.3
|
||||||
|
gnocchiclient
|
||||||
|
pifpaf>=0.13
|
||||||
|
cradox
|
||||||
|
# cradox is required because 2.2 extra names are incorrect
|
||||||
|
commands = pifpaf --env-prefix INDEXER run mysql -- pifpaf --env-prefix STORAGE run ceph {toxinidir}/run-upgrade-tests.sh {posargs}
|
||||||
|
|
||||||
[testenv:bashate]
|
[testenv:bashate]
|
||||||
deps = bashate
|
deps = bashate
|
||||||
commands = bashate -v devstack/plugin.sh devstack/gate/gate_hook.sh devstack/gate/post_test_hook.sh
|
commands = bashate -v devstack/plugin.sh devstack/gate/gate_hook.sh devstack/gate/post_test_hook.sh
|
||||||
|
|
Loading…
Reference in New Issue