Skip to content

chore: migrate test-fixtures to testdata#531

Merged
wagoodman merged 3 commits intomainfrom
move-test-fixtures
Mar 6, 2026
Merged

chore: migrate test-fixtures to testdata#531
wagoodman merged 3 commits intomainfrom
move-test-fixtures

Conversation

@wagoodman
Copy link
Copy Markdown
Contributor

@wagoodman wagoodman commented Mar 3, 2026

This PR does a few things:

  • removes the dependence on anchore/go-testutils
  • Adds testutils internal package for finding and migrating test paths (from test-fixtures to testdata)
  • reorients the image fixture test helpers (in pkg/imagetest) to use a testdata/cache over test-fixtures/cache (including auto migrations on test runs).

Note

This is a breaking change for users of the imagetest package (a package not meant for production)

@wagoodman wagoodman force-pushed the move-test-fixtures branch 2 times, most recently from 136981c to da43d34 Compare March 3, 2026 15:29
@wagoodman wagoodman changed the title Migrate test-fixtures to testdata chore: migrate test-fixtures to testdata Mar 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

Benchmark Test Results

Benchmark results from the latest changes vs base branch
make .tool/task
make[1]: Entering directory '/home/runner/work/stereoscope/stereoscope'
make[1]: Leaving directory '/home/runner/work/stereoscope/stereoscope'
.tool/task show-benchstat
?   	github.com/anchore/stereoscope	[no test files]
?   	github.com/anchore/stereoscope/examples	[no test files]
PASS
ok  	github.com/anchore/stereoscope/internal	0.004s
?   	github.com/anchore/stereoscope/internal/bus	[no test files]
PASS
ok  	github.com/anchore/stereoscope/internal/containerd	0.008s
PASS
ok  	github.com/anchore/stereoscope/internal/docker	0.005s
?   	github.com/anchore/stereoscope/internal/log	[no test files]
PASS
ok  	github.com/anchore/stereoscope/internal/podman	0.005s
?   	github.com/anchore/stereoscope/internal/testutil	[no test files]
?   	github.com/anchore/stereoscope/pkg/event	[no test files]
?   	github.com/anchore/stereoscope/pkg/event/parsers	[no test files]
goos: linux
goarch: amd64
pkg: github.com/anchore/stereoscope/pkg/file
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkTarIndex-4   	   26810	     44700 ns/op	    5700 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26751	     44772 ns/op	    5701 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26652	     45003 ns/op	    5703 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26564	     44755 ns/op	    5700 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26538	     44791 ns/op	    5702 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26914	     45710 ns/op	    5701 B/op	      93 allocs/op
BenchmarkTarIndex-4   	   26823	     45487 ns/op	    5703 B/op	      93 allocs/op
PASS
ok  	github.com/anchore/stereoscope/pkg/file	11.621s
PASS
ok  	github.com/anchore/stereoscope/pkg/filetree	0.005s
?   	github.com/anchore/stereoscope/pkg/filetree/filenode	[no test files]
PASS
ok  	github.com/anchore/stereoscope/pkg/image	0.006s
PASS
ok  	github.com/anchore/stereoscope/pkg/image/containerd	0.007s
PASS
ok  	github.com/anchore/stereoscope/pkg/image/docker	0.006s
PASS
ok  	github.com/anchore/stereoscope/pkg/image/oci	0.006s
PASS
ok  	github.com/anchore/stereoscope/pkg/image/oci/credhelpers	0.006s
?   	github.com/anchore/stereoscope/pkg/image/podman	[no test files]
PASS
ok  	github.com/anchore/stereoscope/pkg/image/sif	0.005s
?   	github.com/anchore/stereoscope/pkg/imagetest	[no test files]
PASS
ok  	github.com/anchore/stereoscope/pkg/tree	0.004s
PASS
ok  	github.com/anchore/stereoscope/pkg/tree/node	0.004s
goos: linux
goarch: amd64
pkg: github.com/anchore/stereoscope/test/integration
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkSimpleImage_GetImage/docker-archive-4 	     969	   1231557 ns/op	  272551 B/op	    2249 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     960	   1257058 ns/op	  272691 B/op	    2249 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     961	   1251910 ns/op	  272595 B/op	    2249 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     960	   1253878 ns/op	  272507 B/op	    2249 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     952	   1249704 ns/op	  272235 B/op	    2249 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     936	   1333945 ns/op	  272258 B/op	    2248 allocs/op
BenchmarkSimpleImage_GetImage/docker-archive-4 	     946	   1239876 ns/op	  272287 B/op	    2248 allocs/op
--- FAIL: BenchmarkSimpleImage_GetImage/podman
    fixture_image_simple_test.go:175: could not get fixture image: unable to detect input for 'stereoscope-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7', errs: podman not available: no host address
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 345B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load build context
#3 transferring context: 209B done
#3 DONE 0.0s

