mirror of
https://github.com/moby/moby.git
synced 2026-07-12 18:45:06 +00:00
Integration tests will now configure clients to propagate traces as well as create spans for all tests. Some extra changes were needed (or desired for trace propagation) in the test helpers to pass through tracing spans via context. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
49 lines
1016 B
Go
49 lines
1016 B
Go
package logging // import "github.com/docker/docker/integration/plugin/logging"
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/docker/docker/testutil"
|
|
"github.com/docker/docker/testutil/environment"
|
|
"go.opentelemetry.io/otel"
|
|
"go.opentelemetry.io/otel/codes"
|
|
)
|
|
|
|
var (
|
|
testEnv *environment.Execution
|
|
baseContext context.Context
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
shutdown := testutil.ConfigureTracing()
|
|
ctx, span := otel.Tracer("").Start(context.Background(), "integration/plugin/logging.TestMain")
|
|
baseContext = ctx
|
|
|
|
var err error
|
|
testEnv, err = environment.New(ctx)
|
|
if err != nil {
|
|
span.SetStatus(codes.Error, err.Error())
|
|
span.End()
|
|
shutdown(ctx)
|
|
panic(err)
|
|
}
|
|
err = environment.EnsureFrozenImagesLinux(ctx, testEnv)
|
|
if err != nil {
|
|
span.SetStatus(codes.Error, err.Error())
|
|
span.End()
|
|
shutdown(ctx)
|
|
panic(err)
|
|
}
|
|
|
|
testEnv.Print()
|
|
code := m.Run()
|
|
span.End()
|
|
if code != 0 {
|
|
span.SetStatus(codes.Error, "m.Run() exited with non-zero code")
|
|
}
|
|
shutdown(ctx)
|
|
os.Exit(code)
|
|
}
|