diff --git a/dev-tools/systemtests/container.go b/dev-tools/systemtests/container.go index c6cc75da15..07a4fdb9cd 100644 --- a/dev-tools/systemtests/container.go +++ b/dev-tools/systemtests/container.go @@ -240,6 +240,13 @@ func (tr *DockerTestRunner) createTestContainer(ctx context.Context, apiClient * containerEnv = append(containerEnv, fmt.Sprintf("MONITOR_PID=%d", tr.MonitorPID)) } + gomodcacheCmd := exec.Command("go", "env", "GOMODCACHE") + gomodcacheValue, err := gomodcacheCmd.CombinedOutput() + require.NoError(tr.Runner, err) + require.NotEmpty(tr.Runner, gomodcacheValue) + + tr.Runner.Logf("out: GOMODCACHE=%s", gomodcacheValue) + resp, err := apiClient.ContainerCreate(ctx, &container.Config{ Image: tr.Container, Cmd: testRunCmd, diff --git a/metric/system/filesystem/filesystem_test.go b/metric/system/filesystem/filesystem_test.go index 135697d473..d6dcea2a19 100644 --- a/metric/system/filesystem/filesystem_test.go +++ b/metric/system/filesystem/filesystem_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-system-metrics/dev-tools/systemtests" @@ -40,11 +41,11 @@ func TestFileSystemList(t *testing.T) { if err != nil { t.Fatal("GetFileSystemList", err) } - assert.True(t, (len(fss) > 0)) + require.True(t, (len(fss) > 0)) for _, fs := range fss { err := fs.GetUsage() - assert.NoError(t, err, "filesystem=%#v: %v", fs, err) + require.NoError(t, err, "filesystem=%#v: %v", fs, err) } } diff --git a/metric/system/process/process_container_test.go b/metric/system/process/process_container_test.go index 39fc8baead..0dbc2aef31 100644 --- a/metric/system/process/process_container_test.go +++ b/metric/system/process/process_container_test.go @@ -20,10 +20,12 @@ package process import ( "fmt" "os" + "os/exec" "os/user" "runtime" "strconv" "testing" + "time" "github.com/stretchr/testify/require" @@ -38,6 +40,13 @@ import ( // However, they are designed so that `go test` can run them normally as well func TestContainerMonitoringFromInsideContainer(t *testing.T) { + gomodcacheCmd := exec.Command("go", "env", "GOMODCACHE") + gomodcacheValue, err1 := gomodcacheCmd.CombinedOutput() + require.NoError(t, err1) + require.NotEmpty(t, gomodcacheValue) + + t.Logf("in: GOMODCACHE=%s", gomodcacheValue) + _ = logp.DevelopmentSetup() testStats := Stats{CPUTicks: true, @@ -64,6 +73,13 @@ func TestContainerMonitoringFromInsideContainer(t *testing.T) { } func TestSelfMonitoringFromInsideContainer(t *testing.T) { + gomodcacheCmd := exec.Command("go", "env", "GOMODCACHE") + gomodcacheValue, err1 := gomodcacheCmd.CombinedOutput() + require.NoError(t, err1) + require.NotEmpty(t, gomodcacheValue) + + t.Logf("in: GOMODCACHE=%s", gomodcacheValue) + _ = logp.DevelopmentSetup() testStats := Stats{CPUTicks: true, @@ -89,6 +105,14 @@ func TestSelfMonitoringFromInsideContainer(t *testing.T) { } func TestSystemHostFromContainer(t *testing.T) { + gomodcacheCmd := exec.Command("go", "env", "GOMODCACHE") + gomodcacheValue, err1 := gomodcacheCmd.CombinedOutput() + require.NoError(t, err1) + require.NotEmpty(t, gomodcacheValue) + + t.Logf("in: GOMODCACHE=%s", gomodcacheValue) + + t.Logf("start: %v", time.Now()) _ = logp.DevelopmentSetup() testStats := Stats{CPUTicks: true, @@ -120,6 +144,7 @@ func TestSystemHostFromContainer(t *testing.T) { proc["process"].(map[string]interface{})["command_line"]) } } + t.Logf("end: %v", time.Now()) } // validate test results.