@@ -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+
14091432func createEnvironmentConfig (t * testing.T , envName string , testConfig * CCIPTestConfig , reportPath string ) * environment.Config {
14101433 envConfig := & environment.Config {
14111434 NamespacePrefix : envName ,
0 commit comments