#4 [1/3] ADD file-1.txt /somefile-1.txt
#4 CACHED

#5 [2/3] ADD file-2.txt /somefile-2.txt
#5 CACHED

#6 [3/3] ADD target /
#6 CACHED

#7 exporting to image
#7 exporting layers done
#7 writing image sha256:7d6fccf9b3891c02920dc7bb117004b6f68a10e5a076c3813c83a4e60aca2295 done
#7 naming to docker.io/library/stereoscope-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7 done
#7 naming to docker.io/library/stereoscope-fixture-image-simple:latest done
#7 DONE 0.0s
time="2026-03-06T18:35:34Z" level=warning msg="Failed to check deprecations" error="connection error: desc = \"transport: Error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied\""
ctr: connection error: desc = "transport: Error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied"
--- FAIL: BenchmarkSimpleImage_GetImage
    image_fixtures.go:195: using existing image tar: 'testdata/cache/stereoscope-fixture-image-simple-04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7.tar' (size: 22528, modified: 2026-03-06 18:34:43.048229117 +0000 UTC, mode: -rw-r--r--)
    image_fixtures.go:243: Build docker image: name="stereoscope-fixture-image-simple" tag="04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7"
    image_fixtures.go:293: saveImage running: docker image save stereoscope-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7
    image_fixtures.go:288: 
        	Error Trace:	/home/runner/work/stereoscope/stereoscope/pkg/imagetest/image_fixtures.go:288
        	            				/home/runner/work/stereoscope/stereoscope/pkg/imagetest/image_fixtures.go:164
        	            				/home/runner/work/stereoscope/stereoscope/pkg/imagetest/image_fixtures.go:154
        	            				/home/runner/work/stereoscope/stereoscope/pkg/imagetest/image_fixtures.go:35
        	            				/home/runner/work/stereoscope/stereoscope/test/integration/fixture_image_simple_test.go:163
        	            				/opt/hostedtoolcache/go/1.25.7/x64/src/testing/benchmark.go:245
        	            				/opt/hostedtoolcache/go/1.25.7/x64/src/runtime/asm_amd64.s:1693
        	Error:      	Received unexpected error:
        	            	exit status 1
        	Test:       	BenchmarkSimpleImage_GetImage
        	Messages:   	could not import docker image to containerd (shell out)
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45291	     26395 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45429	     26621 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45723	     26243 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45495	     26400 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45765	     26362 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45616	     26286 ns/op	    2616 B/op	      18 allocs/op
BenchmarkSimpleImage_FetchSquashedContents/docker-archive-4         	   45591	     26347 ns/op	    2616 B/op	      18 allocs/op
--- FAIL: BenchmarkSimpleImage_FetchSquashedContents
    image_fixtures.go:195: using existing image tar: 'testdata/cache/stereoscope-fixture-image-simple-04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7.tar' (size: 22528, modified: 2026-03-06 18:34:43.048229117 +0000 UTC, mode: -rw-r--r--)
    image_fixtures.go:77: error getting fixture image: 'podman' 'image-simple' with request 'podman:stereoscope-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7': unable to detect input for 'stereoscope-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7', errs: podman not available: no host address
