1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
. $DIR/.ltm_instance_$GCE_PROJECT
# The hostname has to match the common name field of the certificate, as set
# in util/gce-do-setup when running openssl to create a self-signed cert.
# curl will fail otherwise, stating that the common names do not match.
LTM_HOSTNAME="a.$GCE_PROJECT.gce-xfstests"
function ltm_post_json() {
if test -n "$GCE_LTM_INT_IP"; then
curl -s --cacert $GCE_LTM_SERVER_CERT -H "Content-Type: application/json" \
--resolve "$LTM_HOSTNAME:443:$GCE_LTM_INT_IP" -X POST "$@" -k | jq '.'
else
curl -s --cacert $GCE_LTM_SERVER_CERT -H "Content-Type: application/json" \
--resolve "$LTM_HOSTNAME:443:$GCE_LTM_EXT_IP" -X POST "$@" -k | jq '.'
fi
}
function ltm_post_failed() {
if run_gcloud compute instances describe "xfstests-ltm" &> /dev/null; then
echo "The ltm instance seems to be running. Try deleting the"
echo "$DIR/.ltm_instance_$GCE_PROJECT file and re-running launch-ltm to recreate"
echo "the file. If the issue persists, try relaunching the LTM"
echo "If configuration changes have been made, it may be necessary"
echo "to delete and re-launch the LTM."
else
echo "The ltm doesn't seem to be running. Try launching the ltm"
echo "instance with launch-ltm. This will recreate the"
echo ".ltm_instance_$GCE_PROJECT file."
fi
}
function send_to_ltm() {
local cmd_to_send=$1
shift
if test ! -f "$DIR/.ltm_cookie_$GCE_PROJECT"; then
# just create a new login session and store it in the cookie
ltm_post_json -c $DIR/.ltm_cookie_$GCE_PROJECT -d "{\"password\":\"$GCE_LTM_PWD\"}" \
"https://$LTM_HOSTNAME/login"
if [ ! $? = 0 ]; then
echo "Login failed."
ltm_post_failed
return 1
fi
echo
fi
if test -n "$LTM_INFO"; then
ltm_post_json -b $DIR/.ltm_cookie_$GCE_PROJECT "https://$LTM_HOSTNAME/status"
if [ $? != 0 ]; then
echo "Request failed."
ltm_post_failed
return 1
fi
echo
else
LTM_OPTS=""
if [ -n "$NO_REGION_SHARD" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"no_region_shard\":true"
fi
if [ -n "$BUCKET_SUBDIR" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"bucket_subdir\":\"$BUCKET_SUBDIR\""
fi
if [ -n "$GS_KERNEL" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"gs_kernel\":\"$GS_KERNEL\""
fi
if [ -n "${GCE_REPORT_EMAIL+x}" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"report_email\":\"$GCE_REPORT_EMAIL\""
fi
if [ -n "$COMMIT" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"commit_id\":\"$COMMIT\""
fi
if [ -n "$GIT_REPO" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"git_repo\":\"$GIT_REPO\""
fi
if [ -n "$BRANCH" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"branch_name\":\"$BRANCH\""
fi
if [ -n "$WATCHER_ID" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"unwatch\":\"$WATCHER_ID\""
fi
if [ -n "$BISECT_BAD" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"bad_commit\":\"$BISECT_BAD\""
fi
if [ -n "$BISECT_GOOD" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"good_commit\":\"$BISECT_GOOD\""
fi
if [ -n "$KCONFIG" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"kconfig\":\"$KCONFIG\""
fi
if [ -n "$KCONFIG_OPTS" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"kconfig_opts\":\"$KCONFIG_OPTS\""
fi
if [ -n "$KBUILD_OPTS" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"kbuild_opts\":\"$KBUILD_OPTS\""
fi
if [ -n "$ARCH" ]; then
LTM_OPTS="${LTM_OPTS:+$LTM_OPTS, }\"arch\":\"$ARCH\""
fi
if [ -n "$LTM_OPTS" ]; then
LTM_OPTS="\"options\": {$LTM_OPTS}"
fi
# Create OPTS.
ltm_post_json -b $DIR/.ltm_cookie_$GCE_PROJECT -d \
"{\"orig_cmdline\": \"$cmd_to_send\"${LTM_OPTS:+, $LTM_OPTS}}" \
"https://$LTM_HOSTNAME/gce-xfstests"
if [ $? != 0 ]; then
echo "Request failed."
ltm_post_failed
return 1
fi
echo
fi
}
|