@@ -66,19 +66,63 @@ class TestStack {
6666 Service : 'Powertools-for-AWS-e2e-tests' ,
6767 } ,
6868 } ) ;
69+ let lastCreateLog = 0 ;
70+ let lastDestroyLog = 0 ;
71+ const creationDeleteLogFrequency = 10000 ; // 10 seconds
72+ const that = this ;
6973 this . #cli = new Toolkit ( {
7074 color : false ,
7175 ioHost : {
76+ /**
77+ * Log messages to the console depending on the log level.
78+ *
79+ * If the `RUNNER_DEBUG` environment variable is set to `1`, all messages are logged.
80+ *
81+ * Otherwise, we log messages that are either warnings or errors as well as periodic
82+ * updates on the stack creation and destruction process.
83+ *
84+ * @param msg - Message to log sent by the CDK CLI
85+ */
7286 async notify ( msg ) {
87+ if ( process . env . RUNNER_DEBUG === '1' ) {
88+ testConsole . log ( msg ) ;
89+ return ;
90+ }
91+ if ( msg . message . includes ( 'destroyed' ) && msg . message . includes ( '✅' ) ) {
92+ testConsole . log ( msg . message ) ;
93+ return ;
94+ }
95+ if ( msg . message . includes ( '✅' ) && ! msg . message . includes ( 'deployed' ) ) {
96+ testConsole . log ( `${ that . testName } deployed successfully` ) ;
97+ return ;
98+ }
99+ if ( msg . message . includes ( 'CREATE_IN_PROGRESS' ) ) {
100+ if ( Date . now ( ) - lastCreateLog < creationDeleteLogFrequency ) {
101+ return ;
102+ }
103+ lastCreateLog = Date . now ( ) ;
104+ testConsole . log ( `${ that . testName } stack is being created...` ) ;
105+ return ;
106+ }
107+ if ( msg . message . includes ( 'DELETE_IN_PROGRESS' ) ) {
108+ if ( Date . now ( ) - lastDestroyLog < creationDeleteLogFrequency ) {
109+ return ;
110+ }
111+ lastDestroyLog = Date . now ( ) ;
112+ testConsole . log ( `${ that . testName } stack is being destroyed...` ) ;
113+ return ;
114+ }
115+ if ( [ 'warning' , 'error' ] . includes ( msg . level ) ) {
116+ testConsole . log ( msg ) ;
117+ }
118+ } ,
119+ async requestResponse ( msg ) {
73120 if (
74121 process . env . RUNNER_DEBUG === '1' ||
75122 [ 'warning' , 'error' ] . includes ( msg . level )
76123 ) {
77124 testConsole . log ( msg ) ;
78125 }
79- } ,
80- async requestResponse ( msg ) {
81- testConsole . log ( msg ) ;
82126 return msg . defaultResponse ;
83127 } ,
84128 } ,
0 commit comments