tests: functional with tox+pifpaf

Change-Id: I7d609a778c7c8592a3c7847e62b832d3805a71f4
This commit is contained in:
Mehdi Abaakouk 2017-02-02 09:10:46 +01:00
parent 234193793b
commit aa0716be94
8 changed files with 84 additions and 8 deletions

View File

@ -7,3 +7,4 @@ libffi-dev [platform:dpkg]
librados-dev [platform:dpkg]
ceph [platform:dpkg]
redis-server [platform:dpkg]
liberasurecode-dev [platform:dpkg]

View File

@ -40,6 +40,7 @@ openstack catalog list
export GNOCCHI_SERVICE_TOKEN=$(openstack token issue -c id -f value)
export GNOCCHI_SERVICE_URL=$(openstack catalog show metric -c endpoints -f value | awk '/public/{print $2}')
export GNOCCHI_AUTHORIZATION="" # Temporary set to transition to the new functional testing
curl -X GET ${GNOCCHI_SERVICE_URL}/v1/archive_policy -H "Content-Type: application/json"

View File

@ -62,6 +62,7 @@ class GnocchiGabbiTest(tempest.test.BaseTestCase):
require_ssl=require_ssl)
os.environ["GNOCCHI_SERVICE_TOKEN"] = token
os.environ["GNOCCHI_AUTHORIZATION"] = "not used"
@classmethod
def clear_credentials(cls):

View File

@ -6,6 +6,7 @@
defaults:
request_headers:
x-auth-token: $ENVIRON['GNOCCHI_SERVICE_TOKEN']
authorization: $ENVIRON['GNOCCHI_AUTHORIZATION']
tests:
- name: check /
@ -34,6 +35,7 @@ tests:
request_headers:
content-type: application/json
x-auth-token: 'hello'
authorization: 'basic hello:'
data:
name: medium
definition:
@ -145,8 +147,8 @@ tests:
$.definition[2].granularity: "0:01:00"
$.definition[2].points: 5
$.definition[2].timespan: "0:05:00"
response_strings:
- '"aggregation_methods": ["max", "min", "mean"]'
response_json_paths:
$.aggregation_methods.`sorted`: ["max", "mean", "min"]
- name: get wrong accept
desc: invalid 'accept' header
@ -300,6 +302,7 @@ tests:
request_headers:
content-type: application/json
x-auth-token: 'hello'
authorization: 'basic hello:'
data:
name: test_rule
metric_pattern: "disk.foo.*"
@ -329,8 +332,10 @@ tests:
- name: get all archive policy rules
GET: /v1/archive_policy_rule
status: 200
response_strings:
- '"metric_pattern": "live.*", "archive_policy_name": "gabbilive", "name": "gabbilive_rule"'
response_json_paths:
$[\name][0].name: "gabbilive_rule"
$[\name][0].metric_pattern: "live.*"
$[\name][0].archive_policy_name: "gabbilive"
- name: get unknown archive policy rule
GET: /v1/archive_policy_rule/foo

View File

@ -19,6 +19,7 @@
defaults:
request_headers:
x-auth-token: $ENVIRON['GNOCCHI_SERVICE_TOKEN']
authorization: $ENVIRON['GNOCCHI_AUTHORIZATION']
tests:
#