FAIL
exit status 1
FAIL	github.com/anchore/stereoscope/test/integration	20.379s
FAIL
goos: linux
goarch: amd64
pkg: github.com/anchore/stereoscope/pkg/file
cpu: AMD EPYC 7763 64-Core Processor                
ctr: 
           │ .tmp/benchmark-833378d.txt │
           │           sec/op           │
TarIndex-4                  44.79µ ± 2%

           │ .tmp/benchmark-833378d.txt │
           │            B/op            │
TarIndex-4                 5.567Ki ± 0%

           │ .tmp/benchmark-833378d.txt │
           │         allocs/op          │
TarIndex-4                   93.00 ± 0%

pkg: github.com/anchore/stereoscope/test/integration
                                      │ .tmp/benchmark-833378d.txt │
                                      │           sec/op           │
SimpleImage_GetImage/docker-archive-4                  1.252m ± 7%

                                      │ .tmp/benchmark-833378d.txt │
                                      │            B/op            │
SimpleImage_GetImage/docker-archive-4                 266.1Ki ± 0%

                                      │ .tmp/benchmark-833378d.txt │
                                      │         allocs/op          │
SimpleImage_GetImage/docker-archive-4                  2.249k ± 0%

ctr: connection error: desc = "transport: Error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied"
                                                   │ .tmp/benchmark-833378d.txt │
                                                   │           sec/op           │
SimpleImage_FetchSquashedContents/docker-archive-4                  26.36µ ± 1%

                                                   │ .tmp/benchmark-833378d.txt │
                                                   │            B/op            │
SimpleImage_FetchSquashedContents/docker-archive-4                 2.555Ki ± 0%

                                                   │ .tmp/benchmark-833378d.txt │
                                                   │         allocs/op          │
SimpleImage_FetchSquashedContents/docker-archive-4                   18.00 ± 0%
goos: linux
goarch: amd64
pkg: github.com/anchore/stereoscope/pkg/file
cpu: AMD EPYC 7763 64-Core Processor                
ctr: 
           │ .tmp/benchmark-833378d.txt │
           │           sec/op           │
TarIndex-4                  44.79µ ± 2%

           │ .tmp/benchmark-833378d.txt │
           │            B/op            │
TarIndex-4                 5.567Ki ± 0%

           │ .tmp/benchmark-833378d.txt │
           │         allocs/op          │
TarIndex-4                   93.00 ± 0%

pkg: github.com/anchore/stereoscope/test/integration
                                      │ .tmp/benchmark-833378d.txt │
                                      │           sec/op           │
SimpleImage_GetImage/docker-archive-4                  1.252m ± 7%

                                      │ .tmp/benchmark-833378d.txt │
                                      │            B/op            │
SimpleImage_GetImage/docker-archive-4                 266.1Ki ± 0%

                                      │ .tmp/benchmark-833378d.txt │
                                      │         allocs/op          │
SimpleImage_GetImage/docker-archive-4                  2.249k ± 0%

ctr: connection error: desc = "transport: Error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied"
                                                   │ .tmp/benchmark-833378d.txt │
                                                   │           sec/op           │
SimpleImage_FetchSquashedContents/docker-archive-4                  26.36µ ± 1%

                                                   │ .tmp/benchmark-833378d.txt │
                                                   │            B/op            │
SimpleImage_FetchSquashedContents/docker-archive-4                 2.555Ki ± 0%

                                                   │ .tmp/benchmark-833378d.txt │
                                                   │         allocs/op          │
SimpleImage_FetchSquashedContents/docker-archive-4                   18.00 ± 0%

@wagoodman wagoodman force-pushed the move-test-fixtures branch 2 times, most recently from 5b4f4f6 to 28f8b39 Compare March 3, 2026 15:37
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@spiffcs spiffcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits about duplicate function and a comment that was confusing regarding why we made a function change.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman force-pushed the move-test-fixtures branch from f135f78 to 4b2c787 Compare March 6, 2026 18:32
@wagoodman wagoodman enabled auto-merge (squash) March 6, 2026 18:33
@wagoodman wagoodman merged commit 99ed0b6 into main Mar 6, 2026
8 checks passed
@wagoodman wagoodman deleted the move-test-fixtures branch March 6, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants