-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move output dir logic to suite (#29580)
- Loading branch information
Showing
8 changed files
with
148 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import ( | |
"github.com/stretchr/testify/require" | ||
|
||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" | ||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner" | ||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client/agentclient" | ||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client/agentclientparams" | ||
) | ||
|
@@ -197,13 +196,15 @@ func waitForReadyTimeout(t *testing.T, host *Host, commandRunner *agentCommandRu | |
} | ||
|
||
func generateAndDownloadFlare(t *testing.T, commandRunner *agentCommandRunner, host *Host) error { | ||
profile := runner.GetProfile() | ||
outputDir, err := profile.GetOutputDir() | ||
flareFound := false | ||
|
||
root, err := e2e.CreateRootOutputDir() | ||
if err != nil { | ||
return fmt.Errorf("could not get output directory: %v", err) | ||
return fmt.Errorf("could not get root output directory: %w", err) | ||
} | ||
outputDir, err := e2e.CreateTestOutputDir(root, t) | ||
if err != nil { | ||
return fmt.Errorf("could not get output directory: %w", err) | ||
} | ||
flareFound := false | ||
|
||
_, err = commandRunner.FlareWithError(agentclient.WithArgs([]string{"--email", "[email protected]", "--send", "--local"})) | ||
if err != nil { | ||
|
@@ -213,17 +214,17 @@ func generateAndDownloadFlare(t *testing.T, commandRunner *agentCommandRunner, h | |
|
||
flareRegex, err := regexp.Compile(`datadog-agent-.*\.zip`) | ||
if err != nil { | ||
return fmt.Errorf("could not compile regex: %v", err) | ||
return fmt.Errorf("could not compile regex: %w", err) | ||
} | ||
|
||
tmpFolder, err := host.GetTmpFolder() | ||
if err != nil { | ||
return fmt.Errorf("could not get tmp folder: %v", err) | ||
return fmt.Errorf("could not get tmp folder: %w", err) | ||
} | ||
|
||
entries, err := host.ReadDir(tmpFolder) | ||
if err != nil { | ||
return fmt.Errorf("could not read directory: %v", err) | ||
return fmt.Errorf("could not read directory: %w", err) | ||
} | ||
|
||
for _, entry := range entries { | ||
|
@@ -233,15 +234,15 @@ func generateAndDownloadFlare(t *testing.T, commandRunner *agentCommandRunner, h | |
if host.osFamily != osComp.WindowsFamily { | ||
_, err = host.Execute(fmt.Sprintf("sudo chmod 744 %s/%s", tmpFolder, entry.Name())) | ||
if err != nil { | ||
return fmt.Errorf("could not update permission of flare file %s/%s : %v", tmpFolder, entry.Name(), err) | ||
return fmt.Errorf("could not update permission of flare file %s/%s : %w", tmpFolder, entry.Name(), err) | ||
} | ||
} | ||
|
||
t.Logf("Downloading flare file in: %s", outputDir) | ||
err = host.GetFile(fmt.Sprintf("%s/%s", tmpFolder, entry.Name()), fmt.Sprintf("%s/%s", outputDir, entry.Name())) | ||
|
||
if err != nil { | ||
return fmt.Errorf("could not download flare file from %s/%s : %v", tmpFolder, entry.Name(), err) | ||
return fmt.Errorf("could not download flare file from %s/%s : %w", tmpFolder, entry.Name(), err) | ||
} | ||
|
||
flareFound = true | ||
|
@@ -253,21 +254,21 @@ func generateAndDownloadFlare(t *testing.T, commandRunner *agentCommandRunner, h | |
|
||
logsFolder, err := host.GetLogsFolder() | ||
if err != nil { | ||
return fmt.Errorf("could not get logs folder: %v", err) | ||
return fmt.Errorf("could not get logs folder: %w", err) | ||
} | ||
|
||
entries, err = host.ReadDir(logsFolder) | ||
|
||
if err != nil { | ||
return fmt.Errorf("could not read directory: %v", err) | ||
return fmt.Errorf("could not read directory: %w", err) | ||
} | ||
|
||
for _, entry := range entries { | ||
t.Logf("Found log file: %s. Downloading file in: %s", entry.Name(), outputDir) | ||
|
||
err = host.GetFile(fmt.Sprintf("%s/%s", logsFolder, entry.Name()), fmt.Sprintf("%s/%s", outputDir, entry.Name())) | ||
if err != nil { | ||
return fmt.Errorf("could not download log file from %s/%s : %v", logsFolder, entry.Name(), err) | ||
return fmt.Errorf("could not download log file from %s/%s : %w", logsFolder, entry.Name(), err) | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.