From 44d1518886cce192b054fd4ca72e8939ab67f3a2 Mon Sep 17 00:00:00 2001 From: Dmitry Burmistrov Date: Thu, 22 Sep 2016 14:54:47 +0300 Subject: [PATCH] Remove tests stuff Change-Id: I0528b95fd9e55e0d3aa2ae186b8fa011739710bc Related-Bug: #1602240 --- tests/integration_tests.conf | 1 - tests/runtests.sh | 389 ----------------------------------- 2 files changed, 390 deletions(-) delete mode 100644 tests/integration_tests.conf delete mode 100755 tests/runtests.sh diff --git a/tests/integration_tests.conf b/tests/integration_tests.conf deleted file mode 100644 index 374708f..0000000 --- a/tests/integration_tests.conf +++ /dev/null @@ -1 +0,0 @@ -TEST_GROUP=deploy_ceilometer_ha_with_mongo diff --git a/tests/runtests.sh b/tests/runtests.sh deleted file mode 100755 index ca20556..0000000 --- a/tests/runtests.sh +++ /dev/null @@ -1,389 +0,0 @@ -#!/bin/bash - -set -eux - -package_to_test=${1} -RES=0 - -mysql_pass="admin" -token=$(openssl rand -hex 10) -auth_string="--os-auth-url http://127.0.0.1:35357 --os-token ${token} --os-endpoint http://127.0.0.1:35357/v2.0/" -ceilometer_auth_string="--debug --os-username ceilometer --os-password ceilometer --os-tenant-name ceilometer --os-auth-url http://127.0.0.1:35357" -ceilometer_service= - -keystone_log_file="/var/log/keystone/keystone.log" -ceilometer_log_dir="/var/log/ceilometer" -mongodb_log="/var/log/mongodb/mongodb.log" - -if [[ `cat /etc/*-release | head -n 1 | awk '{print $1}'` =~ Ubuntu ]]; then - os="ubuntu" - packages_list="python-pip curl" - export DEBIAN_FRONTEND=noninteractive - command_to_install="apt-get install -y --force-yes" - keystone_package="keystone" - keystone_service="keystone" - mysql_service="mysql" - mongodb_service="mongodb" - ceilometer_packages=( - ceilometer-agent-central - ceilometer-agent-compute - ceilometer-collector - ceilometer-agent-notification - ceilometer-polling - ceilometer-api - ceilometer-alarm-notifier - ceilometer-alarm-evaluator - ) - - ceilometer_services=( - ceilometer-agent-central - ceilometer-agent-compute - ceilometer-collector - ceilometer-agent-notification - ceilometer-polling - ceilometer-api - ) - - ceilometer_binaries=( - ceilometer-collector - ceilometer-agent-notification - ceilometer-polling - ceilometer-api - ceilometer-dbsync - ceilometer-expirer - ceilometer-rootwrap - ceilometer-send-sample - ) - config_files=( - api_paste.ini - ceilometer.conf - event_definitions.yaml - event_pipeline.yaml - pipeline.yaml - policy.json - ) -else - setenforce 0 && service firewalld stop - os="centos" - packages_list="python-pip curl" - command_to_install="yum install -y" - keystone_package="openstack-keystone" - keystone_service="openstack-keystone" - mysql_service="mysql" - mongodb_service="mongod" - ceilometer_packages=( - python-ceilometerclient - openstack-ceilometer-central - openstack-ceilometer-compute - openstack-ceilometer-collector - openstack-ceilometer-notification - openstack-ceilometer-polling - openstack-ceilometer-api - openstack-ceilometer-alarm - ) - ceilometer_services=( - openstack-ceilometer-central - openstack-ceilometer-compute - openstack-ceilometer-collector - openstack-ceilometer-notification - openstack-ceilometer-polling - openstack-ceilometer-api - ) - ceilometer_binaries=( - ceilometer-agent-notification - ceilometer-api - ceilometer-collector - ceilometer-dbsync - ceilometer-expirer - ceilometer-polling - ceilometer-send-sample - ) - config_files=( - api_paste.ini - ceilometer.conf - event_definitions.yaml - event_pipeline.yaml - pipeline.yaml - policy.json - ) -fi - -list_commands=( - alarm-list - event-list - meter-list - resource-list - sample-list -) - -install_packages() { - ${command_to_install} $@ -} - -prepare_vm() { - install_packages ${packages_list} -} - -install_and_setup_keystone() { - install_packages ${keystone_package} - service ${keystone_service} stop - - cat > /etc/keystone/keystone.conf << EOF -[DEFAULT] -admin_token=${token} -log_file=${keystone_log_file} -rabbit_password = guest -rabbit_hosts = 127.0.0.1 -notification_driver = messaging -notification_topics = notifications -[database] -connection=mysql://keystone:keystone@127.0.0.1/keystone -[token] -provider=keystone.token.providers.uuid.Provider -EOF - [ -d "/var/log/keystone/" ] || mkdir /var/log/keystone/ - touch ${keystone_log_file} - chown -R keystone:keystone /var/log/keystone/ - chown -R keystone:keystone /etc/keystone - keystone-manage db_sync - service ${keystone_service} restart - sleep 5 - if [ -z "$(curl -s http://127.0.0.1:5000/ | grep '^{"versions":')" ]; then - exit_on_error 1 "Failed to get to keystone API.\nTests failed because of keystone problem" - fi -} - -install_and_setup_mysql() { - if [[ "$os" == "ubuntu" ]]; then - echo "mysql-server mysql-server/root_password select ${mysql_pass}" | debconf-set-selections - echo "mysql-server mysql-server/root_password_again select ${mysql_pass}" | debconf-set-selections - ${command_to_install} mysql-server mysql-client python-mysqldb - MYSQL_PASSWORD='' - else - ${command_to_install} mysql-client mysql-server mysql-libs MySQL-python - MYSQL_PASSWORD=$(cat /root/.mysql_secret | head -1 | awk -F': ' '{print $2}') - fi - service mysql restart - sleep 10 - if [ ! -z "${MYSQL_PASSWORD}" ]; then - mysqladmin -u root -p${MYSQL_PASSWORD} password ${mysql_pass} - fi - if [ -z "$(service ${mysql_service} status | grep "running" )" ]; then - exit_on_error 1 "Mysql service has failed to start" - fi - - mysql -uroot -p${mysql_pass} -Bse "drop database if exists keystone" - mysql -uroot -p${mysql_pass} -Bse "create database keystone" - mysql -uroot -p${mysql_pass} -Bse "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'" - mysql -uroot -p${mysql_pass} -Bse "drop database if exists ceilometer" - mysql -uroot -p${mysql_pass} -Bse "create database ceilometer" - mysql -uroot -p${mysql_pass} -Bse "GRANT ALL PRIVILEGES ON ceilometer.* TO 'ceilometer'@'localhost' IDENTIFIED BY 'ceilometer'" - mysql -uroot -p${mysql_pass} -Bse "flush privileges" -} - -install_and_setup_rabbit() { - install_packages rabbitmq-server - echo "127.0.0.1 $(hostname)" >> /etc/hosts - if [[ "$os" == "ubuntu" ]]; then - update-rc.d rabbitmq-server defaults - else - systemctl enable rabbitmq-server - fi - service rabbitmq-server restart - sleep 5 -} - -ceilometer_configuration() { - cat > /etc/ceilometer/ceilometer.conf << EOF -[DEFAULT] -api_paste_config = /etc/ceilometer/api_paste.ini -policy_file = /etc/ceilometer/policy.json -debug = True -verbose = True -log_dir = ${ceilometer_log_dir} -auth_strategy = keystone -rabbit_password = guest -rabbit_hosts = 127.0.0.1 - -[keystone_authtoken] -auth_host = 127.0.0.1 -auth_port = 35357 -auth_protocol = http -admin_tenant_name = ceilometer -admin_user = ceilometer -admin_password = ceilometer -auth_url=http://127.0.0.1:35357 - -[database] -connection=mysql://ceilometer:ceilometer@127.0.0.1/ceilometer - -[notification] -store_events = True -EOF - [ -e /etc/default/ceilometer-polling ] && rm -f /etc/default/ceilometer-polling - echo "DAEMON_ARGS=\"--polling-namespaces=central\"" > /etc/default/ceilometer-polling - - [ -d "${ceilometer_log_dir}" ] || mkdir ${ceilometer_log_dir} - chown -R ceilometer:ceilometer ${ceilometer_log_dir} - chown -R ceilometer:ceilometer /etc/ceilometer - - ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf - if [ "$?" -ne '0' ]; then - cat ${ceilometer_log_dir}/ceilometer-dbsync.log - exit_on_error 1 "DB sync command has failures" - fi - - keystone ${auth_string} user-create --name ceilometer --pass ceilometer - keystone ${auth_string} tenant-create --name ceilometer - keystone ${auth_string} role-create --name=admin - keystone ${auth_string} user-role-add --user ceilometer --role admin --tenant ceilometer - ceilometer_service=$(keystone ${auth_string} service-create --name=ceilometer\ - --type=metering --description="ceilometer" | grep id | awk -F '|' '{print $3}' | tr -d ' ') - keystone ${auth_string} endpoint-create --region RegionOne --service-id=${ceilometer_service}\ - --publicurl=http://127.0.0.1:8777/ --internalurl=http://127.0.0.1:8777/ --adminurl=http://127.0.0.1:8777/ -} - -send_fake_instance_notification() { - if [ $os == "centos" ]; then - curl -LO https://bootstrap.pypa.io/get-pip.py - python get-pip.py - fi - - pip install pika==0.9.8 - echo '#!/usr/bin/env python -import pika -import uuid -connection = pika.BlockingConnection(pika.ConnectionParameters(host="127.0.0.1")) -channel = connection.channel() -channel.queue_declare(queue="notifications.info") -test='"'"'{"event_type": "compute.instance.create", "payload": {"instance_id": "fake", "memory_mb": 512, "disk_gb": 20, "root_gb": 20, "ephemeral_gb": 0, "vcpus": 1, "instance_type_id": 1, "state": "fake"}, "publisher_id": "fake", "priority":"INFO", "message_id": "%s"}'"'"' % uuid.uuid4() -channel.basic_publish(exchange="nova", routing_key="notifications.info", - properties=pika.BasicProperties(priority=0, delivery_mode=2, headers="", content_encoding="utf-8", content_type="application/json"), - body=test) -print " [x] Message was sent!" -connection.close()' > $(pwd)/send.py - python $(pwd)/send.py -} - -exit_on_error() { - # $1 - responce code - # $2 - message - if [ "${1}" -ne '0' ]; then - echo -e "${2}" - RES=${1} - exit ${RES} - fi -} - -found=false -for i in ${ceilometer_packages[@]}; do - if [ "${i}" == "${package_to_test}" ]; then - found=true - fi -done - -if ${found}; then - echo "Test for package ${package_to_test} will be run with ceilometer-common package" - RES=0 -fi - -case ${package_to_test} in - ceilometer-common|openstack-ceilometer-common) - prepare_vm - install_packages "${ceilometer_packages[@]}" - install_and_setup_rabbit - install_and_setup_mysql - install_and_setup_keystone - ceilometer_configuration - - for binary in ${ceilometer_binaries[@]}; do - if [ ! -f "/usr/bin/${binary}" ]; then - exit_on_error 1 "Ceilometer binary ${binary} is missed" - fi - done - - for config in ${config_files[@]}; do - if [ ! -f "/etc/ceilometer/${config}" ]; then - exit_on_error 1 "Ceilometer configuration file ${config} is missed" - fi - done - - for service in ${ceilometer_services[@]}; do - service ${service} restart - sleep 5 - if [ -z "$(service ${service} status | grep "running")" ]; then - cat /var/log/ceilometer/${service}.log - exit_on_error 1 "Service ${service} has failed to start" - fi - done - - repsonce=$(curl "http://127.0.0.1:8777" | grep "Authentication required") - if [ -z "$repsonce" ]; then - exit_on_error 1 "Ceilometer api doesn't work.\n No one process is listening on 8777 port" - fi - - - for Command in ${list_commands[@]}; do - ceilometer ${ceilometer_auth_string} ${Command} || true - cat $keystone_log_file - if [ "$?" -ne '0' ]; then - exit_on_error 1 "Command ${Command} has failed" - fi - done - - send_fake_instance_notification - - # Keystone notifications - if [ -z "$(ceilometer ${ceilometer_auth_string} meter-list | grep fake)" ]; then - exit_on_error 1 "Keystone notifications don't work" - fi - - # Instance notification - resource_id=$(ceilometer ${ceilometer_auth_string} resource-list | grep fake) - if [ -z "${resource_id}" ]; then - exit_on_error 1 "Notification is not received" - fi - - # Events - if [ -z "$(ceilometer ${ceilometer_auth_string} event-list | grep fake)" ]; then - exit_on_error 1 "Events wasn't created" - fi - - # Alarming -# Moved to Aodh -# ceilometer -dv ${ceilometer_auth_string} alarm-threshold-create --name cpu_high --description 'instance running hot' \ -# --meter-name cpu_util --threshold 70.0 --comparison-operator gt --statistic avg \ -# --period 600 --evaluation-periods 3 --alarm-action 'log://' --query resource_id="${resource_id}" - -# if [ "$?" -ne '0' -a -z "$(ceilometer ${ceilometer_auth_string} alarm-list | grep cpu_high)" ]; then -# exit_on_error 1 "Alarm creation has failed" -# fi - - # Samples - ceilometer -dv ${ceilometer_auth_string} sample-create -m fake_sample --meter-type gauge --meter-unit '%' --sample-volume 100 -r "fake" - - if [ "$?" -ne '0' -a -z "$(ceilometer ${ceilometer_auth_string} sample-list | grep fake_sample)" ]; then - exit_on_error 1 "Sample creation has failed" - fi - ;; - ceilometer-agent-ipmi|openstack-ceilometer-ipmi) - # Ceilometer-agent-ipmi is not included in common testing - # because it is not used in Fuel now - #if [ ! -f "/usr/bin/ceilometer-agent-ipmi" ]; then - # exit_on_error 1 "Ceilometer ipmi binary is missed" - #fi - ;; - python-ceilometer) - python -c 'import ceilometer' - if [ $? -ne '0' ]; then - exit_on_error 1 "Couldn't import module 'ceilometer'" - fi - ;; - *) - if ! ${found}; then - echo "Test not defined. Please create test for package ${package_to_test}" - fi - ;; -esac - -exit ${RES} -- 2.45.2