Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(compat): avoid CloudWatch statistics time race (#3320)

Niels Kootstrabf49390969ce
diff --git a/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts b/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts
index f3820dd3f9..309c8720e2 100644
--- a/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts
+++ b/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts
@@ -77,8 +77,7 @@ describe('CloudWatch Metrics', () => {
});
it('should put metric data with statistic values', async () => {
- const now = new Date();
- const start = new Date(now.getTime() - 3600000);
+ const start = new Date(Date.now() - 3600000);
// Put metric data with pre-calculated statistics
await cw.send(
@@ -100,12 +99,13 @@ describe('CloudWatch Metrics', () => {
);
// Query back the statistics
+ const end = new Date();
const response = await cw.send(
new GetMetricStatisticsCommand({
Namespace: namespace,
MetricName: 'AggregatedMetric',
StartTime: start,
- EndTime: now,
+ EndTime: end,
Period: 3600,
Statistics: ['Sum', 'Average', 'Minimum', 'Maximum', 'SampleCount'],
})