55
run-func-tests.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash -x
set -e
cleanup(){
type -t gnocchi_stop >/dev/null && gnocchi_stop || true
type -t indexer_stop >/dev/null && indexer_stop || true
type -t storage_stop >/dev/null && storage_stop || true
}
trap cleanup EXIT
GNOCCHI_TEST_STORAGE_DRIVERS=${GNOCCHI_TEST_STORAGE_DRIVERS:-file}
GNOCCHI_TEST_INDEXER_DRIVERS=${GNOCCHI_TEST_INDEXER_DRIVERS:-postgresql}
for storage in ${GNOCCHI_TEST_STORAGE_DRIVERS}; do
for indexer in ${GNOCCHI_TEST_INDEXER_DRIVERS}; do
case $storage in
ceph)
eval $(pifpaf -e STORAGE run ceph)
rados -c $STORAGE_CEPH_CONF mkpool gnocchi
STORAGE_URL=ceph://$STORAGE_CEPH_CONF
;;
s3)
if ! which s3rver >/dev/null 2>&1
then
mkdir -p npm-s3rver
export NPM_CONFIG_PREFIX=npm-s3rver
npm install s3rver --global
export PATH=$PWD/npm-s3rver/bin:$PATH
fi
eval $(pifpaf -e STORAGE run s3rver)
;;
file)
STORAGE_URL=file://
;;
swift|redis)
eval $(pifpaf -e STORAGE run $storage)
;;
*)
echo "Unsupported storage backend by functional tests: $storage"
exit 1
;;
esac
eval $(pifpaf -e INDEXER run $indexer)
eval $(pifpaf -e GNOCCHI run gnocchi --indexer-url $INDEXER_URL --storage-url $STORAGE_URL)
export GNOCCHI_SERVICE_URL=$GNOCCHI_ENDPOINT
export GNOCCHI_SERVICE_TOKEN="" # Just make gabbi happy
export GNOCCHI_AUTHORIZATION="basic YWRtaW46" # admin in base64
export OS_TEST_PATH=gnocchi/tests/functional_live
./tools/pretty_tox.sh $*
cleanup
done
done

View File

@ -66,7 +66,7 @@ doc =
Jinja2
reno>=1.6.2
test =
pifpaf>=0.12.0
pifpaf>=0.25.0
gabbi>=1.30.0
coverage>=3.6
fixtures
@ -83,6 +83,8 @@ test =
tooz>=1.38
keystonemiddleware>=4.0.0
wsgi_intercept>=1.4.1
test-swift =
python-swiftclient
[global]
setup-hooks =

16
tox.ini
View File

@ -19,20 +19,30 @@ setenv =
postgresql: GNOCCHI_TEST_INDEXER_DRIVERS=postgresql
mysql: GNOCCHI_TEST_INDEXER_DRIVERS=mysql
GNOCCHI_STORAGE_DEPS=file,swift,s3,ceph,ceph_recommended_lib,redis
GNOCCHI_STORAGE_DEPS=file,swift,test-swift,s3,ceph,ceph_recommended_lib,redis
ceph: GNOCCHI_STORAGE_DEPS=ceph,ceph_recommended_lib
swift: GNOCCHI_STORAGE_DEPS=swift
swift: GNOCCHI_STORAGE_DEPS=swift,test-swift
file: GNOCCHI_STORAGE_DEPS=file
redis: GNOCCHI_STORAGE_DEPS=redis
s3: GNOCCHI_STORAGE_DEPS=s3
# FIXME(sileht): pbr doesn't support url in setup.cfg extras, so we do this crap
GNOCCHI_TEST_TARBALLS=http://tarballs.openstack.org/swift/swift-master.tar.gz#egg=swift
ceph: GNOCCHI_TEST_TARBALLS=
swift: GNOCCHI_TEST_TARBALLS=http://tarballs.openstack.org/swift/swift-master.tar.gz#egg=swift
s3: GNOCCHI_TEST_TARBALLS=
redis: GNOCCHI_TEST_TARBALLS=
file: GNOCCHI_TEST_TARBALLS=
deps = .[test]
postgresql: .[postgresql,{env:GNOCCHI_STORAGE_DEPS}]
mysql: .[mysql,{env:GNOCCHI_STORAGE_DEPS}]
{env:GNOCCHI_TEST_TARBALLS:}
# NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt
commands =
doc8 --ignore-path doc/source/rest.rst doc/source
gnocchi-config-generator
{toxinidir}/run-tests.sh {posargs}
{toxinidir}/run-func-tests.sh {posargs}
[testenv:py35-postgresql-file-upgrade-from-3.1]
# We should always recreate since the script upgrade
@ -76,7 +86,7 @@ commands = flake8
[testenv:py27-gate]
setenv = OS_TEST_PATH=gnocchi/tests/functional_live
GABBI_LIVE=1
passenv = {[testenv]passenv} GNOCCHI_SERVICE*
passenv = {[testenv]passenv} GNOCCHI_SERVICE* GNOCCHI_AUTHORIZATION
sitepackages = True
basepython = python2.7
commands = {toxinidir}/tools/pretty_tox.sh '{posargs}'