mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
Run slow tests in parallel to improve overall test time
This commit is contained in:
@@ -35,7 +35,7 @@ RUN --mount=type=bind,target=. \
|
|||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
--mount=type=cache,target=/root/.cache/go-build <<EOT
|
--mount=type=cache,target=/root/.cache/go-build <<EOT
|
||||||
set -ex
|
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
|
go tool cover -func=/tmp/coverage.txt
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCompareDigest(t *testing.T) {
|
func TestCompareDigest(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rc, err := registry.New(registry.Options{
|
rc, err := registry.New(registry.Options{
|
||||||
CompareDigest: true,
|
CompareDigest: true,
|
||||||
})
|
})
|
||||||
@@ -38,6 +39,7 @@ func TestCompareDigest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestManifest(t *testing.T) {
|
func TestManifest(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rc, err := registry.New(registry.Options{
|
rc, err := registry.New(registry.Options{
|
||||||
CompareDigest: true,
|
CompareDigest: true,
|
||||||
ImageOs: "linux",
|
ImageOs: "linux",
|
||||||
@@ -98,6 +100,7 @@ func TestManifest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestManifestMultiUpdatedPlatform(t *testing.T) {
|
func TestManifestMultiUpdatedPlatform(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rc, err := registry.New(registry.Options{
|
rc, err := registry.New(registry.Options{
|
||||||
CompareDigest: true,
|
CompareDigest: true,
|
||||||
ImageOs: "linux",
|
ImageOs: "linux",
|
||||||
@@ -177,6 +180,7 @@ func TestManifestMultiUpdatedPlatform(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestManifestMultiNotUpdatedPlatform(t *testing.T) {
|
func TestManifestMultiNotUpdatedPlatform(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rc, err := registry.New(registry.Options{
|
rc, err := registry.New(registry.Options{
|
||||||
CompareDigest: true,
|
CompareDigest: true,
|
||||||
ImageOs: "linux",
|
ImageOs: "linux",
|
||||||
@@ -256,6 +260,7 @@ func TestManifestMultiNotUpdatedPlatform(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestManifestVariant(t *testing.T) {
|
func TestManifestVariant(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rc, err := registry.New(registry.Options{
|
rc, err := registry.New(registry.Options{
|
||||||
ImageOs: "linux",
|
ImageOs: "linux",
|
||||||
ImageArch: "arm",
|
ImageArch: "arm",
|
||||||
|
|||||||
@@ -29,43 +29,6 @@ func TestTags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTagsSort(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 {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
sortTag registry.SortTag
|
sortTag registry.SortTag
|
||||||
@@ -155,10 +118,10 @@ func TestTagsSort(t *testing.T) {
|
|||||||
name: "sort reverse",
|
name: "sort reverse",
|
||||||
sortTag: registry.SortTagReverse,
|
sortTag: registry.SortTagReverse,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"ubuntu-5.0",
|
|
||||||
"latest",
|
"latest",
|
||||||
"edge",
|
"edge",
|
||||||
"alpine-5.0",
|
"alpine-5.0",
|
||||||
|
"ubuntu-5.0",
|
||||||
"4.9.0",
|
"4.9.0",
|
||||||
"4.8.1",
|
"4.8.1",
|
||||||
"4.8.0",
|
"4.8.0",
|
||||||
@@ -235,7 +198,45 @@ func TestTagsSort(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range testCases {
|
for _, tt := range testCases {
|
||||||
tt := tt
|
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.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tags := registry.SortTags(repotags, tt.sortTag)
|
tags := registry.SortTags(repotags, tt.sortTag)
|
||||||
assert.Equal(t, tt.expected, tags)
|
assert.Equal(t, tt.expected, tags)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user