@@ -66,19 +66,63 @@ class TestStack {
66
66
Service : 'Powertools-for-AWS-e2e-tests' ,
67
67
} ,
68
68
} ) ;
69
+ let lastCreateLog = 0 ;
70
+ let lastDestroyLog = 0 ;
71
+ const creationDeleteLogFrequency = 10000 ; // 10 seconds
72
+ const that = this ;
69
73
this . #cli = new Toolkit ( {
70
74
color : false ,
71
75
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
+ */
72
86
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 ) {
73
120
if (
74
121
process . env . RUNNER_DEBUG === '1' ||
75
122
[ 'warning' , 'error' ] . includes ( msg . level )
76
123
) {
77
124
testConsole . log ( msg ) ;
78
125
}
79
- } ,
80
- async requestResponse ( msg ) {
81
- testConsole . log ( msg ) ;
82
126
return msg . defaultResponse ;
83
127
} ,
84
128
} ,
0 commit comments