Browse code

add gating up/down script for devstack

This adds the test infrastructure for testing that unstack.sh and
clean.sh do the right thing, and actually stop what's expected. This
is designed to be used in upstream testing to make unstack and clean a
bit more certain.

It includes numerous fixes to make these pass in an errexit
environment with the gate config. The scripts still don't run under
errexit because we don't assume we've handled all possible cleanup safely.

Change-Id: I774dfb2cc934367eef2bb7ea5123197f6da7565b

Sean Dague authored on 2015/02/05 02:44:18
Showing 7 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env bash
1
+#!/bin/bash
2 2
 
3 3
 # **clean.sh**
4 4
 
... ...
@@ -83,7 +83,10 @@ if [[ -d $TOP_DIR/extras.d ]]; then
83 83
 fi
84 84
 
85 85
 # Clean projects
86
-cleanup_cinder
86
+
87
+# BUG: cinder tgt doesn't exit cleanly if it's not running.
88
+cleanup_cinder || /bin/true
89
+
87 90
 cleanup_glance
88 91
 cleanup_keystone
89 92
 cleanup_nova
90 93
new file mode 100755
... ...
@@ -0,0 +1,24 @@
0
+#!/bin/bash -xe
1
+#
2
+# An up / down test for gate functional testing
3
+#
4
+# Note: this is expected to start running as jenkins
5
+
6
+# Step 1: give back sudoers permissions to devstack
7
+TEMPFILE=`mktemp`
8
+echo "stack ALL=(root) NOPASSWD:ALL" >$TEMPFILE
9
+chmod 0440 $TEMPFILE
10
+sudo chown root:root $TEMPFILE
11
+sudo mv $TEMPFILE /etc/sudoers.d/51_stack_sh
12
+
13
+# TODO: do something to start a guest to create crud that should
14
+# disappear
15
+
16
+# Step 2: unstack
17
+echo "Running unstack.sh"
18
+sudo -H -u stack stdbuf -oL -eL bash -ex ./unstack.sh
19
+
20
+# Step 3: clean
21
+echo "Running clean.sh"
22
+sudo -H -u stack stdbuf -oL -eL bash -ex ./clean.sh
23
+
... ...
@@ -28,17 +28,14 @@ function cleanup_database_mysql {
28 28
     stop_service $MYSQL
29 29
     if is_ubuntu; then
30 30
         # Get ruthless with mysql
31
-        stop_service $MYSQL
32 31
         apt_get purge -y mysql* mariadb*
33 32
         sudo rm -rf /var/lib/mysql
34 33
         sudo rm -rf /etc/mysql
35 34
         return
36 35
     elif is_fedora; then
37
-        stop_service mariadb
38 36
         uninstall_package mariadb-server
39 37
         sudo rm -rf /var/lib/mysql
40 38
     elif is_suse; then
41
-        stop_service mysql
42 39
         uninstall_package mysql-community-server
43 40
         sudo rm -rf /var/lib/mysql
44 41
     else
... ...
@@ -40,7 +40,10 @@ function start_dstat {
40 40
 
41 41
 # stop_dstat() stop dstat process
42 42
 function stop_dstat {
43
-    screen_stop dstat
43
+    # dstat runs as a console, not as a service, and isn't trackable
44
+    # via the normal mechanisms for devstack. So lets just do a
45
+    # killall and move on.
46
+    killall dstat || /bin/true
44 47
 }
45 48
 
46 49
 # Restore xtrace
... ...
@@ -74,7 +74,8 @@ function cleanup_rpc_backend {
74 74
     if is_service_enabled rabbit; then
75 75
         # Obliterate rabbitmq-server
76 76
         uninstall_package rabbitmq-server
77
-        sudo killall epmd || sudo killall -9 epmd
77
+        # in case it's not actually running, /bin/true at the end
78
+        sudo killall epmd || sudo killall -9 epmd || /bin/true
78 79
         if is_ubuntu; then
79 80
             # And the Erlang runtime too
80 81
             apt_get purge -y erlang*
... ...
@@ -184,7 +184,7 @@ function start_sahara {
184 184
 # stop_sahara() - Stop running processes
185 185
 function stop_sahara {
186 186
     # Kill the Sahara screen windows
187
-    screen -S $SCREEN_NAME -p sahara -X kill
187
+    stop_process sahara
188 188
 }
189 189
 
190 190
 
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env bash
1
+#!/bin/bash
2 2
 
3 3
 # **unstack.sh**
4 4
 
... ...
@@ -136,10 +136,13 @@ fi
136 136
 
137 137
 SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
138 138
 
139
+# BUG: tgt likes to exit 1 on service stop if everything isn't
140
+# perfect, we should clean up cinder stop paths.
141
+
139 142
 # Get the iSCSI volumes
140 143
 if is_service_enabled cinder; then
141
-    stop_cinder
142
-    cleanup_cinder
144
+    stop_cinder || /bin/true
145
+    cleanup_cinder || /bin/true
143 146
 fi
144 147
 
145 148
 if [[ -n "$UNSTACK_ALL" ]]; then
... ...
@@ -179,4 +182,5 @@ if [[ -n "$SCREEN" ]]; then
179 179
     fi
180 180
 fi
181 181
 
182
-clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME
182
+# BUG: maybe it doesn't exist? We should isolate this further down.
183
+clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME || /bin/true