in dev-tools/systemtests/container.go [146:207]
func (tr *DockerTestRunner) RunTestsOnDocker(ctx context.Context) {
// do we want to run on windows? Much of what we're testing, such as host
// cgroup monitoring, is invalid.
if runtime.GOOS != "linux" {
tr.Runner.Skip("Tests only supported on Linux.")
}
log := logp.L()
if tr.Basepath == "" {
tr.Basepath = "./..."
}
if tr.Container == "" {
tr.Container = "golang:latest"
}
// setup and run
apiClient, err := client.NewClientWithOpts(client.WithAPIVersionNegotiation())
require.NoError(tr.Runner, err)
defer apiClient.Close()
_, err = apiClient.ContainerList(ctx, container.ListOptions{})
if err != nil {
tr.Runner.Skipf("got error in container list, docker isn't installed or not running: %s", err)
}
// create monitored process, if we need to
tr.createMonitoredProcess(ctx)
resp := tr.createTestContainer(ctx, apiClient)
log.Infof("running test...")
result := tr.runContainerTest(ctx, apiClient, resp)
// check for failures
require.Equal(tr.Runner, int64(0), result.ReturnCode, "got bad docker return code. stdout: %s \nstderr: %s", result.Stdout, result.Stderr)
if tr.Verbose {
fmt.Fprintf(os.Stdout, "stderr: %s\n", result.Stderr)
fmt.Fprintf(os.Stdout, "stdout: %s\n", result.Stdout)
}
// iterate by lines to make this easier to read
if len(tr.FatalLogMessages) > 0 {
for _, badLine := range tr.FatalLogMessages {
for _, line := range strings.Split(result.Stdout, "\n") {
require.NotContains(tr.Runner, line, badLine)
}
for _, line := range strings.Split(result.Stderr, "\n") {
// filter our the go mod package download messages
if !strings.Contains(line, "go: downloading") {
require.NotContains(tr.Runner, line, badLine)
}
}
}
}
}