Skip to content

Commit 9a58a84

Browse files
committed
JAVA-2368: Upload mongo-orchestration and server logs to S3 after each test run
1 parent af0dfa6 commit 9a58a84

File tree

1 file changed

+68
-29
lines changed

1 file changed

+68
-29
lines changed

.evg.yml

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,9 @@ functions:
5353
5454
mkdir -p $(dirname "$ORCHESTRATION_FILE")
5555
56-
# Borrow MO config from the C driver
57-
#
58-
curl --location "https://raw.githubusercontent.com/mongodb/mongo-c-driver/master/orchestration_configs/${topology_type}s/${orchestration_file}" > "$ORCHESTRATION_FILE"
59-
export ORCHESTRATION_URL="http://localhost:8889/v1/${topology_type}s"
60-
export MONGO_ORCHESTRATION_HOME=/tmp/orchestration-home
61-
62-
if [ ! -d /tmp/orchestration-home ]; then
63-
mkdir /tmp/orchestration-home
64-
fi
65-
6656
${start_mongo_orchestration}
6757
${start_topology}
6858
69-
7059
mongodb_test_uri="mongodb://${auth_uri_prefix}${hosts}"
7160
7261
./gradlew -Dorg.mongodb.test.uri=$mongodb_test_uri --stacktrace --info test
@@ -76,8 +65,52 @@ functions:
7665
params:
7766
file: ./mongo-java-driver/*/build/test-results/TEST-*.xml
7867

68+
"upload mo artifacts":
69+
- command: shell.exec
70+
params:
71+
working_dir: "mongo-java-driver"
72+
script: |
73+
set -o verbose
74+
set -o errexit
7975
80-
#######################################
76+
[ -d MO ] && find MO -name mongo*.log | xargs tar czf mongodb-logs.tgz
77+
[ -f mongodb-logs.tgz ] && tar ztvf mongodb-logs.tgz
78+
79+
[ -d MO ] && tar czf mongodb-orchestration-logs.tgz MO/*.log
80+
[ -f mongodb-orchestration-logs.tgz ] && tar ztvf mongodb-orchestration-logs.tgz
81+
- command: s3.put
82+
params:
83+
aws_key: ${aws_key}
84+
aws_secret: ${aws_secret}
85+
local_file: mongo-java-driver/mongodb-logs.tgz
86+
remote_file: mongo-java-driver/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-logs.tgz
87+
bucket: mciuploads
88+
permissions: public-read
89+
content_type: ${content_type|application/x-gzip}
90+
display_name: "mongodb-logs.tar.gz"
91+
- command: s3.put
92+
params:
93+
aws_key: ${aws_key}
94+
aws_secret: ${aws_secret}
95+
local_file: mongo-java-driver/mongodb-orchestration-logs.tgz
96+
remote_file: mongo-java-driver/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-orchestration-logs.tgz
97+
bucket: mciuploads
98+
permissions: public-read
99+
content_type: ${content_type|application/x-gzip}
100+
display_name: "mongodb-orchestration-logs.tgz"
101+
102+
"cleanup" :
103+
command: shell.exec
104+
params:
105+
working_dir: "mongo-java-driver"
106+
script: |
107+
set -o errexit
108+
export MONGO_ORCHESTRATION_HOME=$(pwd)"/MO"
109+
export TMPDIR=$MONGO_ORCHESTRATION_HOME/db
110+
mongo-orchestration stop
111+
112+
113+
#####################################
81114
# Tasks #
82115
#######################################
83116

@@ -95,6 +128,8 @@ tasks:
95128
- func: "fetch mongodb"
96129
- func: "run tests"
97130
- func: "attach junit results"
131+
- func: "upload mo artifacts"
132+
- func: "cleanup"
98133

99134

100135
#######################################
@@ -107,26 +142,30 @@ scripts:
107142
mongo_orchestration:
108143
unix: &mongo_orchestration_unix
109144
start_mongo_orchestration: |
110-
trap 'set +o errexit; mongo-orchestration --pidfile /data/mo.pid stop;' EXIT
111-
pidfile=/data/mo.pid
112-
if [ -f $pidfile ]; then
113-
echo "Existing pidfile $pidfile"
114-
cat $pidfile
115-
mongo-orchestration --pidfile /data/mo.pid stop;
116-
rm -f $pidfile
117-
fi
118-
df -h
119-
ls -la
120-
echo "Starting Mongo Orchestration..."
145+
echo "Starting MongoDB Orchestration..."
146+
147+
# Borrow MO config from the C driver
148+
curl --location "https://raw.githubusercontent.com/mongodb/mongo-c-driver/master/orchestration_configs/${topology_type}s/${orchestration_file}" > "$ORCHESTRATION_FILE"
149+
export ORCHESTRATION_URL="http://localhost:8889/v1/${topology_type}s"
150+
export MONGO_ORCHESTRATION_HOME=$(pwd)"/MO"
151+
152+
rm -rf $MONGO_ORCHESTRATION_HOME
153+
mkdir -p $MONGO_ORCHESTRATION_HOME/lib
154+
mkdir -p $MONGO_ORCHESTRATION_HOME/db
155+
121156
echo "{ \"releases\": { \"default\": \"`pwd`/mongodb/bin\" } }" > orchestration.config
122-
TMPDIR=/data/db mongo-orchestration -f orchestration.config -e default start --socket-timeout-ms=60000 --bind=127.0.0.1 --enable-majority-read-concern --pidfile $pidfile
123-
curl -s http://localhost:8889/
157+
export TMPDIR=$MONGO_ORCHESTRATION_HOME/db
158+
nohup mongo-orchestration -f orchestration.config -e default --socket-timeout-ms=60000 --bind=127.0.0.1 --enable-majority-read-concern start > $MONGO_ORCHESTRATION_HOME/out.log 2> $MONGO_ORCHESTRATION_HOME/err.log < /dev/null &
159+
160+
sleep 15
161+
curl http://localhost:8889/ --silent --max-time 120 --fail
162+
echo "MongoDB Orchestration started..."
163+
sleep 5
124164
start_topology_command: &start_topology_command
125165
start_topology: |
126-
curl -s --data @"$ORCHESTRATION_FILE" "$ORCHESTRATION_URL"
127-
./mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS --eval 'printjson(db.serverBuildInfo())' admin
128-
./mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS --eval 'printjson(db.adminCommand({getCmdLineOpts:1}))' admin
129-
./mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS --eval 'printjson(db.isMaster())' admin
166+
echo "Starting MongoDB cluster..."
167+
curl --silent --data @"$ORCHESTRATION_FILE" "$ORCHESTRATION_URL" --max-time 300 --fail
168+
echo "MongoDB cluster started..."
130169
131170
132171
#######################################

0 commit comments

Comments
 (0)