Use pifpaf to setup tests
Change-Id: I6eedaf5749c85e47708f79f37a5cf75c959988e2 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
@@ -10,8 +10,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import uuid
|
||||
|
||||
import requests
|
||||
import six
|
||||
from tempest_lib import exceptions
|
||||
|
||||
@@ -362,8 +364,19 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
def test_gnocchi_resources_threshold_scenario(self):
|
||||
|
||||
PROJECT_ID = str(uuid.uuid4())
|
||||
# NOTE(gordc): taken from setup-tests.sh
|
||||
RESOURCE_ID = '6868DA77-FA82-4E67-ABA9-270C5AE8CBCA'
|
||||
RESOURCE_ID = str(uuid.uuid4())
|
||||
|
||||
req = requests.post(
|
||||
os.environ.get("GNOCCHI_ENDPOINT") + "/v1/resource/instance",
|
||||
json={
|
||||
"display_name": "myvm",
|
||||
"flavor_id": "2", "host": "blah",
|
||||
"id": RESOURCE_ID,
|
||||
"image_ref": "http://image",
|
||||
"project_id": "BD3A1E52-1C62-44CB-BF04-660BD88CD74D",
|
||||
"user_id": "BD3A1E52-1C62-44CB-BF04-660BD88CD74D",
|
||||
})
|
||||
self.assertEqual(201, req.status_code)
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
@@ -381,7 +394,7 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
self.assertEqual('cpu_util', alarm['metric'])
|
||||
self.assertEqual('80.0', alarm['threshold'])
|
||||
self.assertEqual('last', alarm['aggregation_method'])
|
||||
self.assertEqual('6868DA77-FA82-4E67-ABA9-270C5AE8CBCA',
|
||||
self.assertEqual(RESOURCE_ID,
|
||||
alarm['resource_id'])
|
||||
self.assertEqual('instance', alarm['resource_type'])
|
||||
|
||||
|
||||
113
setup-tests.sh
113
setup-tests.sh
@@ -1,113 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e -x
|
||||
|
||||
wait_for_line () {
|
||||
while read line
|
||||
do
|
||||
echo "$line" | grep -q "$1" && break
|
||||
done < "$2"
|
||||
# Read the fifo for ever otherwise process would block
|
||||
cat "$2" &
|
||||
}
|
||||
|
||||
clean_exit () {
|
||||
local error_code="$?"
|
||||
kill $(jobs -p)
|
||||
rm -rf "$@"
|
||||
return $error_code
|
||||
}
|
||||
|
||||
AODH_DATA=`mktemp -d /tmp/aodh-data-XXXXX`
|
||||
MYSQL_DATA=`mktemp -d /tmp/aodh-mysql-XXXXX`
|
||||
trap "clean_exit \"$AODH_DATA\" \"$MYSQL_DATA\"" EXIT
|
||||
|
||||
mysqld --initialize-insecure --datadir=${MYSQL_DATA} || true
|
||||
mkfifo ${MYSQL_DATA}/out
|
||||
PATH=$PATH:/usr/libexec
|
||||
mysqld --no-defaults --datadir=${MYSQL_DATA} --pid-file=${MYSQL_DATA}/mysql.pid --socket=${MYSQL_DATA}/mysql.socket --skip-networking --skip-grant-tables &> ${MYSQL_DATA}/out &
|
||||
# Wait for MySQL to start listening to connections
|
||||
wait_for_line "mysqld: ready for connections." ${MYSQL_DATA}/out
|
||||
export AODH_TEST_STORAGE_URL="mysql+pymysql://root@localhost/test?unix_socket=${MYSQL_DATA}/mysql.socket&charset=utf8"
|
||||
mysql --no-defaults -S ${MYSQL_DATA}/mysql.socket -e 'CREATE DATABASE test;'
|
||||
|
||||
|
||||
|
||||
# NOTE(sileht): FIXME: we must use the upstream policy and paste
|
||||
# configuration and not a copy, but aodh doesn't yet install
|
||||
# etc files in virtualenv
|
||||
cat << EOF > ${AODH_DATA}/policy.json
|
||||
{
|
||||
"context_is_admin": "role:admin",
|
||||
"segregation": "rule:context_is_admin",
|
||||
"admin_or_owner": "rule:context_is_admin or project_id:%(project_id)s",
|
||||
"default": "rule:admin_or_owner",
|
||||
|
||||
"telemetry:get_alarm": "rule:admin_or_owner",
|
||||
"telemetry:get_alarms": "rule:admin_or_owner",
|
||||
"telemetry:query_alarm": "rule:admin_or_owner",
|
||||
|
||||
"telemetry:create_alarm": "",
|
||||
"telemetry:change_alarm": "rule:admin_or_owner",
|
||||
"telemetry:delete_alarm": "rule:admin_or_owner",
|
||||
|
||||
"telemetry:get_alarm_state": "rule:admin_or_owner",
|
||||
"telemetry:change_alarm_state": "rule:admin_or_owner",
|
||||
|
||||
"telemetry:alarm_history": "rule:admin_or_owner",
|
||||
"telemetry:query_alarm_history": "rule:admin_or_owner"
|
||||
}
|
||||
EOF
|
||||
cat << EOF > ${AODH_DATA}/api-paste.ini
|
||||
[pipeline:main]
|
||||
# NOTE(sileht): disable authtoken
|
||||
# pipeline = request_id authtoken api-server
|
||||
pipeline = request_id api-server
|
||||
|
||||
[app:api-server]
|
||||
paste.app_factory = aodh.api.app:app_factory
|
||||
|
||||
[filter:authtoken]
|
||||
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
|
||||
oslo_config_project = aodh
|
||||
|
||||
[filter:request_id]
|
||||
paste.filter_factory = oslo_middleware:RequestId.factory
|
||||
EOF
|
||||
|
||||
mkfifo ${AODH_DATA}/out
|
||||
cat > ${AODH_DATA}/aodh.conf <<EOF
|
||||
[api]
|
||||
paste_config = ${AODH_DATA}/api-paste.ini
|
||||
# paste_config = ${VIRTUAL_ENV}/etc/aodh/api-paste.ini
|
||||
[oslo_policy]
|
||||
policy_file = ${AODH_DATA}/policy.json
|
||||
# policy_file = ${VIRTUAL_ENV}/etc/aodh/policy.json
|
||||
[database]
|
||||
connection = $AODH_TEST_STORAGE_URL
|
||||
[service_credentials]
|
||||
auth_type = gnocchi-noauth
|
||||
user_id = e0f4a978-694f-4ad3-b93d-8959374ab091
|
||||
project_id = e0f4a978-694f-4ad3-b93d-8959374ab091
|
||||
roles = admin
|
||||
endpoint = http://localhost:8041/
|
||||
EOF
|
||||
|
||||
aodh-dbsync --config-file ${AODH_DATA}/aodh.conf
|
||||
aodh-api --config-file ${AODH_DATA}/aodh.conf &> ${AODH_DATA}/out &
|
||||
# Wait for Aodh to start
|
||||
wait_for_line "Running on http://0.0.0.0:8042/" ${AODH_DATA}/out
|
||||
export AODH_ENDPOINT=http://localhost:8042/
|
||||
|
||||
source $(which overtest) gnocchi
|
||||
|
||||
# gnocchi alarms validate existence
|
||||
curl -X POST -H 'Content-Type:application/json' ${OVERTEST_GNOCCHI_HTTP_URL}/v1/resource/instance --data '{
|
||||
"display_name": "myvm",
|
||||
"flavor_id": "2", "host": "blah",
|
||||
"id": "6868DA77-FA82-4E67-ABA9-270C5AE8CBCA",
|
||||
"image_ref": "http://image",
|
||||
"project_id": "BD3A1E52-1C62-44CB-BF04-660BD88CD74D",
|
||||
"user_id": "BD3A1E52-1C62-44CB-BF04-660BD88CD74D"
|
||||
}'
|
||||
|
||||
$*
|
||||
@@ -18,4 +18,4 @@ http://tarballs.openstack.org/aodh/aodh-master.tar.gz#egg=aodh[mysql]
|
||||
http://tarballs.openstack.org/gnocchi/gnocchi-master.tar.gz#egg=gnocchi[postgresql,file]
|
||||
# FIXME(sileht): should be in aodh ?
|
||||
keystonemiddleware
|
||||
overtest>=0.12
|
||||
pifpaf>=0.0.6
|
||||
|
||||
8
tox.ini
8
tox.ini
@@ -8,10 +8,12 @@ usedevelop = True
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
AODH_CLIENT_EXEC_DIR={envdir}/bin
|
||||
passenv = AODH_* OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE
|
||||
AODH_ENDPOINT=http://localhost:8042
|
||||
GNOCCHI_ENDPOINT=http://localhost:8051
|
||||
passenv = GNOCCHI_* AODH_* OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = {toxinidir}/setup-tests.sh python setup.py test --slowest --testr-args='{posargs}'
|
||||
commands = pifpaf run aodh --gnocchi-create-legacy-resource-types -- python setup.py test --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
@@ -28,7 +30,7 @@ commands =
|
||||
python setup.py build_sphinx
|
||||
|
||||
[testenv:debug]
|
||||
commands = {toxinidir}/setup-tests.sh oslo_debug_helper {posargs}
|
||||
commands = pifpaf --debug run aodh --gnocchi-create-legacy-resource-types -- oslo_debug_helper {posargs}
|
||||
|
||||
[flake8]
|
||||
show-source = True
|
||||
|
||||
Reference in New Issue
Block a user