1+ #! /bin/bash
2+
3+ # ###########################################################
4+ # # Start and stop the Pact Mock Server daemon ##
5+ # ###########################################################
6+
7+ LIBDIR=$( dirname " $0 " )
8+ . " ${LIBDIR} /lib"
9+
10+ trap shutdown INT
11+ CUR_DIR=$( pwd)
12+ function shutdown() {
13+ step " Shutting down stub server"
14+ log " Finding Pact daemon PID"
15+ PID=$( ps -ef | grep pact-go | awk -F" " ' {print $2}' | head -n 1)
16+ if [ " ${PID} " != " " ]; then
17+ log " Killing ${PID} "
18+ kill $PID
19+ fi
20+ cd $CUR_DIR
21+ }
22+
23+ # mkdir -p bin
24+ if [ ! -f " dist/pact-go" ]; then
25+ cd dist
26+ platform=$( detect_os)
27+ archive=" ${platform} -amd64.tar.gz"
28+ step " Installing Pact Go for ${platform} "
29+
30+ if [ ! -f " ${archive} " ]; then
31+ log " Cannot find distribution package ${archive} , please run 'make package' first"
32+ exit 1
33+ fi
34+
35+ log " Expanding archive"
36+ if [[ $platform == ' linux' ]]; then
37+ tar -xf $archive
38+ mv pact-go_linux_amd64 pact-go
39+ elif [[ $platform == ' darwin' ]]; then
40+ tar -xf $archive
41+ mv pact-go_darwin_amd64 pact-go
42+ else
43+ log " Unsupported platform ${platform} "
44+ exit 1
45+ fi
46+
47+ cd ..
48+ log " Done"
49+ fi
50+
51+ step " Starting Daemon"
52+ mkdir -p ./logs
53+ ./dist/pact-go daemon -v -l DEBUG > logs/daemon.log 2>&1 &
54+
55+ step " Running integration tests"
56+ export PACT_INTEGRATED_TESTS=1
57+ export PACT_BROKER_HOST=" https://test.pact.dius.com.au"
58+ export PACT_BROKER_USERNAME=" dXfltyFMgNOFZAxr8io9wJ37iUpY42M"
59+ export PACT_BROKER_PASSWORD=" JN4kVfO5AIZWxelWbLvqMd8PkAVycBJh2Psyg11wtkubJC4xlOH5GmIfwO9gWe"
60+ cd dsl
61+ go test -run TestPact_Integration
62+ EXIT_CODE=$?
63+ cd ..
64+
65+ shutdown
66+
67+ # step "Stopping Metrics API"
68+ # make stop
69+
70+ if [ " ${EXIT_CODE} " = " 0" ]; then
71+ step " Integration testing succeeded!"
72+ else
73+ step " Integration testing failed, see stack trace above"
74+ fi
75+
76+ exit $EXIT_CODE
0 commit comments