-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into test-deprecations
- Loading branch information
Showing
15 changed files
with
296 additions
and
249 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Duration, Stack } from "aws-cdk-lib"; | ||
import { Metric } from "aws-cdk-lib/aws-cloudwatch"; | ||
import { Construct } from "constructs"; | ||
|
||
import { | ||
AlarmFactory, | ||
AlarmFactoryDefaults, | ||
LatencyAlarmFactory, | ||
LatencyType, | ||
MetricFactoryDefaults, | ||
noopAction, | ||
} from "../../../lib"; | ||
|
||
const stack = new Stack(); | ||
const construct = new Construct(stack, "SampleConstruct"); | ||
|
||
const globalMetricDefaults: MetricFactoryDefaults = { | ||
namespace: "DummyNamespace", | ||
}; | ||
const globalAlarmDefaults: AlarmFactoryDefaults = { | ||
alarmNamePrefix: "DummyServiceAlarms", | ||
actionsEnabled: true, | ||
datapointsToAlarm: 6, | ||
// we do not care about alarm actions in this test | ||
action: noopAction(), | ||
}; | ||
const factory = new AlarmFactory(construct, { | ||
globalMetricDefaults, | ||
globalAlarmDefaults, | ||
localAlarmNamePrefix: "prefix", | ||
}); | ||
|
||
const metric = new Metric({ | ||
metricName: "DummyMetric1", | ||
namespace: "DummyCustomNamespace", | ||
dimensionsMap: { CustomDimension: "CustomDimensionValue" }, | ||
}); | ||
|
||
const latencyAlarmFactory = new LatencyAlarmFactory(factory); | ||
|
||
test("addLatencyAlarm: non-integral millisecond thresholds do not throw error", () => { | ||
latencyAlarmFactory.addLatencyAlarm(metric, LatencyType.P99, { | ||
maxLatency: Duration.millis(0.5), | ||
}); | ||
}); | ||
|
||
test("addIntegrationLatencyAlarm: non-integral millisecond thresholds do not throw error", () => { | ||
latencyAlarmFactory.addIntegrationLatencyAlarm(metric, LatencyType.P99, { | ||
maxLatency: Duration.millis(2.5), | ||
}); | ||
}); | ||
|
||
test("addDurationAlarm: non-integral millisecond durations do not throw error", () => { | ||
latencyAlarmFactory.addDurationAlarm(metric, LatencyType.P99, { | ||
maxDuration: Duration.millis(0.5), | ||
}); | ||
}); | ||
|
||
test("addJvmGarbageCollectionDurationAlarm: non-integral millisecond durations do not throw error", () => { | ||
latencyAlarmFactory.addJvmGarbageCollectionDurationAlarm( | ||
metric, | ||
LatencyType.P99, | ||
{ | ||
maxDuration: Duration.millis(2.5), | ||
}, | ||
); | ||
}); |
18 changes: 9 additions & 9 deletions
18
test/common/metric/__snapshots__/MetricFactory.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.