]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add simple installation tests for Heat
authorDenis Egorenko <degorenko@mirantis.com>
Thu, 28 Aug 2014 14:25:37 +0000 (18:25 +0400)
committerDenis Egorenko <degorenko@mirantis.com>
Fri, 12 Sep 2014 14:32:27 +0000 (18:32 +0400)
Change-Id: Id3c02528c7c4a3dcc1a0cb153a6e9ff639af32fc

debian/heat-api.init
rpm/SPECS/openstack-heat.spec
tests/runtests.sh

index 57d647ec94858cea04c4b7a1b5ef961bcc00a90c..9f3db2a13e375f87c6b599433570b60ea41b8fcf 100644 (file)
@@ -8,7 +8,6 @@
 # Short-Description: Heat API
 # Description:       Heat API server
 ### END INIT INFO
-
 # Author: Thomas Goirand <zigo@debian.or>
 
 # PATH should only include /usr/* if it runs after the mountnfs.sh script
index 91cde33f79b9d25599992db78e2ce4d100678d53..28614529360b019f66e4c929d3cc38350e7df2d0 100644 (file)
@@ -158,7 +158,7 @@ rm -rf %{buildroot}/%{python_sitelib}/heat/tests
 
 install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/heat.conf.sample %{buildroot}/%{_sysconfdir}/heat/heat.conf
 install -p -D -m 640 %{SOURCE20} %{buildroot}%{_datadir}/heat/heat-dist.conf
-install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/api-paste.ini %{buildroot}/%{_datadir}/heat/api-paste-dist.ini
+install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/api-paste.ini %{buildroot}/%{_sysconfdir}/heat/api-paste.ini
 install -p -D -m 640 etc/heat/policy.json %{buildroot}/%{_sysconfdir}/heat
 
 # TODO: move this to setup.cfg
@@ -227,13 +227,13 @@ Components common to all OpenStack Heat services
 %{_bindir}/heat-keystone-setup-domain
 %{python_sitelib}/heat*
 %attr(-, root, heat) %{_datadir}/heat/heat-dist.conf
-%attr(-, root, heat) %{_datadir}/heat/api-paste-dist.ini
 %dir %attr(0755,heat,root) %{_localstatedir}/log/heat
 %dir %attr(0755,heat,root) %{_localstatedir}/run/heat
 %dir %attr(0755,heat,root) %{_sharedstatedir}/heat
 %dir %attr(0755,heat,root) %{_sysconfdir}/heat
 %config(noreplace) %{_sysconfdir}/logrotate.d/openstack-heat
 %config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/heat.conf
