From 429108b7caa30d2d719e9dbdf6ace0f35a37cf41 Mon Sep 17 00:00:00 2001 From: Otto Jongerius Date: Thu, 21 Feb 2019 15:06:25 +1300 Subject: [PATCH 1/4] Use different Datadog test account per build. This should remove build flake. Tests create and destroy resources, but use the total amount to determine success. This will not work well if we run acceptance test for another language version in parallel. --- .travis.yml | 4 +--- scripts/acceptance-tests.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 scripts/acceptance-tests.sh diff --git a/.travis.yml b/.travis.yml index deecba4..bec7f39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: go go: - - "1.9" - "1.10.x" - "1.11.x" - "tip" @@ -18,8 +17,7 @@ script: - golint ./... | grep -v vendor/ - make - scripts/check-code-generation-ran.sh - # PR's don't have access to Travis EnvVars with DDog API Keys. Skip acceptance tests on PR. - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make testacc; fi' + - scripts/acceptance-tests.sh matrix: allow_failures: diff --git a/scripts/acceptance-tests.sh b/scripts/acceptance-tests.sh new file mode 100755 index 0000000..8adeb41 --- /dev/null +++ b/scripts/acceptance-tests.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then + echo "Not running acceptance tests for pull requests" + exit 0 +fi + +# Using multiple Datadog accounts to minimise flakiness during parallel runs, as some tests rely +# an amount of items across a whole account. +case "$TRAVIS_GO_VERSION" in + 1.10*) + export DATADOG_API_KEY=${DATADOG_API_KEY_A:?} + export DATADOG_APP_KEY=${DATADOG_APP_KEY_A:?} + ;; + 1.11*) + export DATADOG_API_KEY=${DATADOG_API_KEY_B:?} + export DATADOG_APP_KEY=${DATADOG_APP_KEY_B:?} + ;; + *) + export DATADOG_API_KEY=${DATADOG_API_KEY_C:?} + export DATADOG_APP_KEY=${DATADOG_APP_KEY_C:?} + ;; +esac + +echo "Running acceptance tests" +make testacc From 0fa1a7053ae8e3936716215bd59e094fcd7aaa95 Mon Sep 17 00:00:00 2001 From: Otto Jongerius Date: Thu, 21 Feb 2019 16:05:51 +1300 Subject: [PATCH 2/4] Tell which test account we are using for this build --- scripts/acceptance-tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/acceptance-tests.sh b/scripts/acceptance-tests.sh index 8adeb41..2860532 100755 --- a/scripts/acceptance-tests.sh +++ b/scripts/acceptance-tests.sh @@ -11,14 +11,17 @@ case "$TRAVIS_GO_VERSION" in 1.10*) export DATADOG_API_KEY=${DATADOG_API_KEY_A:?} export DATADOG_APP_KEY=${DATADOG_APP_KEY_A:?} + echo "Using Datadog 'A' test account" ;; 1.11*) export DATADOG_API_KEY=${DATADOG_API_KEY_B:?} export DATADOG_APP_KEY=${DATADOG_APP_KEY_B:?} + echo "Using Datadog 'B' test account" ;; *) export DATADOG_API_KEY=${DATADOG_API_KEY_C:?} export DATADOG_APP_KEY=${DATADOG_APP_KEY_C:?} + echo "Using Datadog 'C' test account" ;; esac From 1240dc1146a151ec69bb3f3610a47cf445cf2b44 Mon Sep 17 00:00:00 2001 From: Otto Jongerius Date: Thu, 21 Feb 2019 16:06:33 +1300 Subject: [PATCH 3/4] Shell coding practices; Specify shell to use, no need for bashism --- scripts/check-code-generation-ran.sh | 4 +++- scripts/check-fmt.sh | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/check-code-generation-ran.sh b/scripts/check-code-generation-ran.sh index 5834bee..60534ee 100755 --- a/scripts/check-code-generation-ran.sh +++ b/scripts/check-code-generation-ran.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + # Make generate will always update datadog-accessors.go cp datadog-accessors.go datadog-accessors.go.bak @@ -9,7 +11,7 @@ changed=$? rm datadog-accessors.go.bak # See if contents have changed and error if they have -if [[ $changed != 0 ]] ; then +if [ $changed != 0 ] ; then echo "Did you run 'make generate' before committing?" exit 1 fi diff --git a/scripts/check-fmt.sh b/scripts/check-fmt.sh index cf9e27c..bdc257e 100755 --- a/scripts/check-fmt.sh +++ b/scripts/check-fmt.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash -diff -u <(echo -n) <(gofmt -s -d $(find . -name '*.go' | grep -v vendor)) - -# See if contents have changed and error if they have -if [[ $? != 0 ]] ; then +if ! diff -u <(echo -n) <(gofmt -s -d "$(find . -name '*.go' | grep -v vendor)") +then + # See if contents have changed and error if they have echo "Did you run 'make fmt' before committing?" exit 1 fi From 5462bc59f9e464a49a340ba48cf39619692998d8 Mon Sep 17 00:00:00 2001 From: Otto Jongerius Date: Thu, 21 Feb 2019 16:54:59 +1300 Subject: [PATCH 4/4] Should have no influence.. --- scripts/acceptance-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/acceptance-tests.sh b/scripts/acceptance-tests.sh index 2860532..d826bb0 100755 --- a/scripts/acceptance-tests.sh +++ b/scripts/acceptance-tests.sh @@ -26,4 +26,4 @@ case "$TRAVIS_GO_VERSION" in esac echo "Running acceptance tests" -make testacc +GOCACHE=off make testacc