Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 3573e1a

Browse files
authored
[TT-1894] add logstream flushing to default ccip cleanup (#1570)
## Motivation No Docker container logs are ever dumped. ## Solution CCIP local cluster setup was missing crucial part of flushing the logs.
1 parent 80dd5d2 commit 3573e1a

File tree

1 file changed

+23
-0
lines changed
  • integration-tests/ccip-tests/testsetups

1 file changed

+23
-0
lines changed

integration-tests/ccip-tests/testsetups/ccip.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/smartcontractkit/chainlink-testing-framework/lib/k8s/config"
3636
"github.com/smartcontractkit/chainlink-testing-framework/lib/k8s/environment"
3737
"github.com/smartcontractkit/chainlink-testing-framework/lib/networks"
38+
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/osutil"
3839
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
3940

4041
integrationactions "github.com/smartcontractkit/chainlink/integration-tests/actions"
@@ -1386,6 +1387,10 @@ func (o *CCIPTestSetUpOutputs) CreateEnvironment(
13861387
t.Cleanup(func() {
13871388
if configureCLNode {
13881389
if ccipEnv.LocalCluster != nil {
1390+
if t.Failed() || (ccipEnv.LocalCluster.TestConfig.GetLoggingConfig() != nil && ccipEnv.LocalCluster.TestConfig.GetLoggingConfig().TestLogCollect != nil && *ccipEnv.LocalCluster.TestConfig.GetLoggingConfig().TestLogCollect) {
1391+
flushClLogs(*lggr, ccipEnv.LocalCluster)
1392+
}
1393+
13891394
err := ccipEnv.LocalCluster.Terminate()
13901395
require.NoError(t, err, "Local cluster termination shouldn't fail")
13911396
require.NoError(t, o.Reporter.SendReport(t, namespace, false), "Aggregating and sending report shouldn't fail")
@@ -1406,6 +1411,24 @@ func (o *CCIPTestSetUpOutputs) CreateEnvironment(
14061411
return chainByChainID
14071412
}
14081413

1414+
func flushClLogs(l zerolog.Logger, testEnv *test_env.CLClusterTestEnv) {
1415+
l.Info().Msg("Shutting down LogStream")
1416+
logPath, err := osutil.GetAbsoluteFolderPath("logs")
1417+
if err == nil {
1418+
l.Info().Str("Absolute path", logPath).Msg("LogStream logs folder location")
1419+
}
1420+
1421+
l.Info().Msg("Flushing LogStream logs")
1422+
// we can't do much if this fails, so we just log the error in LogStream
1423+
if err := testEnv.LogStream.FlushAndShutdown(); err != nil {
1424+
l.Error().Err(err).Msg("Error flushing and shutting down LogStream")
1425+
}
1426+
testEnv.LogStream.PrintLogTargetsLocations()
1427+
testEnv.LogStream.SaveLogLocationInTestSummary()
1428+
1429+
l.Info().Msg("Finished shutting down LogStream")
1430+
}
1431+
14091432
func createEnvironmentConfig(t *testing.T, envName string, testConfig *CCIPTestConfig, reportPath string) *environment.Config {
14101433
envConfig := &environment.Config{
14111434
NamespacePrefix: envName,

0 commit comments

Comments
 (0)