private async Task <bool> InspectExistingAlarm(string alarmName, double thresholdInUnits, int periodSeconds, string targetTopic) { var existingAlarm = await _alarmFinder.FindAlarmByName(alarmName); if (existingAlarm == null) { _logger.Info($"Table alarm {alarmName} does not already exist. Creating it at threshold {thresholdInUnits}"); return(true); } if (!MetricAlarmHelper.AlarmActionsEqualsTarget(existingAlarm.AlarmActions, targetTopic)) { _logger.Info($"Index alarm {alarmName} alarm target has changed to {targetTopic}"); return(true); } if (!MetricAlarmHelper.AlarmAndOkActionsAreEqual(existingAlarm)) { _logger.Info($"Index alarm {alarmName} alarm actions does not match ok actions"); return(true); } if (AlarmThresholds.AreEqual(existingAlarm.Threshold, thresholdInUnits) && (existingAlarm.Period == periodSeconds)) { _logger.Detail($"Table alarm {alarmName} already exists at same threshold {existingAlarm.Threshold}"); return(false); } LogDifferences(existingAlarm, alarmName, thresholdInUnits, periodSeconds); return(true); }
public async Task TestGet() { var alarm = await _finder.FindAlarmByName("no_such_alarm_1345345"); Assert.That(alarm, Is.Null); }