Skip to content

Commit

Permalink
feat(e2e): run e2e tests in wercker builds. Fixes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Apr 28, 2017
1 parent 33a0434 commit f1ee33c
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ dev:
test:
"$(CURDIR)/scripts/test.sh"

pact:
"$(CURDIR)/scripts/pact.sh"

testrace:
go test -race $(TEST) $(TESTARGS)

Expand Down
21 changes: 21 additions & 0 deletions scripts/lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function step {
echo ""
echo " -----> $1"
}

function log {
echo " $1"
}

function detect_os {
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$OSTYPE" == "darwin"* ]]; then
platform='darwin'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
platform='freebsd'
fi
echo $platform
}
76 changes: 76 additions & 0 deletions scripts/pact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

############################################################
## Start and stop the Pact Mock Server daemon ##
############################################################

LIBDIR=$(dirname "$0")
. "${LIBDIR}/lib"

trap shutdown INT
CUR_DIR=$(pwd)
function shutdown() {
step "Shutting down stub server"
log "Finding Pact daemon PID"
PID=$(ps -ef | grep pact-go | awk -F" " '{print $2}' | head -n 1)
if [ "${PID}" != "" ]; then
log "Killing ${PID}"
kill $PID
fi
cd $CUR_DIR
}

# mkdir -p bin
if [ ! -f "dist/pact-go" ]; then
cd dist
platform=$(detect_os)
archive="${platform}-amd64.tar.gz"
step "Installing Pact Go for ${platform}"

if [ ! -f "${archive}" ]; then
log "Cannot find distribution package ${archive}, please run 'make package' first"
exit 1
fi

log "Expanding archive"
if [[ $platform == 'linux' ]]; then
tar -xf $archive
mv pact-go_linux_amd64 pact-go
elif [[ $platform == 'darwin' ]]; then
tar -xf $archive
mv pact-go_darwin_amd64 pact-go
else
log "Unsupported platform ${platform}"
exit 1
fi

cd ..
log "Done"
fi

step "Starting Daemon"
mkdir -p ./logs
./dist/pact-go daemon -v -l DEBUG > logs/daemon.log 2>&1 &

step "Running integration tests"
export PACT_INTEGRATED_TESTS=1
export PACT_BROKER_HOST="https://test.pact.dius.com.au"
export PACT_BROKER_USERNAME="dXfltyFMgNOFZAxr8io9wJ37iUpY42M"
export PACT_BROKER_PASSWORD="JN4kVfO5AIZWxelWbLvqMd8PkAVycBJh2Psyg11wtkubJC4xlOH5GmIfwO9gWe"
cd dsl
go test -run TestPact_Integration
EXIT_CODE=$?
cd ..

shutdown

# step "Stopping Metrics API"
# make stop

if [ "${EXIT_CODE}" = "0" ]; then
step "Integration testing succeeded!"
else
step "Integration testing failed, see stack trace above"
fi

exit $EXIT_CODE
19 changes: 19 additions & 0 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ package:
ls -larth build
ls -larth output
integration:
steps:
- setup-go-workspace
- golint:
exclude: "vendor"
- script:
name: retrieve artifacts
code: |
mkdir -p output
mkdir -p build
if [ -d "$WERCKER_CACHE_DIR/build" ]; then cp -r $WERCKER_CACHE_DIR/build .; fi
if [ -d "$WERCKER_CACHE_DIR/output" ]; then cp -r $WERCKER_CACHE_DIR/output .; fi
ls -larth build
ls -larth output
- script:
name: pact
code: |
make pact
# TODO: Get tokens for Pact foundation
deploy:
steps:
Expand Down

0 comments on commit f1ee33c

Please sign in to comment.