Skip to content

Commit bd84bf4

Browse files
committed
conformance tests: more parallelization
Parallelize more subtests. Use t.Cleanup() instead of "defer" for a few cleanups. CI: don't run "make all" before making the test target; we fixed the target dependencies in the Makefile so that targets ensure that what they need has been built before use. CI: build the buildah binary for the buildah_version and buildah_info tasks. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
1 parent 23cf340 commit bd84bf4

4 files changed

Lines changed: 37 additions & 31 deletions

File tree

contrib/ci/logcollector.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ case $1 in
3333
df) showrun df -lhTx tmpfs ;;
3434
journal) showrun journalctl -b ;;
3535
podman) showrun podman system info ;;
36-
buildah_version) showrun "$GOSRC/bin/buildah" version ;;
37-
buildah_info) showrun "$GOSRC/bin/buildah" info ;;
36+
buildah_version) make bin/buildah && showrun "$GOSRC/bin/buildah" version ;;
37+
buildah_info) make bin/buildah && showrun "$GOSRC/bin/buildah" info ;;
3838
golang) showrun go version ;;
3939
packages)
4040
PKG_NAMES=(\

contrib/ci/runner.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,13 @@ function run_conformance() {
9898
}
9999

100100
function run_integration() {
101-
make all
102101
$SUDO make test-integration
103102
}
104103

105104
function run_in_podman() {
106105
export IN_PODMAN=true
107106
export BUILDAH_ISOLATION=chroot
108107
export STORAGE_DRIVER=vfs
109-
make all
110108
$SUDO make test-integration
111109
}
112110

tests/conformance/conformance_test.go

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"slices"
2020
"strconv"
2121
"strings"
22-
"sync"
2322
"syscall"
2423
"testing"
2524
"text/tabwriter"
@@ -53,6 +52,7 @@ import (
5352
"go.podman.io/storage/pkg/idtools"
5453
"go.podman.io/storage/pkg/ioutils"
5554
"go.podman.io/storage/pkg/reexec"
55+
"golang.org/x/sync/errgroup"
5656
)
5757

5858
const (
@@ -152,7 +152,6 @@ func TestMain(m *testing.M) {
152152
}
153153

154154
func TestConformance(t *testing.T) {
155-
t.Parallel()
156155
dateStamp := fmt.Sprintf("%d", time.Now().UnixNano())
157156
for i := range internalTestCases {
158157
t.Run(internalTestCases[i].name, func(t *testing.T) {
@@ -196,6 +195,11 @@ func TestConformance(t *testing.T) {
196195

197196
func testConformanceInternal(t *testing.T, dateStamp string, testIndex int, mutate func(*testCase)) {
198197
test := internalTestCases[testIndex]
198+
199+
if !test.dontParallelize {
200+
t.Parallel()
201+
}
202+
199203
if mutate != nil {
200204
mutate(&test)
201205
}
@@ -232,28 +236,25 @@ func testConformanceInternal(t *testing.T, dateStamp string, testIndex int, muta
232236
// copy either a directory or just a Dockerfile into the temporary directory
233237
pipeReader, pipeWriter := io.Pipe()
234238
var getErr, putErr error
235-
var wg sync.WaitGroup
236-
wg.Add(1)
237-
go func() {
239+
var eg errgroup.Group
240+
eg.Go(func() error {
238241
if test.contextDir != "" {
239242
getErr = copier.Get("", testDataDir, copier.GetOptions{}, []string{test.contextDir}, pipeWriter)
240243
} else if test.dockerfile != "" {
241244
getErr = copier.Get("", testDataDir, copier.GetOptions{}, []string{test.dockerfile}, pipeWriter)
242245
}
243-
pipeWriter.Close()
244-
wg.Done()
245-
}()
246-
wg.Add(1)
247-
go func() {
246+
return errors.Join(getErr, pipeWriter.Close())
247+
})
248+
eg.Go(func() error {
248249
if test.contextDir != "" || test.dockerfile != "" {
249250
putErr = copier.Put("", contextDir, copier.PutOptions{}, pipeReader)
250251
} else {
251252
putErr = os.Mkdir(contextDir, 0o755)
252253
}
253-
pipeReader.Close()
254-
wg.Done()
255-
}()
256-
wg.Wait()
254+
return errors.Join(putErr, pipeReader.Close())
255+
})
256+
err = eg.Wait()
257+
assert.NoErrorf(t, err, "error copying build info from %q", filepath.Join("testdata", test.dockerfile))
257258
assert.NoErrorf(t, getErr, "error reading build info from %q", filepath.Join("testdata", test.dockerfile))
258259
assert.NoErrorf(t, putErr, "error writing build info to %q", contextDir)
259260
if t.Failed() {
@@ -295,12 +296,12 @@ func testConformanceInternal(t *testing.T, dateStamp string, testIndex int, muta
295296
}
296297
store, err := storage.GetStore(options)
297298
require.NoErrorf(t, err, "error creating buildah storage at %q", rootDir)
298-
defer func() {
299+
t.Cleanup(func() {
299300
if store != nil {
300301
_, err := store.Shutdown(true)
301302
require.NoError(t, err, "error shutting down storage for buildah")
302303
}
303-
}()
304+
})
304305
storageDriver := store.GraphDriverName()
305306
storageRoot := store.GraphRoot()
306307

@@ -460,13 +461,13 @@ func testConformanceInternalBuild(ctx context.Context, t *testing.T, cwd string,
460461
if compareImagebuilder && !test.withoutImagebuilder {
461462
imagebuilderRef, imagebuilderLog = buildUsingImagebuilder(t, client, test, imagebuilderImage, contextDir, dockerfileName, line, finalOfSeveral)
462463
if imagebuilderRef != nil {
463-
defer func() {
464+
t.Cleanup(func() {
464465
err := client.RemoveImageExtended(imagebuilderImage, docker.RemoveImageOptions{
465466
Context: ctx,
466467
Force: true,
467468
})
468469
assert.Nil(t, err, "error deleting newly-built-by-imagebuilder image %q", imagebuilderImage)
469-
}()
470+
})
470471
}
471472
saveReport(ctx, t, imagebuilderRef, filepath.Join(imagebuilderDir, t.Name()), dockerfileContents, imagebuilderLog, dockerVersion)
472473
if finalOfSeveral && compareLayers {
@@ -481,10 +482,10 @@ func testConformanceInternalBuild(ctx context.Context, t *testing.T, cwd string,
481482
// always build using buildah
482483
buildahRef, buildahLog = buildUsingBuildah(ctx, t, store, test, buildahImage, contextDir, dockerfileName, line, finalOfSeveral)
483484
if buildahRef != nil {
484-
defer func() {
485+
t.Cleanup(func() {
485486
err := buildahRef.DeleteImage(ctx, nil)
486487
assert.Nil(t, err, "error deleting newly-built-by-buildah image %q", buildahImage)
487-
}()
488+
})
488489
}
489490
saveReport(ctx, t, buildahRef, filepath.Join(buildahDir, t.Name()), dockerfileContents, buildahLog, nil)
490491
if finalOfSeveral && compareLayers {
@@ -1449,6 +1450,7 @@ type (
14491450

14501451
fsSkipCompatVolumesTrue []string // more expected filesystem differences when compatVolumes=true
14511452
buildArgs map[string]string // build args to supply, as if --build-arg was used
1453+
dontParallelize bool // uses shared state managed elsewhere
14521454
}
14531455
)
14541456

@@ -3794,20 +3796,22 @@ var internalTestCases = []testCase{
37943796
},
37953797
{
37963798
name: "mount-cache-by-ownership",
3799+
dontParallelize: true, // the docker build seems to fail without this?
37973800
dockerUseBuildKit: true,
37983801
dockerfileContents: strings.Join([]string{
37993802
"FROM mirror.gcr.io/busybox",
38003803
"USER 10",
38013804
"RUN --mount=type=cache,uid=10,target=/cache touch /cache/10.txt",
38023805
"USER 0",
38033806
"RUN --mount=type=cache,target=/cache touch /cache/0.txt",
3807+
"RUN --mount=type=cache,uid=10,target=/cache touch /cache/0+10.txt",
38043808
"RUN mkdir -m 770 /results /results/0 /results/10 /results/0+10",
38053809
"RUN chown -R 10 /results",
3806-
"RUN --mount=type=cache,target=/cache cp -a /cache/* /results/0",
3810+
"RUN --mount=type=cache,target=/cache cp -av /cache/* /results/0",
38073811
"USER 10",
3808-
"RUN --mount=type=cache,uid=10,target=/cache cp -a /cache/* /results/10",
3812+
"RUN --mount=type=cache,uid=10,target=/cache cp -av /cache/* /results/10",
38093813
"USER 0",
3810-
"RUN --mount=type=cache,uid=10,target=/cache cp -a /cache/* /results/0+10",
3814+
"RUN --mount=type=cache,uid=10,target=/cache cp -av /cache/* /results/0+10",
38113815
"RUN touch -r /bin `find /results -print`",
38123816
}, "\n"),
38133817
},
@@ -3895,12 +3899,12 @@ var internalTestCases = []testCase{
38953899
}
38963900

38973901
func TestCommit(t *testing.T) {
3898-
t.Parallel()
38993902
testCases := []struct {
39003903
description string
39013904
baseImage string
39023905
changes, derivedChanges []string
39033906
config, derivedConfig *docker.Config
3907+
dontParallelize bool // uses shared state that lives elsewhere
39043908
}{
39053909
{
39063910
description: "defaults",
@@ -4239,16 +4243,20 @@ func TestCommit(t *testing.T) {
42394243
}
42404244
store, err := storage.GetStore(options)
42414245
require.NoErrorf(t, err, "error creating buildah storage at %q", rootDir)
4242-
defer func() {
4246+
t.Cleanup(func() {
42434247
if store != nil {
42444248
_, err := store.Shutdown(true)
42454249
require.NoErrorf(t, err, "error shutting down storage for buildah")
42464250
}
4247-
}()
4251+
})
42484252

42494253
// walk through test cases
42504254
for testIndex, testCase := range testCases {
42514255
t.Run(testCase.description, func(t *testing.T) {
4256+
if !testCase.dontParallelize {
4257+
t.Parallel()
4258+
}
4259+
42524260
test := testCases[testIndex]
42534261

42544262
// create the test container, then commit it, using the docker client

tests/conformance/testdata/Dockerfile.edgecases

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: Hopefully a registries.conf alias redirects this to quay.io/libpod/mirror.gcr.io/busybox
1+
# Note: Hopefully a registries.conf alias redirects this to quay.io/libpod/busybox
22
FROM mirror.gcr.io/busybox
33

44
MAINTAINER docker <docker@docker.io>

0 commit comments

Comments
 (0)