-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
run-load-balancer-tests.sh
executable file
·95 lines (79 loc) · 3.67 KB
/
run-load-balancer-tests.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
#!/bin/bash
set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail
# Supported/used environment variables:
# AUTH Set to enable authentication. Values are: "auth" / "noauth" (default)
# SSL Set to enable SSL. Values are "ssl" / "nossl" (default)
# JDK Set the version of java to be used. Java versions can be set from the java toolchain /opt/java
# SINGLE_MONGOS_LB_URI Set the URI pointing to a load balancer configured with a single mongos server
# MULTI_MONGOS_LB_URI Set the URI pointing to a load balancer configured with multiple mongos servers
AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
JDK=${JDK:-jdk8}
export JAVA_HOME="/opt/java/jdk11"
############################################
# Main Program #
############################################
if [ "$SSL" != "nossl" ]; then
# We generate the keystore and truststore on every run with the certs in the drivers-tools repo
if [ ! -f client.pkc ]; then
openssl pkcs12 -CAfile ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -export -in ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem -out client.pkc -password pass:bithere
fi
cp ${JAVA_HOME}/lib/security/cacerts mongo-truststore
${JAVA_HOME}/bin/keytool -importcert -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -keystore mongo-truststore -storepass changeit -storetype JKS -noprompt
# We add extra gradle arguments for SSL
GRADLE_EXTRA_VARS="-Pssl.enabled=true -Pssl.keyStoreType=pkcs12 -Pssl.keyStore=$(pwd)/client.pkc -Pssl.keyStorePassword=bithere -Pssl.trustStoreType=jks -Pssl.trustStore=$(pwd)/mongo-truststore -Pssl.trustStorePassword=changeit"
SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}&ssl=true&sslInvalidHostNameAllowed=true"
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}&ssl=true&sslInvalidHostNameAllowed=true"
fi
echo "Running $AUTH tests over $SSL and connecting to $SINGLE_MONGOS_LB_URI"
echo "Running tests with ${JDK}"
./gradlew -version
# Disabling errexit so that both gradle command will run.
# Then we exit with non-zero if either of them exited with non-zero
set +o errexit
./gradlew -PjdkHome=/opt/java/${JDK} \
-Dorg.mongodb.test.uri=${SINGLE_MONGOS_LB_URI} \
-Dorg.mongodb.test.transaction.uri=${MULTI_MONGOS_LB_URI} \
${GRADLE_EXTRA_VARS} --stacktrace --info --continue driver-sync:test \
--tests LoadBalancerTest \
--tests RetryableReadsTest \
--tests RetryableWritesTest \
--tests VersionedApiTest \
--tests ChangeStreamsTest \
--tests UnifiedCrudTest \
--tests UnifiedTransactionsTest \
--tests InitialDnsSeedlistDiscoveryTest
first=$?
echo $first
./gradlew -PjdkHome=/opt/java/${JDK} \
-Dorg.mongodb.test.uri=${SINGLE_MONGOS_LB_URI} \
-Dorg.mongodb.test.transaction.uri=${MULTI_MONGOS_LB_URI} \
${GRADLE_EXTRA_VARS} --stacktrace --info --continue driver-reactive-stream:test \
--tests LoadBalancerTest \
--tests RetryableReadsTest \
--tests RetryableWritesTest \
--tests VersionedApiTest \
--tests ChangeStreamsTest \
--tests UnifiedCrudTest \
--tests UnifiedTransactionsTest \
--tests InitialDnsSeedlistDiscoveryTest
second=$?
echo $second
./gradlew -PjdkHome=/opt/java/${JDK} \
-Dorg.mongodb.test.uri=${SINGLE_MONGOS_LB_URI} \
-Dorg.mongodb.test.transaction.uri=${MULTI_MONGOS_LB_URI} \
${GRADLE_EXTRA_VARS} --stacktrace --info --continue driver-core:test \
--tests QueryBatchCursorFunctionalSpecification
third=$?
echo $third
if [ $first -ne 0 ]; then
exit $first
elif [ $second -ne 0 ]; then
exit $second
elif [ $third -ne 0 ]; then
exit $third
else
exit 0
fi