2018-02-05 21:05:59 +00:00
|
|
|
package image // import "github.com/docker/docker/integration/image"
|
2017-11-22 16:13:32 +00:00
|
|
|
|
|
|
|
import (
|
2023-07-14 18:02:38 +00:00
|
|
|
"context"
|
2017-11-22 16:13:32 +00:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
"github.com/docker/docker/testutil"
|
2019-08-29 20:52:40 +00:00
|
|
|
"github.com/docker/docker/testutil/environment"
|
2023-07-14 18:02:38 +00:00
|
|
|
"go.opentelemetry.io/otel"
|
|
|
|
"go.opentelemetry.io/otel/codes"
|
2017-11-22 16:13:32 +00:00
|
|
|
)
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
var (
|
|
|
|
testEnv *environment.Execution
|
|
|
|
baseContext context.Context
|
|
|
|
)
|
2017-11-22 16:13:32 +00:00
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
2023-07-14 18:02:38 +00:00
|
|
|
shutdown := testutil.ConfigureTracing()
|
|
|
|
ctx, span := otel.Tracer("").Start(context.Background(), "integration/daemon/TestMain")
|
|
|
|
baseContext = ctx
|
|
|
|
|
2017-11-22 16:13:32 +00:00
|
|
|
var err error
|
2023-07-14 18:02:38 +00:00
|
|
|
testEnv, err = environment.New(ctx)
|
2017-11-22 16:13:32 +00:00
|
|
|
if err != nil {
|
2023-07-14 18:02:38 +00:00
|
|
|
span.SetStatus(codes.Error, err.Error())
|
|
|
|
span.End()
|
|
|
|
shutdown(ctx)
|
|
|
|
panic(err)
|
2017-11-22 16:13:32 +00:00
|
|
|
}
|
2023-07-14 18:02:38 +00:00
|
|
|
err = environment.EnsureFrozenImagesLinux(ctx, testEnv)
|
2017-11-22 16:13:32 +00:00
|
|
|
if err != nil {
|
2023-07-14 18:02:38 +00:00
|
|
|
span.SetStatus(codes.Error, err.Error())
|
|
|
|
span.End()
|
|
|
|
shutdown(ctx)
|
|
|
|
panic(err)
|
2017-11-22 16:13:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testEnv.Print()
|
|
|
|
os.Exit(m.Run())
|
|
|
|
}
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
func setupTest(t *testing.T) context.Context {
|
|
|
|
ctx := testutil.StartSpan(baseContext, t)
|
|
|
|
environment.ProtectAll(ctx, t, testEnv)
|
|
|
|
t.Cleanup(func() { testEnv.Clean(ctx, t) })
|
|
|
|
return ctx
|
2017-11-22 16:13:32 +00:00
|
|
|
}
|