Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect hermes config.toml file in e2e diagnostics #5420

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
14 changes: 10 additions & 4 deletions e2e/testsuite/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Collect(t *testing.T, dc *dockerclient.Client, debugModeEnabled bool, chain

testContainers, err := dockerutil.GetTestContainers(ctx, t, dc)
if err != nil {
t.Logf("failed listing containers test cleanup: %s", err)
t.Logf("failed listing containers during test cleanup: %s", err)
return
}

Expand All @@ -72,7 +72,6 @@ func Collect(t *testing.T, dc *dockerclient.Client, debugModeEnabled bool, chain

logFile := fmt.Sprintf("%s/%s.log", containerDir, containerName)
if err := os.WriteFile(logFile, logsBz, defaultFilePerm); err != nil {
t.Logf("failed writing log file for container %s in test cleanup: %s", containerName, err)
continue
}

Expand All @@ -82,19 +81,18 @@ func Collect(t *testing.T, dc *dockerclient.Client, debugModeEnabled bool, chain
for _, chainName := range chainNames {
diagnosticFiles = append(diagnosticFiles, chainDiagnosticAbsoluteFilePaths(chainName)...)
}
diagnosticFiles = append(diagnosticFiles, relayerDiagnosticAbsoluteFilePaths()...)

for _, absoluteFilePathInContainer := range diagnosticFiles {
localFilePath := ospath.Join(containerDir, ospath.Base(absoluteFilePathInContainer))
if err := fetchAndWriteDiagnosticsFile(ctx, dc, container.ID, localFilePath, absoluteFilePathInContainer); err != nil {
t.Logf("failed to fetch and write file %s for container %s in test cleanup: %s", absoluteFilePathInContainer, containerName, err)
continue
}
t.Logf("successfully wrote diagnostics file %s", absoluteFilePathInContainer)
}

localFilePath := ospath.Join(containerDir, dockerInspectFileName)
if err := fetchAndWriteDockerInspectOutput(ctx, dc, container.ID, localFilePath); err != nil {
t.Logf("failed to fetch docker inspect output: %s", err)
continue
}
t.Logf("successfully wrote docker inspect output")
Expand Down Expand Up @@ -156,6 +154,14 @@ func chainDiagnosticAbsoluteFilePaths(chainName string) []string {
}
}

// relayerDiagnosticAbsoluteFilePaths returns a slice of absolute file paths (in the containers) which are the files that should be
// copied locally when fetching diagnostics.
func relayerDiagnosticAbsoluteFilePaths() []string {
return []string{
"/home/hermes/.hermes/config.toml",
}
}

// getE2EDir finds the e2e directory above the test.
func getE2EDir(t *testing.T) (string, error) {
t.Helper()
Expand Down
11 changes: 2 additions & 9 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ func (s *E2ETestSuite) ConfigureRelayer(ctx context.Context, chainA, chainB ibc.
s.startRelayerFn = func(relayer ibc.Relayer) {
err := relayer.StartRelayer(ctx, eRep, pathName)
s.Require().NoError(err, fmt.Sprintf("failed to start relayer: %s", err))
s.T().Cleanup(func() {
if !s.T().Failed() {
if err := relayer.StopRelayer(ctx, eRep); err != nil {
s.T().Logf("error stopping relayer: %v", err)
}
}
})
Comment on lines -138 to -144
Copy link
Contributor Author

@chatton chatton Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block isn't required as the containers are cleaned up at the end of the tests anyway. This was also removing the hermes container before the logs would be collected.

// wait for relayer to start.
s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks")
}
Expand Down Expand Up @@ -377,9 +370,9 @@ func (s *E2ETestSuite) createChains(chainOptions ChainOptions) (ibc.Chain, ibc.C
// cleanup task which deletes all containers. By registering a cleanup function afterwards, it is executed first
// this allows us to process the logs before the containers are removed.
t.Cleanup(func() {
debugModeEnabled := LoadConfig().DebugConfig.DumpLogs
dumpLogs := LoadConfig().DebugConfig.DumpLogs
chains := []string{chainOptions.ChainASpec.ChainConfig.Name, chainOptions.ChainBSpec.ChainConfig.Name}
diagnostics.Collect(t, s.DockerClient, debugModeEnabled, chains...)
diagnostics.Collect(t, s.DockerClient, dumpLogs, chains...)
})

chains, err := cf.Chains(t.Name())
Expand Down
Loading