Exemple #1
0
        private async Task <AlarmDefinition> AlarmWithMergedValues(
            AwsResource <T> entity,
            AlarmDefinition alarm,
            AwsServiceAlarms <TAlarmConfig> serviceConfig,
            ResourceThresholds <TAlarmConfig> resourceConfig)
        {
            var mergedThreshold = MergeValueOverrides(alarm.Name, new [] { resourceConfig.Values, serviceConfig.Values });
            var config          = MergeConfiguration(serviceConfig.Options, resourceConfig.Options);

            var copy = alarm.Copy();

            copy.Threshold = await ExpandThreshold(entity.Resource, config, new Threshold
            {
                SourceAttribute = alarm.Threshold.SourceAttribute,
                ThresholdType   = alarm.Threshold.ThresholdType,
                Value           = mergedThreshold.Threshold ?? alarm.Threshold.Value
            });

            copy.EvaluationPeriods = mergedThreshold.EvaluationPeriods ?? alarm.EvaluationPeriods;

            copy.ExtendedStatistic = !string.IsNullOrEmpty(mergedThreshold.ExtendedStatistic)
                ? mergedThreshold.ExtendedStatistic
                : alarm.ExtendedStatistic;

            return(copy);
        }
        public void TestDefaultFlagsState()
        {
            var alarmDef = new AlarmDefinition();

            Assert.That(alarmDef.AlertOnInsufficientData, Is.False);
            Assert.That(alarmDef.AlertOnOk, Is.True);
        }
        public void TestFlagsCopy()
        {
            var original = new AlarmDefinition
            {
                AlertOnInsufficientData = true,
                AlertOnOk = false
            };

            var copy = original.Copy();

            Assert.That(copy.AlertOnInsufficientData, Is.True);
            Assert.That(copy.AlertOnOk, Is.False);
        }
        private static AlarmDefinition AlarmWithMergedValues(
            AlarmDefinition alarm,
            Dictionary <string, AlarmValues>[] thresholds)
        {
            var mergedThreshold = MergeValueOverrides(alarm.Name, thresholds);

            var copy = alarm.Copy();

            copy.Threshold = new Threshold
            {
                SourceAttribute = alarm.Threshold.SourceAttribute,
                ThresholdType   = alarm.Threshold.ThresholdType,
                Value           = mergedThreshold.Threshold ?? alarm.Threshold.Value
            };

            copy.EvaluationPeriods = mergedThreshold.EvaluationPeriods ?? alarm.EvaluationPeriods;

            return(copy);
        }