Skip to content

Commit

Permalink
Fix Windows and use "container" test group
Browse files Browse the repository at this point in the history
This commit fixes the implementation on Windows and puts the
container integration tests in the container group again. The test for
long state paths will create files outside of the test directory.

It also cleans up the default folder used as state path.
  • Loading branch information
belimawr committed Jun 11, 2024
1 parent 8679507 commit 085517f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 11 additions & 2 deletions testing/integration/container_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand Down

0 comments on commit 085517f

Please sign in to comment.