Browse code

Check out integration tests and install prereqs

Change-Id: I2a70a91c69005051f149a247faef42cfa88856a0

Dean Troyer authored on 2011/11/24 14:21:06
Showing 1 changed files
... ...
@@ -6,18 +6,14 @@
6 6
 function usage {
7 7
     echo "$0 - Build config.ini for openstack-integration-tests"
8 8
     echo ""
9
-    echo "Usage: $0 configdir"
9
+    echo "Usage: $0 [configdir]"
10 10
     exit 1
11 11
 }
12 12
 
13
-if [ ! "$#" -eq "1" ]; then
13
+if [ "$1" = "-h" ]; then
14 14
     usage
15 15
 fi
16 16
 
17
-CONFIG_DIR=$1
18
-CONFIG_CONF=$CONFIG_DIR/storm.conf
19
-CONFIG_INI=$CONFIG_DIR/config.ini
20
-
21 17
 # Clean up any resources that may be in use
22 18
 cleanup() {
23 19
     set +o errexit
... ...
@@ -53,8 +49,51 @@ source ./stackrc
53 53
 # Where Openstack code lives
54 54
 DEST=${DEST:-/opt/stack}
55 55
 
56
+CITEST_DIR=$DEST/openstack-integration-tests
57
+
58
+CONFIG_DIR=${1:-$CITEST_DIR/etc}
59
+CONFIG_CONF=$CONFIG_DIR/storm.conf
60
+CONFIG_INI=$CONFIG_DIR/config.ini
61
+
56 62
 DIST_NAME=${DIST_NAME:-oneiric}
57 63
 
64
+# git clone only if directory doesn't exist already.  Since ``DEST`` might not
65
+# be owned by the installation user, we create the directory and change the
66
+# ownership to the proper user.
67
+function git_clone {
68
+
69
+    GIT_REMOTE=$1
70
+    GIT_DEST=$2
71
+    GIT_BRANCH=$3
72
+
73
+    # do a full clone only if the directory doesn't exist
74
+    if [ ! -d $GIT_DEST ]; then
75
+        git clone $GIT_REMOTE $GIT_DEST
76
+        cd $2
77
+        # This checkout syntax works for both branches and tags
78
+        git checkout $GIT_BRANCH
79
+    elif [[ "$RECLONE" == "yes" ]]; then
80
+        # if it does exist then simulate what clone does if asked to RECLONE
81
+        cd $GIT_DEST
82
+        # set the url to pull from and fetch
83
+        git remote set-url origin $GIT_REMOTE
84
+        git fetch origin
85
+        # remove the existing ignored files (like pyc) as they cause breakage
86
+        # (due to the py files having older timestamps than our pyc, so python
87
+        # thinks the pyc files are correct using them)
88
+        find $GIT_DEST -name '*.pyc' -delete
89
+        git checkout -f origin/$GIT_BRANCH
90
+        # a local branch might not exist
91
+        git branch -D $GIT_BRANCH || true
92
+        git checkout -b $GIT_BRANCH
93
+    fi
94
+}
95
+
96
+# Install tests and prerequisites
97
+sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/openstack-integration-tests`
98
+
99
+git_clone $CITEST_REPO $CITEST_DIR $CITEST_BRANCH
100
+
58 101
 if [ ! -f $DEST/.ramdisk ]; then
59 102
     # Process network configuration vars
60 103
     GUEST_NETWORK=${GUEST_NETWORK:-1}