Skip to content

Commit

Permalink
chore: collect hermes config.toml (cosmos#5420)
Browse files Browse the repository at this point in the history
  • Loading branch information
chatton committed Dec 14, 2023
1 parent a7a7865 commit d0cf5b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
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)
}
}
})
// 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

0 comments on commit d0cf5b6

Please sign in to comment.