4
4
* @group e2e/parameters/appconfig/class
5
5
*/
6
6
import path from 'path' ;
7
- import { App , Stack , Aspects } from 'aws-cdk-lib' ;
7
+ import { App , Stack , Aspects , Duration } from 'aws-cdk-lib' ;
8
8
import { toBase64 } from '@aws-sdk/util-base64-node' ;
9
9
import { v4 } from 'uuid' ;
10
10
import {
@@ -111,6 +111,7 @@ let stack: Stack;
111
111
* Test 6
112
112
* get parameter twice, but force fetch 2nd time, we count number of SDK requests and
113
113
* check that we made two API calls
114
+ * check that we got matching results
114
115
*
115
116
* Note: To avoid race conditions, we add a dependency between each pair of configuration profiles.
116
117
* This allows us to influence the order of creation and ensure that each configuration profile
@@ -141,6 +142,7 @@ describe(`parameters E2E tests (appConfigProvider) for runtime ${runtime}`, () =
141
142
FEATURE_FLAG_NAME : featureFlagName ,
142
143
} ,
143
144
runtime,
145
+ timeout : Duration . seconds ( 10 ) ,
144
146
} ) ;
145
147
146
148
// Create the base resources for an AppConfig application.
@@ -291,8 +293,12 @@ describe(`parameters E2E tests (appConfigProvider) for runtime ${runtime}`, () =
291
293
it ( 'should retrieve single parameter cached' , ( ) => {
292
294
293
295
const logs = invocationLogs [ 0 ] . getFunctionLogs ( ) ;
294
- const testLog = InvocationLogs . parseFunctionLog ( logs [ 4 ] ) ;
295
296
297
+ const resultLog1 = InvocationLogs . parseFunctionLog ( logs [ 4 ] ) ;
298
+ const resultLog2 = InvocationLogs . parseFunctionLog ( logs [ 5 ] ) ;
299
+ expect ( resultLog1 . value ) . toStrictEqual ( resultLog2 . value ) ;
300
+
301
+ const testLog = InvocationLogs . parseFunctionLog ( logs [ 6 ] ) ;
296
302
expect ( testLog ) . toStrictEqual ( {
297
303
test : 'get-cached' ,
298
304
value : 1
@@ -305,7 +311,7 @@ describe(`parameters E2E tests (appConfigProvider) for runtime ${runtime}`, () =
305
311
it ( 'should retrieve single parameter twice without caching' , async ( ) => {
306
312
307
313
const logs = invocationLogs [ 0 ] . getFunctionLogs ( ) ;
308
- const testLog = InvocationLogs . parseFunctionLog ( logs [ 5 ] ) ;
314
+ const testLog = InvocationLogs . parseFunctionLog ( logs [ 7 ] ) ;
309
315
310
316
expect ( testLog ) . toStrictEqual ( {
311
317
test : 'get-forced' ,
@@ -314,6 +320,27 @@ describe(`parameters E2E tests (appConfigProvider) for runtime ${runtime}`, () =
314
320
315
321
} , TEST_CASE_TIMEOUT ) ;
316
322
323
+ // Test 7 - get parameter twice, wait for expiration betweenn
324
+ // we count number of SDK requests and check that we made two API calls
325
+ // and check that the values match
326
+ it ( 'should retrieve single parameter twice, with expiration between and matching values' , async ( ) => {
327
+
328
+ const logs = invocationLogs [ 0 ] . getFunctionLogs ( ) ;
329
+
330
+ const resultLog1 = InvocationLogs . parseFunctionLog ( logs [ 8 ] ) ;
331
+ const resultLog2 = InvocationLogs . parseFunctionLog ( logs [ 9 ] ) ;
332
+ expect ( resultLog1 . test ) . toBe ( 'get-expired-result1' ) ;
333
+ expect ( resultLog2 . test ) . toBe ( 'get-expired-result2' ) ;
334
+ expect ( resultLog1 . value ) . toStrictEqual ( resultLog2 . value ) ;
335
+
336
+ const testLog = InvocationLogs . parseFunctionLog ( logs [ 10 ] ) ;
337
+ expect ( testLog ) . toStrictEqual ( {
338
+ test : 'get-expired' ,
339
+ value : 2
340
+ } ) ;
341
+
342
+ } , TEST_CASE_TIMEOUT ) ;
343
+
317
344
} ) ;
318
345
319
346
afterAll ( async ( ) => {
0 commit comments