Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dev-tools/systemtests/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions metric/system/filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)

}
}
Expand Down
25 changes: 25 additions & 0 deletions metric/system/process/process_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ package process
import (
"fmt"
"os"
"os/exec"
"os/user"
"runtime"
"strconv"
"testing"
"time"

"github.com/stretchr/testify/require"

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
Loading