Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d96065f

Browse files
committed
Randomize test order
I don't know why this isn't the default behavior, but relying on test order is a bad idea (TM) that we should do our best to avoid. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 81c3a16 commit d96065f

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

Makefile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,84 +26,84 @@ lint:
2626
.PHONY: lint
2727

2828
unit:
29-
go test ./...
29+
go test -shuffle on ./...
3030
.PHONY: unit
3131

3232
coverage:
33-
go test -covermode count -coverprofile cover.out -coverpkg=./... ./...
33+
go test -shuffle on -covermode count -coverprofile cover.out -coverpkg=./... ./...
3434
.PHONY: coverage
3535

3636
acceptance: acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-imageservice acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow
3737
.PHONY: acceptance
3838

3939
acceptance-baremetal:
40-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/...
40+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/...
4141
.PHONY: acceptance-baremetal
4242

4343
acceptance-blockstorage:
44-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/blockstorage/...
44+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/blockstorage/...
4545
.PHONY: acceptance-blockstorage
4646

4747
acceptance-compute:
48-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/compute/...
48+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/compute/...
4949
.PHONY: acceptance-compute
5050

5151
acceptance-container:
52-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/container/...
52+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/container/...
5353
.PHONY: acceptance-container
5454

5555
acceptance-containerinfra:
56-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/containerinfra/...
56+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/containerinfra/...
5757
.PHONY: acceptance-containerinfra
5858

5959
acceptance-db:
60-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/db/...
60+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/db/...
6161
.PHONY: acceptance-db
6262

6363
acceptance-dns:
64-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/dns/...
64+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/dns/...
6565
.PHONY: acceptance-dns
6666

6767
acceptance-identity:
68-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/identity/...
68+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/identity/...
6969
.PHONY: acceptance-identity
7070

7171
acceptance-image:
72-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/imageservice/...
72+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/imageservice/...
7373
.PHONY: acceptance-image
7474

7575
acceptance-keymanager:
76-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/keymanager/...
76+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/keymanager/...
7777
.PHONY: acceptance-keymanager
7878

7979
acceptance-loadbalancer:
80-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/loadbalancer/...
80+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/loadbalancer/...
8181
.PHONY: acceptance-loadbalancer
8282

8383
acceptance-messaging:
84-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/messaging/...
84+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/messaging/...
8585
.PHONY: acceptance-messaging
8686

8787
acceptance-networking:
88-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/networking/...
88+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/networking/...
8989
.PHONY: acceptance-networking
9090

9191
acceptance-objectstorage:
92-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/objectstorage/...
92+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/objectstorage/...
9393
.PHONY: acceptance-objectstorage
9494

9595
acceptance-orchestration:
96-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/orchestration/...
96+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/orchestration/...
9797
.PHONY: acceptance-orchestration
9898

9999
acceptance-placement:
100-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/placement/...
100+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/placement/...
101101
.PHONY: acceptance-placement
102102

103103
acceptance-sharedfilesystems:
104-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/sharedfilesystems/...
104+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/sharedfilesystems/...
105105
.PHONY: acceptance-sharefilesystems
106106

107107
acceptance-workflow:
108-
go test -tags "fixtures acceptance" ./internal/acceptance/openstack/workflow/...
108+
go test -shuffle on -tags "fixtures acceptance" ./internal/acceptance/openstack/workflow/...
109109
.PHONY: acceptance-workflow

script/acceptancetest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ if [[ -z "${LOG_DIR}" ]]; then
2222
fi
2323
mkdir -p ${LOG_DIR}
2424

25-
go test -v -timeout $timeout -tags "fixtures acceptance" ${PACKAGE:-./internal/acceptance/openstack/...} $@ |& tee -a ${LOG_DIR}/acceptance_tests.log
25+
go test -v -shuffle on -timeout $timeout -tags "fixtures acceptance" ${PACKAGE:-./internal/acceptance/openstack/...} $@ |& tee -a ${LOG_DIR}/acceptance_tests.log

script/coverage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ set -euxo pipefail
77
n=1
88
for testpkg in $(go list ./testing ./.../testing); do
99
covpkg="${testpkg/"/testing"/}"
10-
go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$covpkg" "$testpkg" 2>/dev/null
10+
go test -shuffle on -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$covpkg" "$testpkg" 2>/dev/null
1111
n=$((n+1))
1212
done
1313

1414
base_pkg=$(go list)
1515
# Look for additional test files
1616
for path in $(find . -path '*/testing' -prune -o -path '*/internal' -prune -o -name '*_test.go' -exec dirname {} \; | uniq); do
1717
pkg="${base_pkg}${path:1}"
18-
go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$pkg" "$pkg" 2>/dev/null
18+
go test -shuffle on -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$pkg" "$pkg" 2>/dev/null
1919
n=$((n+1))
2020
done
2121

script/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
set -euxo pipefail
66

7-
go test -v -tags 'acceptance fixtures' ./... $@
7+
go test -v -shuffle on -tags 'acceptance fixtures' ./... $@

script/unittest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -euxo pipefail
66

77
# Do extra rounds of testing to help identify reauth concurrency issues.
88
# All other packages are tested in the `coverage` tests.
9-
go test -v -race -count=5 ./testing $@
9+
go test -v -shuffle on -race -count=5 ./testing $@

0 commit comments

Comments
 (0)