+%config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/api-paste.ini
 %config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/policy.json
 %config(noreplace) %attr(-,root,heat) %{_sysconfdir}/heat/environment.d/*
 %config(noreplace) %attr(-,root,heat) %{_sysconfdir}/heat/templates/*
@@ -369,7 +369,6 @@ if [ $1 -ge 1 ]; then
     /sbin/service openstack-heat-api-cfn condrestart >/dev/null 2>&1 || :
 fi
 
-
 %package api-cloudwatch
 Summary: Heat CloudWatch API
 Group: System Environment/Base
index 47c00260b78d3a36a8ba886c934ec2c54f381619..e34280374db1a49cc01b239c5b4f28754b558f42 100755 (executable)
@@ -1,2 +1,153 @@
 #!/bin/bash -x
-exit 0
+RES=0
+package=$1
+MYSQL_PASSWORD="heat"
+conf_file=/etc/heat/heat.conf
+
+prepare_vm() {
+   if [[ `cat /etc/*-release | head -n 1 | awk '{print $1}'` =~ Ubuntu ]]
+   then
+      echo "mysql-server mysql-server/root_password select $MYSQL_PASSWORD" | sudo debconf-set-selections
+      echo "mysql-server mysql-server/root_password_again select $MYSQL_PASSWORD" | sudo debconf-set-selections
+      apt-get install -y mysql-server python-mysqldb rabbitmq-server
+   else
+      yum install screen mysql-server MySQL-python rabbitmq-server -y
+      service mysqld start
+      /usr/bin/mysqladmin -u root password $MYSQL_PASSWORD
+      /usr/bin/mysqladmin -u root --password=$MYSQL_PASSWORD  -h localhost $MYSQL_PASSWORD
+   fi
+   service rabbitmq-server start
+   mysql -uroot -p$MYSQL_PASSWORD -Bse "create database heat"
+   sed -i "/^\[database\]/a connection=mysql://root:$MYSQL_PASSWORD@localhost/heat"  $conf_file
+   heat-manage -d db_sync
+   if [ "$?" != "0" ]
+   then
+      echo "Couldn't execute 'heat-manage db_sync'"
+      RES=1
+   fi
+}
+
+case $package in
+     openstack-heat-common)
+        python -c 'import heat'
+        if [ $? -ne '0' ]; then
+            echo -e "Couldn't import module 'heat'"
+            RES=1
+        fi
+        if [ -z "$(cut -d: -f1 /etc/passwd | grep 'heat')" ]; then
+            echo -e "User 'heat' doesn't exist"
+            RES=1
+        fi
+        files="policy.json api-paste.ini heat.conf"
+        for i in $config_files; do
+            if [ ! -f "/etc/heat/$i" ]; then
+               RES=1
+               echo "File /etc/heat/$i doesn't exist"
+            fi
+        done
+     ;;
+     python-heat)
+        python -c 'import heat'
+        if [ $? -ne '0' ]; then
+            echo -e "Couldn't import module 'heat'"
+            RES=1
+        fi
+     ;;
+     heat-common)
+        if [ -z "$(cut -d: -f1 /etc/passwd | grep 'heat')" ]; then
+            echo -e "User 'heat' doesn't exist"
+            RES=1
+        fi
+        files="policy.json api-paste.ini heat.conf"
+        for i in $config_files; do
+            if [ ! -f "/etc/heat/$i" ]; then
+               RES=1
+               echo "File /etc/heat/$i doesn't exist"
+            fi
+        done
+     ;;
+     heat-api|openstack-heat-api)
+        prepare_vm
+        screen -dmS heat-api
+        sleep 2
+        echo "Starting Heat API..."
+        screen -S heat-api -p 0 -X stuff "heat-api --config-file $conf_file -d --log-file /tmp/heat-api.log
+"
+        sleep 5
+        curl_req=`curl http://localhost:8004/v1/tenant/stacks`
+        cat /tmp/heat-api.log
+        if [ `netstat -nat | grep 8004 | wc -l` != 0 ] && [[ $curl_req =~ Auth ]]
+        then
+            echo "Heat API successfully started"
+        else
+            echo "Heat API didn't start"
+            RES=1
+        fi
+     ;;
+     heat-engine|openstack-heat-engine)
+        prepare_vm
+        screen -dmS heat-engine
+        sleep 2
+        echo "Starting Heat Engine..."
+        screen -S heat-engine -p 0 -X stuff "heat-engine --config-file $conf_file -d --log-file /tmp/heat-engine.log
+"
+        sleep 5
+        cat /tmp/heat-engine.log
+        trace_count=`cat /tmp/heat-engine.log | grep -i Traceback | wc -l`
+        if [ "$trace_count" -ne "0" ]
+        then
+           echo "Something went wrong! Log file have trace errors! Check logs"
+           RES=1
+        else
+           rabbit_connections=`cat /tmp/heat-engine.log | grep 'Connected to AMQP server on' | wc -l`
+           if [ "$rabbit_connections" -eq "0" ]
+           then
+               echo "Heat Engine: Can't connected to RabbitMQ"
+               RES=1
+           else
+               echo "Heat Engine successfully started"
+           fi
+        fi
+     ;;
+     heat-api-cfn|openstack-heat-api-cfn)
+        prepare_vm
+        screen -dmS heat-api-cfn
+        sleep 2
+        echo "Starting Heat API CFN..."
+        screen -S heat-api-cfn -p 0 -X stuff "heat-api-cfn --config-file $conf_file -d --log-file /tmp/heat-api-cfn.log
+"
+        sleep 5
+        cat /tmp/heat-api-cfn.log
+        check_start_cfn=`cat /tmp/heat-api-cfn.log | grep 'Starting Heat API on' | wc -l`
+        if [ "$check_start_cfn" -ne "0" ]
+        then
+            echo "Heat API CFN successfully started"
+        else
+            RES=1
+            echo "Heat API CFN didn't start"
+        fi
+     ;;
+     heat-api-cloudwatch|openstack-heat-api-cloudwatch)
+        prepare_vm
+        screen -dmS heat-api-clw
+        sleep 2
+        echo "Starting Heat API Cloudwatch..."
+        screen -S heat-api-clw -p 0 -X stuff "heat-api-cloudwatch --config-file $conf_file -d --log-file /tmp/heat-api-clw.log
+"
+        sleep 5
+        cat /tmp/heat-api-clw.log
+        check_start_clw=`cat /tmp/heat-api-clw.log | grep 'Starting Heat CloudWatch API on' | wc -l`
+        if [ "$check_start_clw" -ne "0" ]
+        then
+            echo "Heat API Cloudwatch successfully started"
+        else
+            RES=1
+            echo "Heat API Cloudwatch didn't start"
+        fi
+     ;;
+     *)
+        echo "test not defined, skipping..."
+     ;;
+esac
+killall -15 screen
+exit $RES