Browse code

Merge "Workaround missing zip snapshot"

Jenkins authored on 2014/01/26 03:38:11
Showing 4 changed files
... ...
@@ -70,6 +70,9 @@ the `XENAPI_PASSWORD` must be your dom0 root password.
70 70
 Of course, use real passwords if this machine is exposed.
71 71
 
72 72
     cat > ./localrc <<EOF
73
+    # At the moment, we depend on github's snapshot function.
74
+    GIT_BASE="http://github.com"
75
+
73 76
     # Passwords
74 77
     # NOTE: these need to be specified, otherwise devstack will try
75 78
     # to prompt for these passwords, blocking the install process.
... ...
@@ -1,5 +1,14 @@
1 1
 #!/bin/bash
2 2
 
3
+function die_with_error {
4
+    local err_msg
5
+
6
+    err_msg="$1"
7
+
8
+    echo "$err_msg" >&2
9
+    exit 1
10
+}
11
+
3 12
 function xapi_plugin_location {
4 13
     for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins"; do
5 14
         if [ -d $PLUGIN_DIR ]; then
... ...
@@ -11,7 +20,7 @@ function xapi_plugin_location {
11 11
 }
12 12
 
13 13
 function zip_snapshot_location {
14
-    echo $1 | sed "s:\.git$::;s:$:/zipball/$2:g"
14
+    echo $1 | sed "s,^git://,http://,g;s:\.git$::;s:$:/zipball/$2:g"
15 15
 }
16 16
 
17 17
 function create_directory_for_kernels {
... ...
@@ -41,7 +50,9 @@ function extract_remote_zipball {
41 41
     local EXTRACTED_FILES=$(mktemp -d)
42 42
 
43 43
     {
44
-        wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate
44
+        if ! wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate; then
45
+            die_with_error "Failed to download [$ZIPBALL_URL]"
46
+        fi
45 47
         unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES
46 48
         rm -f $LOCAL_ZIPBALL
47 49
     } >&2
... ...
@@ -35,7 +35,7 @@ function mktemp {
35 35
 
36 36
 function wget {
37 37
     if [[ $@ =~ "failurl" ]]; then
38
-        exit 1
38
+        return 1
39 39
     fi
40 40
     echo "wget $@" >> $LIST_OF_ACTIONS
41 41
 }
... ...
@@ -77,6 +77,10 @@ function [ {
77 77
     exit 1
78 78
 }
79 79
 
80
+function die_with_error {
81
+    echo "$1" >> $DEAD_MESSAGES
82
+}
83
+
80 84
 function xe {
81 85
     cat $XE_RESPONSE
82 86
     {
... ...
@@ -29,6 +29,9 @@ function before_each_test {
29 29
 
30 30
     XE_CALLS=$(mktemp)
31 31
     truncate -s 0 $XE_CALLS
32
+
33
+    DEAD_MESSAGES=$(mktemp)
34
+    truncate -s 0 $DEAD_MESSAGES
32 35
 }
33 36
 
34 37
 # Teardown
... ...
@@ -64,6 +67,10 @@ function assert_xe_param {
64 64
     grep -qe "^$1\$" $XE_CALLS
65 65
 }
66 66
 
67
+function assert_died_with {
68
+    diff -u <(echo "$1") $DEAD_MESSAGES
69
+}
70
+
67 71
 function mock_out {
68 72
     local FNNAME="$1"
69 73
     local OUTPUT="$2"
... ...
@@ -109,10 +116,16 @@ function test_no_plugin_directory_found {
109 109
     grep "[ -d /usr/lib/xcp/plugins/ ]" $LIST_OF_ACTIONS
110 110
 }
111 111
 
112
-function test_zip_snapshot_location {
112
+function test_zip_snapshot_location_http {
113 113
     diff \
114
-    <(zip_snapshot_location "git://git.openstack.org/openstack/nova.git" "master") \
115
-    <(echo "git://git.openstack.org/openstack/nova/zipball/master")
114
+    <(zip_snapshot_location "http://github.com/openstack/nova.git" "master") \
115
+    <(echo "http://github.com/openstack/nova/zipball/master")
116
+}
117
+
118
+function test_zip_snapsot_location_git {
119
+    diff \
120
+    <(zip_snapshot_location "git://github.com/openstack/nova.git" "master") \
121
+    <(echo "http://github.com/openstack/nova/zipball/master")
116 122
 }
117 123
 
118 124
 function test_create_directory_for_kernels {
... ...
@@ -179,7 +192,7 @@ function test_extract_remote_zipball_wget_fail {
179 179
     local IGNORE
180 180
     IGNORE=$(. mocks && extract_remote_zipball "failurl")
181 181
 
182
-    assert_previous_command_failed
182
+    assert_died_with "Failed to download [failurl]"
183 183
 }
184 184
 
185 185
 function test_find_nova_plugins {