diff --git a/internal/pkg/agent/cmd/container.go b/internal/pkg/agent/cmd/container.go index a00cc2f58ee..9e51cd93489 100644 --- a/internal/pkg/agent/cmd/container.go +++ b/internal/pkg/agent/cmd/container.go @@ -780,7 +780,7 @@ func setPaths(statePath, configPath, logsPath, socketPath string, writePaths boo // the statePath when concatenated with the socked name is going to // be smaller than 104 characters. if len(statePath) > 75 { - statePath = utils.SocketFallbackDirectory + statePath = utils.SocketURLWithFallback(statePath, paths.TempDir()) } topPath := filepath.Join(statePath, "data") diff --git a/testing/integration/container_cmd_test.go b/testing/integration/container_cmd_test.go index 748a3874e12..6d321c038f5 100644 --- a/testing/integration/container_cmd_test.go +++ b/testing/integration/container_cmd_test.go @@ -106,7 +106,7 @@ func TestContainerCMD(t *testing.T) { OS: []define.OS{ {Type: define.Linux}, }, - Group: define.Default, + Group: "container", }) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) @@ -164,7 +164,7 @@ func TestContainerCMDWithAVeryLongStatePath(t *testing.T) { OS: []define.OS{ {Type: define.Linux}, }, - Group: define.Default, + Group: "container", }) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) @@ -182,6 +182,15 @@ func TestContainerCMDWithAVeryLongStatePath(t *testing.T) { // so we join the workdir and a 120 characters long string. statePath := filepath.Join(agentFixture.WorkDir(), "de9a2a338c4fe10a466ee9fae57ce0c8a5b010dfcd6bd3f41d2c569ef5ed873193fd7d1966a070174f47f93ee667f921616c2d6d29efb6dbcc2b8b33") + // We know it will use the OS temp folder for the state path, so we try + // to clean it up at the end of the test. + t.Cleanup(func() { + defaultStatePath := "/tmp/elastic-agent" + if err := os.RemoveAll(defaultStatePath); err != nil { + t.Errorf("could not remove config path '%s': %s", defaultStatePath, err) + } + }) + enrollmentToken := createPolicy(t, ctx, agentFixture, info) env := []string{ "FLEET_ENROLL=1",