diff --git a/RELEASE_PROCEDURE.md b/RELEASE_PROCEDURE.md index 9198705b28..c63d48bdbf 100644 --- a/RELEASE_PROCEDURE.md +++ b/RELEASE_PROCEDURE.md @@ -133,10 +133,10 @@ release of a new major or minor version. Each new RC follows step 5 and above. 1. Ensure the user and admin documentation is up-to-date for the new version, has been branched, and tagged. - * [User Docs](https://www.sylabs.io/guides/latest/user-guide/) can be edited - [here](https://github.com/sylabs/singularity-userdocs) - * [Admin Docs](https://www.sylabs.io/guides/latest/admin-guide/) can be edited - [here](https://github.com/sylabs/singularity-admindocs) + * [User Docs](https://www.sylabs.io/guides/latest/user-guide/) can be [edited + here](https://github.com/sylabs/singularity-userdocs) + * [Admin Docs](https://www.sylabs.io/guides/latest/admin-guide/) can be [edited + here](https://github.com/sylabs/singularity-admindocs) 1. Ensure the user and admin documentation has been deployed to the sylabs.io website. 1. Modify the `README.md`, `INSTALL.md`, `CHANGELOG.md` via PR against the diff --git a/e2e/README.md b/e2e/README.md index 07545e3176..442d4d2542 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -903,8 +903,8 @@ name of the file/dir, and so both these goals can be accomplished: package of the standard Go library accepts both a parent directory in which to create the file (`dir`) and a pattern for the filename to include (`pattern`). Typically, the pattern is used as a prefix, but other behaviors - are possible. See the full documentation for this function - [here](https://pkg.go.dev/os#CreateTemp). + are possible. See the [full documentation for this function + here](https://pkg.go.dev/os#CreateTemp). - The function `e2e.WriteTempFile(dir, pattern, content string) (string, error)` defined in e2e/internal/e2e/fileutil.go behaves similarly - indeed, it calls os.CreateTemp() with the `dir` and `pattern` arguments it is given. @@ -916,8 +916,8 @@ name of the file/dir, and so both these goals can be accomplished: package of the standard Go library accepts both a parent directory in which to create the temporary subdir (`dir`) and a pattern for the dirname to include (`pattern`). Typically, the pattern is used as a prefix, but other - behaviors are possible. See the full documentation for this function - [here](https://pkg.go.dev/os#MkdirTemp). + behaviors are possible. See the [full documentation for this function + here](https://pkg.go.dev/os#MkdirTemp). - The function `e2e.MakeTempDir(t *testing.T, baseDir string, prefix string, context string) (string, func(t *testing.T))` defined in e2e/internal/e2e/fileutil.go behaves similarly - indeed, it calls diff --git a/e2e/docker/regressions.go b/e2e/docker/regressions.go index dc113dfb31..bd9ee02fd9 100644 --- a/e2e/docker/regressions.go +++ b/e2e/docker/regressions.go @@ -244,11 +244,6 @@ func (c ctx) issue1286(t *testing.T) { // https://github.com/sylabs/singularity/issues/1528 // Check that host's TERM value gets passed to OCI container. -// This test uses fairly fine-grained env vars manipulation which, at the -// present, is beyond what an API like testing.T.Setenv() enables, and so -// the tenv linter is turned off here. -// -//nolint:tenv func (c ctx) issue1528(t *testing.T) { e2e.EnsureOCISIF(t, c.env) diff --git a/go.mod b/go.mod index a00e447685..65f75172a5 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/sylabs/singularity/v4 -go 1.23.4 +go 1.24.0 require ( github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 - github.com/ProtonMail/go-crypto v1.2.0 + github.com/ProtonMail/go-crypto v1.3.0 github.com/adigunhammedolalekan/registry-auth v0.0.0-20200730122110-8cde180a3a60 github.com/apex/log v1.9.0 github.com/astromechza/etcpwdparse v0.0.0-20170319193008-f0e5f0779716 @@ -28,7 +28,7 @@ require ( github.com/fatih/color v1.18.0 github.com/go-log/log v0.2.0 github.com/gofrs/flock v0.12.1 - github.com/google/go-containerregistry v0.20.4-0.20250225234217-098045d5e61f + github.com/google/go-containerregistry v0.20.5 github.com/google/uuid v1.6.0 github.com/gosimple/slug v1.15.0 github.com/moby/buildkit v0.21.1 @@ -111,7 +111,7 @@ require ( github.com/containerd/typeurl/v2 v2.2.3 // indirect github.com/containers/storage v1.58.0 // indirect github.com/coreos/go-iptables v0.8.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/creack/pty v1.1.24 // indirect github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect @@ -251,7 +251,7 @@ require ( go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.31.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.31.0 // indirect @@ -260,7 +260,7 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect go.opentelemetry.io/otel/sdk v1.35.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect go.opentelemetry.io/proto/otlp v1.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect diff --git a/go.sum b/go.sum index cd0a215abb..20c4547c51 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= -github.com/ProtonMail/go-crypto v1.2.0 h1:+PhXXn4SPGd+qk76TlEePBfOfivE0zkWFenhGhFLzWs= -github.com/ProtonMail/go-crypto v1.2.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= +github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw= +github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY+9ef8E= github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= @@ -262,8 +262,9 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= @@ -437,8 +438,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-containerregistry v0.20.4-0.20250225234217-098045d5e61f h1:q+kbH7LI4wK3gNCxyvy2rFldJqAAB+Gch79/xj9/+GU= -github.com/google/go-containerregistry v0.20.4-0.20250225234217-098045d5e61f/go.mod h1:UnXV0UkKqoHbzwn49vfozmwMcLMS8XLLsVKVuhv3cGc= +github.com/google/go-containerregistry v0.20.5 h1:4RnlYcDs5hoA++CeFjlbZ/U9Yp1EuWr+UhhTyYQjOP0= +github.com/google/go-containerregistry v0.20.5/go.mod h1:Q14vdOOzug02bwnhMkZKD4e30pDaD9W65qzXpyzF49E= github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg= github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -975,8 +976,8 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.5 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0/go.mod h1:ijPqXp5P6IRRByFVVg9DY8P5HkxkHE5ARIa+86aXPf4= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 h1:4BZHA+B1wXEQoGNHxW8mURaLhcdGwvRnmhGbm+odRbc= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0/go.mod h1:3qi2EEwMgB4xnKgPLqsDP3j9qxnHDZeHsnAxfjQqTko= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ= go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.31.0 h1:FZ6ei8GFW7kyPYdxJaV2rgI6M+4tvZzhYsQ2wgyVC08= @@ -993,8 +994,8 @@ go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/ go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY= go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg= -go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= -go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= +go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w= go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg= @@ -1048,8 +1049,8 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98= -golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1122,8 +1123,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/app/starter/master_linux_test.go b/internal/app/starter/master_linux_test.go index f9f9429eb9..d99fc3f30a 100644 --- a/internal/app/starter/master_linux_test.go +++ b/internal/app/starter/master_linux_test.go @@ -6,7 +6,6 @@ package starter import ( - "context" "testing" "github.com/sylabs/singularity/v4/internal/pkg/runtime/engine" @@ -52,7 +51,7 @@ func TestCreateContainer(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - go createContainer(context.Background(), tt.rpcSocket, tt.containerPid, tt.engine, fatalChan) + go createContainer(t.Context(), tt.rpcSocket, tt.containerPid, tt.engine, fatalChan) // createContainer is creating a separate thread and we sync with that // thread through a channel similarly to the createContainer function itself, // as well as the Master function. @@ -102,7 +101,7 @@ func TestStartContainer(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - go startContainer(context.Background(), tt.masterSocket, tt.postStartSocket, tt.containerPid, tt.engine, fatalChan) + go startContainer(t.Context(), tt.masterSocket, tt.postStartSocket, tt.containerPid, tt.engine, fatalChan) fatal = <-fatalChan if tt.shallPass && fatal != nil { t.Fatalf("test %s expected to succeed but failed: %s", tt.name, fatal) diff --git a/internal/pkg/build/assemblers/sandbox_test.go b/internal/pkg/build/assemblers/sandbox_test.go index c1064f0145..eec8a48f60 100644 --- a/internal/pkg/build/assemblers/sandbox_test.go +++ b/internal/pkg/build/assemblers/sandbox_test.go @@ -6,7 +6,6 @@ package assemblers_test import ( - "context" "os" "path/filepath" "testing" @@ -51,11 +50,11 @@ func TestSandboxAssemblerDocker(t *testing.T) { ocp := &sources.OCIConveyorPacker{} - if err := ocp.Get(context.Background(), b); err != nil { + if err := ocp.Get(t.Context(), b); err != nil { t.Fatalf("failed to Get from %s: %v\n", assemblerDockerURI, err) } - _, err = ocp.Pack(context.Background()) + _, err = ocp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", assemblerDockerURI, err) } @@ -94,11 +93,11 @@ func TestSandboxAssemblerShub(t *testing.T) { scp := &sources.ShubConveyorPacker{} - if err := scp.Get(context.Background(), b); err != nil { + if err := scp.Get(t.Context(), b); err != nil { t.Fatalf("failed to Get from %s: %v\n", assemblerShubURI, err) } - _, err = scp.Pack(context.Background()) + _, err = scp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", assemblerShubURI, err) } diff --git a/internal/pkg/build/assemblers/sif_test.go b/internal/pkg/build/assemblers/sif_test.go index 6e09c646d6..9c2be37aad 100644 --- a/internal/pkg/build/assemblers/sif_test.go +++ b/internal/pkg/build/assemblers/sif_test.go @@ -6,7 +6,6 @@ package assemblers_test import ( - "context" "os" "path/filepath" "testing" @@ -66,11 +65,11 @@ func TestSIFAssemblerDocker(t *testing.T) { ocp := &sources.OCIConveyorPacker{} - if err = ocp.Get(context.Background(), b); err != nil { + if err = ocp.Get(t.Context(), b); err != nil { t.Fatalf("failed to Get from %s: %v\n", assemblerDockerURI, err) } - _, err = ocp.Pack(context.Background()) + _, err = ocp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", assemblerDockerURI, err) } @@ -109,11 +108,11 @@ func TestSIFAssemblerShub(t *testing.T) { scp := &sources.ShubConveyorPacker{} - if err := scp.Get(context.Background(), b); err != nil { + if err := scp.Get(t.Context(), b); err != nil { t.Fatalf("failed to Get from %s: %v\n", assemblerShubURI, err) } - _, err = scp.Pack(context.Background()) + _, err = scp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", assemblerShubURI, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_arch_test.go b/internal/pkg/build/sources/conveyorPacker_arch_test.go index 39db079fa6..3f820d6dee 100644 --- a/internal/pkg/build/sources/conveyorPacker_arch_test.go +++ b/internal/pkg/build/sources/conveyorPacker_arch_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "os/exec" "path/filepath" @@ -55,7 +54,7 @@ func TestArchConveyor(t *testing.T) { cp := &sources.ArchConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -93,14 +92,14 @@ func TestArchPacker(t *testing.T) { cp := &sources.ArchConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", archDef, err) } - _, err = cp.Pack(context.Background()) + _, err = cp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", archDef, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_busybox_test.go b/internal/pkg/build/sources/conveyorPacker_busybox_test.go index 721e932f39..ebbf7e8fbb 100644 --- a/internal/pkg/build/sources/conveyorPacker_busybox_test.go +++ b/internal/pkg/build/sources/conveyorPacker_busybox_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "path/filepath" "testing" @@ -52,7 +51,7 @@ func TestBusyBoxConveyor(t *testing.T) { c := &sources.BusyBoxConveyor{} - err = c.Get(context.Background(), b) + err = c.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer c.CleanUp() if err != nil { @@ -88,14 +87,14 @@ func TestBusyBoxPacker(t *testing.T) { cp := &sources.BusyBoxConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", busyBoxDef, err) } - _, err = cp.Pack(context.Background()) + _, err = cp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", busyBoxDef, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_debootstrap_test.go b/internal/pkg/build/sources/conveyorPacker_debootstrap_test.go index 911e2fb7d4..a3be9c5127 100644 --- a/internal/pkg/build/sources/conveyorPacker_debootstrap_test.go +++ b/internal/pkg/build/sources/conveyorPacker_debootstrap_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "os/exec" "path/filepath" @@ -42,7 +41,7 @@ func TestDebootstrapConveyor(t *testing.T) { cp := sources.DebootstrapConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -75,14 +74,14 @@ func TestDebootstrapPacker(t *testing.T) { cp := sources.DebootstrapConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { t.Fatalf("Debootstrap Get failed: %v", err) } - _, err = cp.Pack(context.Background()) + _, err = cp.Pack(t.Context()) if err != nil { t.Fatalf("Debootstrap Pack failed: %v", err) } diff --git a/internal/pkg/build/sources/conveyorPacker_library_test.go b/internal/pkg/build/sources/conveyorPacker_library_test.go index 8cf3904755..210157dc0b 100644 --- a/internal/pkg/build/sources/conveyorPacker_library_test.go +++ b/internal/pkg/build/sources/conveyorPacker_library_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "path/filepath" "testing" @@ -54,7 +53,7 @@ func TestLibraryConveyor(t *testing.T) { defer cleanup() b.Opts.ImgCache = imgCache - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -90,14 +89,14 @@ func TestLibraryPacker(t *testing.T) { defer cleanup() b.Opts.ImgCache = imgCache - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", libraryURI, err) } - _, err = cp.Pack(context.Background()) + _, err = cp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", libraryURI, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_local_test.go b/internal/pkg/build/sources/conveyorPacker_local_test.go index b408ec7a55..89899fb4eb 100644 --- a/internal/pkg/build/sources/conveyorPacker_local_test.go +++ b/internal/pkg/build/sources/conveyorPacker_local_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "path/filepath" "testing" @@ -69,10 +68,10 @@ func TestLocalPackerSquashfs(t *testing.T) { // Creates and execute packer lcp := &sources.LocalConveyorPacker{} - if err := lcp.Get(context.Background(), b); err != nil { + if err := lcp.Get(t.Context(), b); err != nil { t.Fatalf("while getting local packer: %v", err) } - if _, err = lcp.Pack(context.Background()); err != nil { + if _, err = lcp.Pack(t.Context()); err != nil { t.Fatalf("failed to Pack from %s: %v\n", image, err) } rootfsPath := b.RootfsPath diff --git a/internal/pkg/build/sources/conveyorPacker_oci_test.go b/internal/pkg/build/sources/conveyorPacker_oci_test.go index ff16dc3d08..1730ab4309 100644 --- a/internal/pkg/build/sources/conveyorPacker_oci_test.go +++ b/internal/pkg/build/sources/conveyorPacker_oci_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "io" "log" "net/http" @@ -74,7 +73,7 @@ func TestOCIConveyorDocker(t *testing.T) { b.Opts.Platform = *p cp := &sources.OCIConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -113,7 +112,7 @@ func TestOCIConveyorDockerArchive(t *testing.T) { cp := &sources.OCIConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -160,7 +159,7 @@ func TestOCIConveyorDockerDaemon(t *testing.T) { cp := &sources.OCIConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -195,7 +194,7 @@ func TestOCIConveyorOCIArchive(t *testing.T) { cp := &sources.OCIConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -239,7 +238,7 @@ func TestOCIConveyorOCILayout(t *testing.T) { cp := &sources.OCIConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -275,14 +274,14 @@ func TestOCIPacker(t *testing.T) { } b.Opts.Platform = *p - err = ocp.Get(context.Background(), b) + err = ocp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer ocp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", dockerURI, err) } - _, err = ocp.Pack(context.Background()) + _, err = ocp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", dockerURI, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_scratch_test.go b/internal/pkg/build/sources/conveyorPacker_scratch_test.go index 0191a0a901..77d42d7ac0 100644 --- a/internal/pkg/build/sources/conveyorPacker_scratch_test.go +++ b/internal/pkg/build/sources/conveyorPacker_scratch_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "path/filepath" "testing" @@ -45,7 +44,7 @@ func TestScratchConveyor(t *testing.T) { c := &sources.ScratchConveyor{} - err = c.Get(context.Background(), b) + err = c.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer c.CleanUp() if err != nil { @@ -75,14 +74,14 @@ func TestScratchPacker(t *testing.T) { cp := &sources.ScratchConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", scratchDef, err) } - _, err = cp.Pack(context.Background()) + _, err = cp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", scratchDef, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_shub_test.go b/internal/pkg/build/sources/conveyorPacker_shub_test.go index d64aa58557..d49f94b7b3 100644 --- a/internal/pkg/build/sources/conveyorPacker_shub_test.go +++ b/internal/pkg/build/sources/conveyorPacker_shub_test.go @@ -6,7 +6,6 @@ package sources_test import ( - "context" "os" "path/filepath" "testing" @@ -44,7 +43,7 @@ func TestShubConveyor(t *testing.T) { cp := &sources.ShubConveyorPacker{} - err = cp.Get(context.Background(), b) + err = cp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer cp.CleanUp() if err != nil { @@ -71,14 +70,14 @@ func TestShubPacker(t *testing.T) { scp := &sources.ShubConveyorPacker{} - err = scp.Get(context.Background(), b) + err = scp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer scp.CleanUp() if err != nil { t.Fatalf("failed to Get from %s: %v\n", shubURI, err) } - _, err = scp.Pack(context.Background()) + _, err = scp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", shubURI, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_yum_test.go b/internal/pkg/build/sources/conveyorPacker_yum_test.go index b320583e34..d063c0a057 100644 --- a/internal/pkg/build/sources/conveyorPacker_yum_test.go +++ b/internal/pkg/build/sources/conveyorPacker_yum_test.go @@ -6,7 +6,6 @@ package sources import ( - "context" "fmt" "os" "os/exec" @@ -73,14 +72,14 @@ func testYumConveyorPacker(t *testing.T, yumDef string) { ycp := &YumConveyorPacker{} - err = ycp.Get(context.Background(), b) + err = ycp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer ycp.b.Remove() if err != nil { t.Fatalf("failed to Get from %s: %v\n", yumDef, err) } - _, err = ycp.Pack(context.Background()) + _, err = ycp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", yumDef, err) } diff --git a/internal/pkg/build/sources/conveyorPacker_zypper_test.go b/internal/pkg/build/sources/conveyorPacker_zypper_test.go index 638378b110..3236a5b462 100644 --- a/internal/pkg/build/sources/conveyorPacker_zypper_test.go +++ b/internal/pkg/build/sources/conveyorPacker_zypper_test.go @@ -6,7 +6,6 @@ package sources import ( - "context" "fmt" "os" "os/exec" @@ -56,14 +55,14 @@ func testZypperConveyorPacker(t *testing.T, defName string) { zcp := &ZypperConveyorPacker{} - err = zcp.Get(context.Background(), b) + err = zcp.Get(t.Context(), b) // clean up tmpfs since assembler isn't called defer zcp.b.Remove() if err != nil { t.Fatalf("failed to Get from %s: %v\n", defName, err) } - _, err = zcp.Pack(context.Background()) + _, err = zcp.Pack(t.Context()) if err != nil { t.Fatalf("failed to Pack from %s: %v\n", defName, err) } diff --git a/internal/pkg/client/progress/progress_test.go b/internal/pkg/client/progress/progress_test.go index 4534655a4b..4fe91761c0 100644 --- a/internal/pkg/client/progress/progress_test.go +++ b/internal/pkg/client/progress/progress_test.go @@ -7,7 +7,6 @@ package progress import ( "bytes" - "context" "fmt" "testing" @@ -16,7 +15,7 @@ import ( func TestProgressCallback(t *testing.T) { const input = "Hello World!" - ctx := context.Background() + ctx := t.Context() // Check the progress bar, or invisible copy-through, works at all sylog // levels diff --git a/internal/pkg/client/shub/pull_test.go b/internal/pkg/client/shub/pull_test.go index fd5d6c8f87..56ebf575ca 100644 --- a/internal/pkg/client/shub/pull_test.go +++ b/internal/pkg/client/shub/pull_test.go @@ -6,7 +6,6 @@ package shub import ( - "context" "os" "testing" @@ -41,7 +40,7 @@ func TestDownloadImage(t *testing.T) { t.Fatalf("failed to get manifest from shub: %s", err) } - err = DownloadImage(context.Background(), manifest, shubImgPath, shubImageURI, false, false) + err = DownloadImage(t.Context(), manifest, shubImgPath, shubImageURI, false, false) if err != nil { t.Fatalf("failed to Get from %s: %v\n", shubURI, err) } diff --git a/internal/pkg/cosign/sign_test.go b/internal/pkg/cosign/sign_test.go index 31d743e92e..969306ae3c 100644 --- a/internal/pkg/cosign/sign_test.go +++ b/internal/pkg/cosign/sign_test.go @@ -7,7 +7,6 @@ package cosign import ( "bytes" - "context" "crypto" "encoding/json" "path/filepath" @@ -51,7 +50,7 @@ func TestSignOCISIF(t *testing.T) { t.Fatalf("while generating test signer: %v", err) } - if err := SignOCISIF(context.Background(), testSIF, sv); err != nil { + if err := SignOCISIF(t.Context(), testSIF, sv); err != nil { t.Error(err) } @@ -63,7 +62,7 @@ func checkSignature(t *testing.T, verifier signature.Verifier, imgDigest v1.Hash if err != nil { t.Fatal(err) } - d, err := s.Get(context.Background()) + d, err := s.Get(t.Context()) if err != nil { t.Fatal(err) } @@ -72,7 +71,7 @@ func checkSignature(t *testing.T, verifier signature.Verifier, imgDigest v1.Hash if !ok { t.Fatal("could not upgrade Descriptor to SignedDescriptor") } - si, err := sd.SignedImage(context.Background()) + si, err := sd.SignedImage(t.Context()) if err != nil { t.Fatal(err) } diff --git a/internal/pkg/cosign/verify_test.go b/internal/pkg/cosign/verify_test.go index 38b2a7ae70..bcbe5a5bdd 100644 --- a/internal/pkg/cosign/verify_test.go +++ b/internal/pkg/cosign/verify_test.go @@ -6,7 +6,6 @@ package cosign import ( - "context" "crypto" "errors" "io" @@ -63,7 +62,7 @@ func TestVerifyOCISIF(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - payloads, err := VerifyOCISIF(context.Background(), tt.sifPath, tt.verifier) + payloads, err := VerifyOCISIF(t.Context(), tt.sifPath, tt.verifier) if !errors.Is(err, tt.expectErr) { t.Errorf("Expected error %v, got %v", tt.expectErr, err) } diff --git a/internal/pkg/runtime/engine/config/starter/starter_linux.go b/internal/pkg/runtime/engine/config/starter/starter_linux.go index a1ec4e913e..479568402f 100644 --- a/internal/pkg/runtime/engine/config/starter/starter_linux.go +++ b/internal/pkg/runtime/engine/config/starter/starter_linux.go @@ -55,7 +55,7 @@ func NewConfig(config SConfig) *Config { // GetIsSUID returns true if the SUID workflow is enabled. // This field is set by starter at the very beginning of its execution. func (c *Config) GetIsSUID() bool { - return c.config.starter.isSuid == true //nolint:gosimple,staticcheck + return c.config.starter.isSuid == true //nolint:staticcheck } // GetContainerPid returns the container PID (if any). diff --git a/internal/pkg/signature/sign_test.go b/internal/pkg/signature/sign_test.go index 7ebec8f94f..9792823141 100644 --- a/internal/pkg/signature/sign_test.go +++ b/internal/pkg/signature/sign_test.go @@ -6,7 +6,6 @@ package signature import ( - "context" "crypto" "errors" "io" @@ -143,7 +142,7 @@ func TestSign(t *testing.T) { } defer os.Remove(path) - if got, want := Sign(context.Background(), path, tt.opts...), tt.wantErr; !errors.Is(got, want) { + if got, want := Sign(t.Context(), path, tt.opts...), tt.wantErr; !errors.Is(got, want) { t.Errorf("got error %v, want %v", got, want) } }) diff --git a/internal/pkg/signature/verify_test.go b/internal/pkg/signature/verify_test.go index f96084ea38..d59b89d9e7 100644 --- a/internal/pkg/signature/verify_test.go +++ b/internal/pkg/signature/verify_test.go @@ -7,7 +7,6 @@ package signature import ( "bytes" - "context" "crypto" "crypto/x509" "encoding/pem" @@ -342,7 +341,7 @@ func Test_verifier_getOpts(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - opts, err := tt.v.getOpts(context.Background(), tt.f) + opts, err := tt.v.getOpts(t.Context(), tt.f) if got, want := err, tt.wantErr; !errors.Is(got, want) { t.Errorf("got error %v, want %v", got, want) @@ -582,7 +581,7 @@ func TestVerify(t *testing.T) { //nolint:maintidx } tt.opts = append(tt.opts, OptVerifyCallback(cb)) - err := Verify(context.Background(), tt.path, tt.opts...) + err := Verify(t.Context(), tt.path, tt.opts...) if got, want := err, tt.wantErr; !errors.Is(got, want) { t.Errorf("got error %v, want %v", got, want) @@ -768,7 +767,7 @@ func TestVerifyFingerPrint(t *testing.T) { return false } tt.opts = append(tt.opts, OptVerifyCallback(cb)) - err := VerifyFingerprints(context.Background(), tt.path, tt.fingerprints, tt.opts...) + err := VerifyFingerprints(t.Context(), tt.path, tt.fingerprints, tt.opts...) if got, want := err, tt.wantErr; !errors.Is(got, want) { t.Errorf("got error %v, want %v", got, want) } diff --git a/internal/pkg/syecl/syecl_test.go b/internal/pkg/syecl/syecl_test.go index 0cac0ae1d1..fdc5f81591 100644 --- a/internal/pkg/syecl/syecl_test.go +++ b/internal/pkg/syecl/syecl_test.go @@ -7,7 +7,6 @@ package syecl import ( - "context" "fmt" "os" "path/filepath" @@ -428,7 +427,7 @@ func TestShouldRun(t *testing.T) { } // Test ShouldRun (takes path). - got, err := c.ShouldRun(context.Background(), tt.path, openpgp.EntityList{getTestEntity(t)}) + got, err := c.ShouldRun(t.Context(), tt.path, openpgp.EntityList{getTestEntity(t)}) if want := !tt.wantErr; got != want { t.Errorf("got run %v, want %v", got, want) @@ -445,7 +444,7 @@ func TestShouldRun(t *testing.T) { } defer f.Close() - got, err = c.ShouldRunFp(context.Background(), f, openpgp.EntityList{getTestEntity(t)}) + got, err = c.ShouldRunFp(t.Context(), f, openpgp.EntityList{getTestEntity(t)}) if want := !tt.wantErr; got != want { t.Errorf("got run %v, want %v", got, want) diff --git a/internal/pkg/sypgp/sypgp_test.go b/internal/pkg/sypgp/sypgp_test.go index c746c7e836..e2830a7eb9 100644 --- a/internal/pkg/sypgp/sypgp_test.go +++ b/internal/pkg/sypgp/sypgp_test.go @@ -8,7 +8,6 @@ package sypgp import ( "bytes" - "context" "encoding/hex" "log" "net/http" @@ -89,7 +88,7 @@ func TestSearchPubkey(t *testing.T) { client.OptHTTPClient(srv.Client()), } - if err := SearchPubkey(context.Background(), tt.search, false, opts...); (err != nil) != tt.wantErr { + if err := SearchPubkey(t.Context(), tt.search, false, opts...); (err != nil) != tt.wantErr { t.Fatalf("got err %v, want error %v", err, tt.wantErr) } }) @@ -132,7 +131,7 @@ func TestFetchPubkey(t *testing.T) { client.OptHTTPClient(srv.Client()), } - el, err := FetchPubkey(context.Background(), tt.fingerprint, opts...) + el, err := FetchPubkey(t.Context(), tt.fingerprint, opts...) if (err != nil) != tt.wantErr { t.Fatalf("unexpected error: %v", err) return @@ -213,7 +212,7 @@ func TestPushPubkey(t *testing.T) { client.OptHTTPClient(srv.Client()), } - if err := PushPubkey(context.Background(), testEntity, opts...); (err != nil) != tt.wantErr { + if err := PushPubkey(t.Context(), testEntity, opts...); (err != nil) != tt.wantErr { t.Fatalf("got err %v, want error %v", err, tt.wantErr) } }) diff --git a/internal/pkg/test/privilege_linux.go b/internal/pkg/test/privilege_linux.go index d279cc00b9..d616c91331 100644 --- a/internal/pkg/test/privilege_linux.go +++ b/internal/pkg/test/privilege_linux.go @@ -67,7 +67,6 @@ func ResetPrivilege(t *testing.T) { // We might want restoration of HOME env var to persist past this individual // test, so use os.Setenv() rather than t.Setenv() - //nolint:tenv os.Setenv("HOME", origHome) //nolint:usetesting runtime.UnlockOSThread() diff --git a/internal/pkg/test/tool/require/require.go b/internal/pkg/test/tool/require/require.go index bda2216e59..50b9eda8a3 100644 --- a/internal/pkg/test/tool/require/require.go +++ b/internal/pkg/test/tool/require/require.go @@ -7,7 +7,6 @@ package require import ( "bytes" - "context" "fmt" "os" "os/exec" @@ -76,7 +75,7 @@ func Network(t *testing.T) { t.Logf("Could not use network: %s", err) } - ctx := context.TODO() + ctx := t.Context() cmd := exec.Command("/bin/cat") cmd.SysProcAttr = &syscall.SysProcAttr{} diff --git a/internal/pkg/util/env/env_test.go b/internal/pkg/util/env/env_test.go index 35710dcb18..c451093f42 100644 --- a/internal/pkg/util/env/env_test.go +++ b/internal/pkg/util/env/env_test.go @@ -6,7 +6,6 @@ package env import ( - "context" "os" "path/filepath" "reflect" @@ -194,7 +193,7 @@ func TestEnvFileMap(t *testing.T) { t.Fatalf("Could not write test env-file: %v", err) } - got, err := FileMap(context.Background(), envFile, []string{}, tt.hostEnv) + got, err := FileMap(t.Context(), envFile, []string{}, tt.hostEnv) if (err != nil) != tt.wantErr { t.Errorf("envFileMap() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/internal/pkg/util/fs/fuse/fuse_mount_linux_test.go b/internal/pkg/util/fs/fuse/fuse_mount_linux_test.go index 8a3153ea5d..f5da39ac89 100644 --- a/internal/pkg/util/fs/fuse/fuse_mount_linux_test.go +++ b/internal/pkg/util/fs/fuse/fuse_mount_linux_test.go @@ -6,7 +6,6 @@ package fuse import ( - "context" "path/filepath" "testing" @@ -38,7 +37,7 @@ func TestExtraOptOverrides(t *testing.T) { } func testOneOverride(t *testing.T, s string) { - ctx := context.Background() + ctx := t.Context() m := ImageMount{ Type: image.SQUASHFS, @@ -63,7 +62,7 @@ func testOneOverride(t *testing.T, s string) { } func TestAllOverridesAtOnce(t *testing.T) { - ctx := context.Background() + ctx := t.Context() m := ImageMount{ Type: image.SQUASHFS, diff --git a/internal/pkg/util/fs/overlay/overlay_item_linux_test.go b/internal/pkg/util/fs/overlay/overlay_item_linux_test.go index b3610d381d..4465f0d0a4 100644 --- a/internal/pkg/util/fs/overlay/overlay_item_linux_test.go +++ b/internal/pkg/util/fs/overlay/overlay_item_linux_test.go @@ -6,7 +6,6 @@ package overlay import ( - "context" "os" "path/filepath" "strings" @@ -176,7 +175,7 @@ func TestUpperAndWorkCreation(t *testing.T) { } func TestDirMounts(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -247,7 +246,7 @@ func TestDirMounts(t *testing.T) { func TestImageRO(t *testing.T) { require.Command(t, "fusermount") - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -349,7 +348,7 @@ func TestExtfsRW(t *testing.T) { require.Command(t, "fuse-overlayfs") require.Command(t, "fusermount") tmpDir := t.TempDir() - ctx := context.Background() + ctx := t.Context() // Create a copy of the extfs test image to be used for testing writable // extfs image overlays diff --git a/internal/pkg/util/fs/overlay/overlay_linux_test.go b/internal/pkg/util/fs/overlay/overlay_linux_test.go index 64b9897391..339fb32e7b 100644 --- a/internal/pkg/util/fs/overlay/overlay_linux_test.go +++ b/internal/pkg/util/fs/overlay/overlay_linux_test.go @@ -216,16 +216,7 @@ func TestCheckLowerUpper(t *testing.T) { func TestAbsOverlay(t *testing.T) { tmpDir := t.TempDir() - oldDir, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - os.Chdir(oldDir) - }) + t.Chdir(tmpDir) innerDir := filepath.Join(tmpDir, "inner") if err := os.Mkdir(innerDir, 0o755); err != nil { diff --git a/internal/pkg/util/fs/overlay/overlay_set_linux_test.go b/internal/pkg/util/fs/overlay/overlay_set_linux_test.go index 9a6997b574..82c20de79e 100644 --- a/internal/pkg/util/fs/overlay/overlay_set_linux_test.go +++ b/internal/pkg/util/fs/overlay/overlay_set_linux_test.go @@ -61,7 +61,7 @@ func wrapOverlayTest(f func(t *testing.T)) func(t *testing.T) { func TestAllTypesAtOnce(t *testing.T) { wrapOverlayTest(func(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := Set{} tmpRoOlDir := mkTempOlDirOrFatal(t) @@ -129,7 +129,7 @@ func TestAllTypesAtOnce(t *testing.T) { func TestPersistentWriteToDir(t *testing.T) { wrapOverlayTest(func(t *testing.T) { tmpRwOlDir := mkTempOlDirOrFatal(t) - ctx := context.Background() + ctx := t.Context() i, err := NewItemFromString(tmpRwOlDir) if err != nil { t.Fatalf("failed to create writable-dir overlay item (%q): %s", tmpRwOlDir, err) @@ -145,7 +145,7 @@ func TestPersistentWriteToExtfsImg(t *testing.T) { require.Command(t, "fuse-overlayfs") require.Command(t, "fusermount") tmpDir := t.TempDir() - ctx := context.Background() + ctx := t.Context() // Create a copy of the extfs test image to be used for testing writable // extfs image overlays @@ -216,7 +216,7 @@ func TestDuplicateItemsInSet(t *testing.T) { var rwI *Item var err error - ctx := context.Background() + ctx := t.Context() s := Set{} // First, test mounting of an overlay set with only readonly items, one of diff --git a/internal/pkg/util/shell/interpreter/interpreter_test.go b/internal/pkg/util/shell/interpreter/interpreter_test.go index 3981c65ed7..c5bf63796c 100644 --- a/internal/pkg/util/shell/interpreter/interpreter_test.go +++ b/internal/pkg/util/shell/interpreter/interpreter_test.go @@ -193,7 +193,7 @@ func TestInterpreter(t *testing.T) { if tt.openHandler != nil { shell.RegisterOpenHandler(tt.openHandler.path, tt.openHandler.fn(shell)) } - if err := shell.Run(context.Background()); err != nil { + if err := shell.Run(t.Context()); err != nil { if tt.expectExit != 0 && shell.Status() != tt.expectExit { t.Fatalf("unexpected exit status for %s: got %d instead of %d", tt.name, shell.Status(), tt.expectExit) } else if tt.expectExit == 0 { @@ -309,7 +309,7 @@ func TestEvaluateEnv(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - env, err := EvaluateEnv(context.Background(), []byte(tt.script), tt.argv, tt.env) + env, err := EvaluateEnv(t.Context(), []byte(tt.script), tt.argv, tt.env) if !tt.expectErr && err != nil { t.Fatalf("unexpected error: %s", err) } else if tt.expectErr && err == nil { diff --git a/pkg/network/network_linux_test.go b/pkg/network/network_linux_test.go index 1146885039..f7eb92da1b 100644 --- a/pkg/network/network_linux_test.go +++ b/pkg/network/network_linux_test.go @@ -363,7 +363,7 @@ func TestNewSetup(t *testing.T) { } // ping requested IP from host -func testPingIP(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { +func testPingIP(ctx context.Context, nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { testIP := "10.111.111.10" setup, err := NewSetup([]string{"test-bridge"}, "test_", nsPath, cniPath) @@ -371,10 +371,10 @@ func testPingIP(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io return err } setup.SetArgs([]string{"IP=" + testIP}) - if err := setup.AddNetworks(context.Background()); err != nil { + if err := setup.AddNetworks(ctx); err != nil { return err } - defer setup.DelNetworks(context.Background()) + defer setup.DelNetworks(ctx) ip, err := setup.GetNetworkIP("test-bridge", "4") if err != nil { @@ -395,15 +395,15 @@ func testPingIP(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io } // ping random acquired IP from host -func testPingRandomIP(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { +func testPingRandomIP(ctx context.Context, nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { setup, err := NewSetup([]string{"test-bridge"}, "test_", nsPath, cniPath) if err != nil { return err } - if err := setup.AddNetworks(context.Background()); err != nil { + if err := setup.AddNetworks(ctx); err != nil { return err } - defer setup.DelNetworks(context.Background()) + defer setup.DelNetworks(ctx) ip, err := setup.GetNetworkIP("test-bridge", "4") if err != nil { @@ -421,16 +421,16 @@ func testPingRandomIP(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, std } // ping IP from host within requested IP range -func testPingIPRange(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { +func testPingIPRange(ctx context.Context, nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { setup, err := NewSetup([]string{"test-bridge-iprange"}, "test_", nsPath, cniPath) if err != nil { return err } setup.SetArgs([]string{"ipRange=10.111.112.0/24"}) - if err := setup.AddNetworks(context.Background()); err != nil { + if err := setup.AddNetworks(ctx); err != nil { return err } - defer setup.DelNetworks(context.Background()) + defer setup.DelNetworks(ctx) ip, err := setup.GetNetworkIP("test-bridge", "4") if err != nil { @@ -455,16 +455,16 @@ func testPingIPRange(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdo // test port mapping by connecting to port 80 mapped inside container // to 31080 on host -func testHTTPPortmap(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { +func testHTTPPortmap(ctx context.Context, nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { setup, err := NewSetup([]string{"test-bridge"}, "test_", nsPath, cniPath) if err != nil { return err } setup.SetArgs([]string{"portmap=31080:80/tcp"}) - if err := setup.AddNetworks(context.Background()); err != nil { + if err := setup.AddNetworks(ctx); err != nil { return err } - defer setup.DelNetworks(context.Background()) + defer setup.DelNetworks(ctx) eth, err := setup.GetNetworkInterface("test-bridge-iprange") if err != nil { @@ -498,15 +498,16 @@ func testHTTPPortmap(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdo } // try with an non existent plugin -func testBadBridge(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { +func testBadBridge(ctx context.Context, nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdout io.ReadCloser) error { + t.Helper() setup, err := NewSetup([]string{"test-badbridge"}, "", nsPath, cniPath) if err != nil { return err } - if err := setup.AddNetworks(context.Background()); err == nil { + if err := setup.AddNetworks(ctx); err == nil { return fmt.Errorf("unexpected success while calling non existent plugin") } - defer setup.DelNetworks(context.Background()) + defer setup.DelNetworks(ctx) return nil } @@ -523,7 +524,7 @@ func TestAddDelNetworks(t *testing.T) { name string command string args []string - runFunc func(string, *CNIPath, io.WriteCloser, io.ReadCloser) error + runFunc func(context.Context, string, *CNIPath, io.WriteCloser, io.ReadCloser) error }{ { name: "TestPingIP", @@ -579,7 +580,7 @@ func TestAddDelNetworks(t *testing.T) { } nsPath := fmt.Sprintf("/proc/%d/ns/net", cmd.Process.Pid) - if err := c.runFunc(nsPath, cniPath, stdinPipe, stdoutPipe); err != nil { + if err := c.runFunc(t.Context(), nsPath, cniPath, stdinPipe, stdoutPipe); err != nil { t.Errorf("unexpected failure for %q: %s", c.name, err) if err := cmd.Process.Kill(); err != nil { t.Fatalf("error killing process %q: %s", cmdPath, err) diff --git a/pkg/ocibundle/native/bundle_linux_test.go b/pkg/ocibundle/native/bundle_linux_test.go index 7cdb15cab9..1e7d973f56 100644 --- a/pkg/ocibundle/native/bundle_linux_test.go +++ b/pkg/ocibundle/native/bundle_linux_test.go @@ -6,7 +6,6 @@ package native import ( - "context" "os" "os/exec" "reflect" @@ -100,7 +99,7 @@ func TestFromImageRef(t *testing.T) { t.Fatalf("While initializing bundle: %s", err) } - if err := b.Create(context.Background(), nil); err != nil { + if err := b.Create(t.Context(), nil); err != nil { t.Errorf("While creating bundle: %s", err) } @@ -110,7 +109,7 @@ func TestFromImageRef(t *testing.T) { ocitest.ValidateBundle(t, bundleDir) - if err := b.Delete(context.Background()); err != nil { + if err := b.Delete(t.Context()); err != nil { t.Errorf("While deleting bundle: %s", err) } }) diff --git a/pkg/ocibundle/ocisif/bundle_linux_test.go b/pkg/ocibundle/ocisif/bundle_linux_test.go index e1bef119aa..da1bbe69eb 100644 --- a/pkg/ocibundle/ocisif/bundle_linux_test.go +++ b/pkg/ocibundle/ocisif/bundle_linux_test.go @@ -6,7 +6,6 @@ package ocisif import ( - "context" "testing" "github.com/sylabs/singularity/v4/internal/pkg/test" @@ -48,13 +47,13 @@ func TestFromImageRef(t *testing.T) { t.Fatalf("While initializing bundle: %s", err) } - if err := b.Create(context.Background(), nil); err != nil { + if err := b.Create(t.Context(), nil); err != nil { t.Fatalf("While creating bundle: %s", err) } ocitest.ValidateBundle(t, bundleDir) - if err := b.Delete(context.Background()); err != nil { + if err := b.Delete(t.Context()); err != nil { t.Errorf("While deleting bundle: %s", err) } }) diff --git a/pkg/ocibundle/sif/bundle_linux_test.go b/pkg/ocibundle/sif/bundle_linux_test.go index 16e8c6f3db..21576067ba 100644 --- a/pkg/ocibundle/sif/bundle_linux_test.go +++ b/pkg/ocibundle/sif/bundle_linux_test.go @@ -6,7 +6,6 @@ package sifbundle import ( - "context" "path/filepath" "runtime" "testing" @@ -40,7 +39,7 @@ func TestFromSif(t *testing.T) { t.Errorf("unexpected success while opening non existent image") } // create OCI bundle from SIF - if err := bundle.Create(context.Background(), nil); err == nil { + if err := bundle.Create(t.Context(), nil); err == nil { // check if cleanup occurred t.Errorf("unexpected success while creating OCI bundle") } @@ -72,7 +71,7 @@ func TestFromSif(t *testing.T) { g.Config.Linux.Seccomp = nil g.SetProcessArgs([]string{tools.RunScript, "id"}) - if err := bundle.Create(context.Background(), g.Config); err != nil { + if err := bundle.Create(t.Context(), g.Config); err != nil { // check if cleanup occurred t.Fatal(err) } @@ -80,7 +79,7 @@ func TestFromSif(t *testing.T) { ocitest.ValidateBundle(t, bundle.Path()) // Clean up - if err := bundle.Delete(context.Background()); err != nil { + if err := bundle.Delete(t.Context()); err != nil { t.Error(err) } }) diff --git a/pkg/util/unix/socket_test.go b/pkg/util/unix/socket_test.go index db008e07b4..532bfc5a39 100644 --- a/pkg/util/unix/socket_test.go +++ b/pkg/util/unix/socket_test.go @@ -77,7 +77,7 @@ func TestCreateSocket(t *testing.T) { <-syncCh // close socket implies to delete file automatically - os.Chdir(dir) + t.Chdir(dir) ln.Close() // socket file is deleted by net package at close