forked from grpc/grpc-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis-script.sh
executable file
·204 lines (177 loc) · 5.25 KB
/
.travis-script.sh
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash -e
# Copyright 2019, gRPC Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# See: Makefile
BUILD_OUTPUT=./.build/debug
info() {
printf '\033[0;34m%s\033[0m\n' "$1"
}
success() {
printf '\033[0;32m%s\033[0m\n' "$1"
}
setup_environment() {
echo -en 'travis_fold:start:script.environment\\r'
export PATH=$HOME/local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/local/lib
echo -en 'travis_fold:end:script.environment\\r'
}
make_all() {
echo -en 'travis_fold:start:make.all\\r'
info "Running make all"
make all
success "make all succeeded"
echo -en 'travis_fold:end:make.all\\r'
}
make_test() {
local tsan=$1
echo -en 'travis_fold:start:make.test\\r'
if $tsan; then
info "Running Swift tests with TSAN"
make test-tsan
else
info "Running Swift tests"
make test
fi
success "Swift tests passed"
echo -en 'travis_fold:end:make.test\\r'
}
run_allocation_tests() {
echo -en 'travis_fold:start:allocation_tests\\r'
info "Running allocation counter tests"
./Performance/allocations/test-allocation-counts.sh
echo -en 'travis_fold:end:allocation_tests\\r'
}
make_test_plugin() {
echo -en 'travis_fold:start:make.test_plugin\\r'
info "Validating protoc plugins on the Echo service"
make test-plugin
success "Validated protoc plugins on the Echo service"
echo -en 'travis_fold:end:make.test_plugin\\r'
}
make_project() {
echo -en 'travis_fold:start:make.project\\r'
info "Validating .xcodeproj can be generated"
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
make project
info ".xcodeproj was successfully generated"
else
info "Not running on macOS, skipping .xcodeproj generation"
fi
echo -en 'travis_fold:end:make.project\\r'
}
run_interop_tests() {
echo -en 'travis_fold:start:test.interop_tests\\r'
make interop-test-runner
INTEROP_TEST_SERVER_PORT=8080
# interop_server should be on $PATH
info "Starting C++ interop server on port $INTEROP_TEST_SERVER_PORT"
"$HOME"/local/bin/interop_server -port "$INTEROP_TEST_SERVER_PORT" &
INTEROP_SERVER_PID=$!
success "C++ interop server started, pid=$INTEROP_SERVER_PID"
# Names of the tests we should run:
TESTS=(
empty_unary
large_unary
client_streaming
server_streaming
ping_pong
empty_stream
custom_metadata
status_code_and_message
special_status_message
unimplemented_method
unimplemented_service
cancel_after_begin
cancel_after_first_response
timeout_on_sleeping_server
)
# Run the tests; logs are written to stderr, capture them per-test.
for test in "${TESTS[@]}"; do
info "Running $test"
$BUILD_OUTPUT/GRPCInteroperabilityTests run-test \
--host "localhost" \
--port "$INTEROP_TEST_SERVER_PORT" \
"$test"
success "PASSED $test"
done
success "Interop tests PASSED"
info "Stopping C++ interop server"
kill "$INTEROP_SERVER_PID"
success "Stopped C++ interop server"
echo -en 'travis_fold:end:test.interop_tests\\r'
}
run_interop_reconnect_test() {
echo -en 'travis_fold:start:test.interop_reconnect\\r'
make interop-backoff-test-runner
INTEROP_TEST_SERVER_CONTROL_PORT=8081
INTEROP_TEST_SERVER_RETRY_PORT=8082
# reconnect_interop_server should be on $PATH
info "Starting C++ reconnect interop server:"
info " - control port: ${INTEROP_TEST_SERVER_CONTROL_PORT}"
info " - retry port: ${INTEROP_TEST_SERVER_RETRY_PORT}"
"$HOME"/local/bin/reconnect_interop_server \
-control_port "$INTEROP_TEST_SERVER_CONTROL_PORT" \
-retry_port "$INTEROP_TEST_SERVER_RETRY_PORT" &
INTEROP_RECONNECT_SERVER_PID=$!
success "C++ reconnect interop server started, pid=$INTEROP_RECONNECT_SERVER_PID"
info "Running connection backoff interop test"
# Run the test; logs are written to stderr, redirect them to a file.
${BUILD_OUTPUT}/GRPCConnectionBackoffInteropTest \
--control-port ${INTEROP_TEST_SERVER_CONTROL_PORT} \
--retry-port ${INTEROP_TEST_SERVER_RETRY_PORT}
success "connection backoff interop test PASSED"
info "Stopping C++ reconnect interop server"
kill "$INTEROP_RECONNECT_SERVER_PID"
success "Stopped C++ reconnect interop server"
echo -en 'travis_fold:end:test.interop_reconnect\\r'
}
just_sanity=false
allocation_tests=false
just_interop_tests=false
tsan=false
while getopts "sita" optname; do
case $optname in
s)
just_sanity=true
;;
i)
just_interop_tests=true
;;
t)
tsan=true
;;
a)
allocation_tests=true
;;
\?)
echo "Uknown option $optname"
exit 2
;;
esac
done
setup_environment
if $just_sanity; then
./scripts/sanity.sh
elif $just_interop_tests; then
run_interop_tests
run_interop_reconnect_test
else
make_all
make_test $tsan
if $allocation_tests; then
run_allocation_tests
fi
make_test_plugin
make_project
fi