@@ -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"
@@ -1393,6 +1394,10 @@ func (o *CCIPTestSetUpOutputs) CreateEnvironment(
13931394 t .Cleanup (func () {
13941395 if configureCLNode {
13951396 if ccipEnv .LocalCluster != nil {
1397+ if t .Failed () || (ccipEnv .LocalCluster .TestConfig .GetLoggingConfig () != nil && ccipEnv .LocalCluster .TestConfig .GetLoggingConfig ().TestLogCollect != nil && * ccipEnv .LocalCluster .TestConfig .GetLoggingConfig ().TestLogCollect ) {
1398+ flushClLogs (* lggr , ccipEnv .LocalCluster )
1399+ }
1400+
13961401 err := ccipEnv .LocalCluster .Terminate ()
13971402 require .NoError (t , err , "Local cluster termination shouldn't fail" )
13981403 require .NoError (t , o .Reporter .SendReport (t , namespace , false ), "Aggregating and sending report shouldn't fail" )
@@ -1413,6 +1418,24 @@ func (o *CCIPTestSetUpOutputs) CreateEnvironment(
14131418 return chainByChainID
14141419}
14151420
1421+ func flushClLogs (l zerolog.Logger , testEnv * test_env.CLClusterTestEnv ) {
1422+ l .Info ().Msg ("Shutting down LogStream" )
1423+ logPath , err := osutil .GetAbsoluteFolderPath ("logs" )
1424+ if err == nil {
1425+ l .Info ().Str ("Absolute path" , logPath ).Msg ("LogStream logs folder location" )
1426+ }
1427+
1428+ l .Info ().Msg ("Flushing LogStream logs" )
1429+ // we can't do much if this fails, so we just log the error in LogStream
1430+ if err := testEnv .LogStream .FlushAndShutdown (); err != nil {
1431+ l .Error ().Err (err ).Msg ("Error flushing and shutting down LogStream" )
1432+ }
1433+ testEnv .LogStream .PrintLogTargetsLocations ()
1434+ testEnv .LogStream .SaveLogLocationInTestSummary ()
1435+
1436+ l .Info ().Msg ("Finished shutting down LogStream" )
1437+ }
1438+
14161439func createEnvironmentConfig (t * testing.T , envName string , testConfig * CCIPTestConfig , reportPath string ) * environment.Config {
14171440 envConfig := & environment.Config {
14181441 NamespacePrefix : envName ,
0 commit comments