Skip to content

Commit 3de944f

Browse files
test test
1 parent 354e672 commit 3de944f

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

.github/workflows/acceptance-tests.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,32 @@ jobs:
2222

2323
- uses: actions/checkout@v3
2424

25-
- name: Run tests
25+
- name: Install test helper (gotestsum)
2626
run: |
27-
TF_ACC=1 go test -v ./... -parallel=6 -timeout=30m
27+
echo "Installing gotestsum for selective test reruns"
28+
go install gotest.tools/gotestsum@v1.12.0
29+
env:
30+
GOPATH: ${{ runner.temp }}/go
31+
id: gotestsum
32+
33+
- name: Run acceptance tests with reruns
34+
run: |
35+
chmod +x scripts/run-acc-tests.sh
36+
PATH="${{ runner.temp }}/go/bin:$PATH" TF_ACC=1 CLOUDSMITH_NAMESPACE=terraform-provider-testing \
37+
CLOUDSMITH_API_KEY='${{ secrets.CLOUDSMITH_API_KEY }}' \
38+
./scripts/run-acc-tests.sh
2839
env:
2940
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
3041
CLOUDSMITH_NAMESPACE: terraform-provider-testing
3142

43+
- name: Upload test report
44+
if: always()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: acceptance-test-report
48+
path: test-report.xml
49+
if-no-files-found: warn
50+
3251
- name: Notify Slack on Success
3352
if: success()
3453
uses: rtCamp/action-slack-notify@v2.0.2

cloudsmith/resource_repository_upstream_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ resource "cloudsmith_repository" "test" {
133133
}
134134
135135
resource "cloudsmith_repository_upstream" "ubuntu" {
136-
distro_versions = ["ubuntu/trusty"]
136+
distro_versions = ["ubuntu/trusty", "ubuntu/xenial"]
137137
namespace = cloudsmith_repository.test.namespace
138138
repository = cloudsmith_repository.test.slug
139139
name = cloudsmith_repository.test.name

scripts/run-acc-tests.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Purpose: Run Terraform provider acceptance tests with automatic selective re-runs
3+
# of only the failing tests to mitigate flakiness (e.g. transient upstream/network issues).
4+
#
5+
# Environment variables (override as needed):
6+
# PARALLEL Go test -parallel value (default 6)
7+
# TIMEOUT Per test package timeout (default 30m)
8+
# RERUN_MAX_TIMES How many times to re-run a failing test (default 2)
9+
# RERUN_FAILS Max number of distinct failing tests eligible for rerun (default 50)
10+
# EXTRA_ARGS Extra args to pass through to `go test` after the rerun flags
11+
# TF_ACC Forced to 1 if unset (enables acceptance tests)
12+
#
13+
# Output:
14+
# - test-report.xml (JUnit format) for CI annotation
15+
# - streaming stdout with concise first-run + rerun summaries
16+
# - exit code 0 only if all tests eventually pass within rerun budget
17+
#
18+
# Requires: gotestsum (installed automatically if missing)
19+
set -euo pipefail
20+
21+
PARALLEL=${PARALLEL:-6}
22+
TIMEOUT=${TIMEOUT:-30m}
23+
RERUN_MAX_TIMES=${RERUN_MAX_TIMES:-2}
24+
RERUN_FAILS=${RERUN_FAILS:-50}
25+
EXTRA_ARGS=${EXTRA_ARGS:-}
26+
27+
export TF_ACC=${TF_ACC:-1}
28+
29+
if ! command -v gotestsum >/dev/null 2>&1; then
30+
echo "[INFO] Installing gotestsum (not found in PATH)" >&2
31+
# Pin a version for reproducibility; update periodically.
32+
go install gotest.tools/gotestsum@v1.12.0
33+
fi
34+
35+
echo "[INFO] Running acceptance tests with selective reruns"
36+
echo " parallel=${PARALLEL} timeout=${TIMEOUT} rerun_max_times=${RERUN_MAX_TIMES} rerun_fails=${RERUN_FAILS}" \
37+
" extra_args='${EXTRA_ARGS}'"
38+
39+
# We disable test caching (-count=1) to ensure fresh runs against live APIs.
40+
set +e
41+
gotestsum --format=short-verbose \
42+
--junitfile test-report.xml \
43+
--rerun-fails="${RERUN_FAILS}" \
44+
--rerun-fails-max-times="${RERUN_MAX_TIMES}" \
45+
--packages="./..." \
46+
-- -count=1 -parallel="${PARALLEL}" -timeout="${TIMEOUT}" ${EXTRA_ARGS}
47+
status=$?
48+
set -e
49+
50+
if [ $status -ne 0 ]; then
51+
echo "[ERROR] Acceptance tests failed after selective reruns." >&2
52+
else
53+
echo "[INFO] All acceptance tests passed (including reruns)." >&2
54+
fi
55+
56+
exit $status

0 commit comments

Comments
 (0)