Skip to content

Commit

Permalink
Merge pull request #936 from IamTheFij/parallel-tests
Browse files Browse the repository at this point in the history
Run slow tests in parallel to improve overall test time
  • Loading branch information
crazy-max authored Sep 12, 2023
2 parents 6ba7dbe + ba3dd0d commit 052a472
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RUN --mount=type=bind,target=. \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build <<EOT
set -ex
go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic -race ./...
go test -parallel 4 -v -coverprofile=/tmp/coverage.txt -covermode=atomic -race ./...
go tool cover -func=/tmp/coverage.txt
EOT

Expand Down
5 changes: 5 additions & 0 deletions pkg/registry/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestCompareDigest(t *testing.T) {
t.Parallel()
rc, err := registry.New(registry.Options{
CompareDigest: true,
})
Expand Down Expand Up @@ -38,6 +39,7 @@ func TestCompareDigest(t *testing.T) {
}

func TestManifest(t *testing.T) {
t.Parallel()
rc, err := registry.New(registry.Options{
CompareDigest: true,
ImageOs: "linux",
Expand Down Expand Up @@ -98,6 +100,7 @@ func TestManifest(t *testing.T) {
}

func TestManifestMultiUpdatedPlatform(t *testing.T) {
t.Parallel()
rc, err := registry.New(registry.Options{
CompareDigest: true,
ImageOs: "linux",
Expand Down Expand Up @@ -177,6 +180,7 @@ func TestManifestMultiUpdatedPlatform(t *testing.T) {
}

func TestManifestMultiNotUpdatedPlatform(t *testing.T) {
t.Parallel()
rc, err := registry.New(registry.Options{
CompareDigest: true,
ImageOs: "linux",
Expand Down Expand Up @@ -256,6 +260,7 @@ func TestManifestMultiNotUpdatedPlatform(t *testing.T) {
}

func TestManifestVariant(t *testing.T) {
t.Parallel()
rc, err := registry.New(registry.Options{
ImageOs: "linux",
ImageArch: "arm",
Expand Down
77 changes: 39 additions & 38 deletions pkg/registry/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,6 @@ func TestTags(t *testing.T) {
}

func TestTagsSort(t *testing.T) {
repotags := []string{
"0.1.0",
"0.4.0",
"3.0.0-beta.1",
"3.0.0-beta.3",
"3.0.0-beta.4",
"4",
"4.0.0",
"4.0.0-beta.1",
"4.1.0",
"4.1.1",
"4.10.0",
"4.11.0",
"4.12.0",
"4.13.0",
"4.14.0",
"4.19.0",
"4.2.0",
"4.20",
"4.20.0",
"4.20.1",
"4.21",
"4.21.0",
"4.3.0",
"4.3.1",
"4.4.0",
"4.6.1",
"4.7.0",
"4.8.0",
"4.8.1",
"4.9.0",
"ubuntu-5.0",
"alpine-5.0",
"edge",
"latest",
}

testCases := []struct {
name string
sortTag registry.SortTag
Expand Down Expand Up @@ -155,10 +118,10 @@ func TestTagsSort(t *testing.T) {
name: "sort reverse",
sortTag: registry.SortTagReverse,
expected: []string{
"ubuntu-5.0",
"latest",
"edge",
"alpine-5.0",
"ubuntu-5.0",
"4.9.0",
"4.8.1",
"4.8.0",
Expand Down Expand Up @@ -235,7 +198,45 @@ func TestTagsSort(t *testing.T) {

for _, tt := range testCases {
tt := tt
repotags := []string{
"0.1.0",
"0.4.0",
"3.0.0-beta.1",
"3.0.0-beta.3",
"3.0.0-beta.4",
"4",
"4.0.0",
"4.0.0-beta.1",
"4.1.0",
"4.1.1",
"4.10.0",
"4.11.0",
"4.12.0",
"4.13.0",
"4.14.0",
"4.19.0",
"4.2.0",
"4.20",
"4.20.0",
"4.20.1",
"4.21",
"4.21.0",
"4.3.0",
"4.3.1",
"4.4.0",
"4.6.1",
"4.7.0",
"4.8.0",
"4.8.1",
"4.9.0",
"ubuntu-5.0",
"alpine-5.0",
"edge",
"latest",
}

t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tags := registry.SortTags(repotags, tt.sortTag)
assert.Equal(t, tt.expected, tags)
})
Expand Down

0 comments on commit 052a472

Please sign in to comment.