radiosonde 0.2.0.beta4 → 0.2.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9fda9a1b6e2f65e201b9d33e0aed658cfe30364
4
- data.tar.gz: 6e3d4f627e6cfe3aa2be50bf3b7d5a1bcc3818de
3
+ metadata.gz: 3a6485caa6d34043676f7aec30ed84d91de507d6
4
+ data.tar.gz: aa93b69e11a8ac9fd2bd0228c2566efaccb625ea
5
5
  SHA512:
6
- metadata.gz: f160b2367a722e16aee1c76266c61bcb3ccc5ee536c35b2f1852c2a71980a22621fa0d3c7f58df4669695ad1c03b437b47a102bf3d49e9727120c6184586340e
7
- data.tar.gz: 77fd7ba591210360e71b5aee898cec9758db010058552161608d1ba7bb7bd2e622beca8bd436ea7eab2c3b1c0a13a9882586faedee45f21eb10b34333d241d9e
6
+ metadata.gz: f80f61477edc138fbe3d533e8857bd8d432d09a3f32d9ad51bb1b4c390af4aa3bba604900593bda3183ea3ce5c04d5451104d91c4a43fd66d2a5de60664fa10a
7
+ data.tar.gz: faf13058e6d0310f7c423ed5e403d045bc65b95164d576387a60689af1ece33e789ff4142cf23dcb83968da77149e3891da746bb1e26f6cff27ddb6c5b41638a
@@ -91,6 +91,11 @@ class Radiosonde::DSL::Context::Alarm
91
91
  @result.evaluation_periods = value.to_i
92
92
  end
93
93
 
94
+ def datapoints_to_alarm(value)
95
+ _call_once(:datapoints_to_alarm)
96
+ @result.datapoints_to_alarm = value.to_i
97
+ end
98
+
94
99
  def unit(value)
95
100
  _call_once(:unit)
96
101
  _validate("Invalid value: #{value}") do
@@ -33,6 +33,7 @@ class Radiosonde::DSL::Converter
33
33
  statistic = Radiosonde::DSL::Statistic.conv_to_alias(attrs[:statistic]).inspect
34
34
  threshold = format_threshold(attrs)
35
35
  evaluation_periods = attrs[:evaluation_periods].inspect
36
+ datapoints_to_alarm = attrs[:datapoints_to_alarm].inspect
36
37
  actions_enabled = attrs[:actions_enabled].inspect
37
38
  alarm_actions = attrs[:alarm_actions].inspect
38
39
  ok_actions = attrs[:ok_actions].inspect
@@ -40,7 +41,7 @@ class Radiosonde::DSL::Converter
40
41
 
41
42
  if unit = attrs[:unit]
42
43
  unit = Radiosonde::DSL::Unit.conv_to_alias(unit).inspect
43
- unit = "unit #{unit}\n"
44
+ unit = "unit #{unit}\n "
44
45
  end
45
46
 
46
47
  if treat_missing_data = attrs[:treat_missing_data]
@@ -59,6 +60,7 @@ alarm #{name} do
59
60
  threshold #{threshold}
60
61
  #{treat_missing_data
61
62
  }evaluation_periods #{evaluation_periods}
63
+ datapoints_to_alarm #{datapoints_to_alarm}
62
64
  #{unit
63
65
  }actions_enabled #{actions_enabled}
64
66
  alarm_actions #{alarm_actions}
@@ -39,6 +39,7 @@ class Radiosonde::Exporter
39
39
  :threshold => alarm.threshold,
40
40
  :comparison_operator => alarm.comparison_operator,
41
41
  :evaluation_periods => alarm.evaluation_periods,
42
+ :datapoints_to_alarm => alarm.datapoints_to_alarm,
42
43
  :actions_enabled => alarm.actions_enabled,
43
44
  :alarm_actions => alarm.alarm_actions,
44
45
  :ok_actions => alarm.ok_actions,
@@ -1,3 +1,3 @@
1
1
  module Radiosonde
2
- VERSION = '0.2.0.beta4'
2
+ VERSION = '0.2.0.beta5'
3
3
  end
@@ -12,6 +12,7 @@ class Radiosonde::Wrapper::Alarm
12
12
  :threshold,
13
13
  :comparison_operator,
14
14
  :evaluation_periods,
15
+ :datapoints_to_alarm,
15
16
  :actions_enabled,
16
17
  :unit,
17
18
  :alarm_actions,
@@ -1,5 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'pp'
3
+
1
4
  describe Radiosonde do
2
- it do
3
- expect(1).to eq(1)
5
+ it 'has a version number' do
6
+ expect(Radiosonde::VERSION).not_to be nil
4
7
  end
5
- end
8
+ end
9
+
10
+ describe Radiosonde::Client do
11
+ end
12
+
13
+ describe Radiosonde::Exporter do
14
+ let(:cloudwatch_client) { Aws::CloudWatch::Client.new }
15
+
16
+ it 'has datapoints_to_alarm' do
17
+ exporter = Radiosonde::Exporter.new(cloudwatch_client, {})
18
+ actual = exporter.export['my-cloudwatch-alarm'][:datapoints_to_alarm]
19
+ expect(actual).to eq(1)
20
+ end
21
+ end
22
+
23
+ describe Radiosonde::DSL::Converter do
24
+ let(:cloudwatch_client) { Aws::CloudWatch::Client.new }
25
+ let(:exporter) { Radiosonde::Exporter.new(cloudwatch_client, {})}
26
+
27
+ it 'convert dsl' do
28
+ dsl = <<-'EOF'
29
+ alarm "my-cloudwatch-alarm" do
30
+ description "my_NumberOfProcesses"
31
+ namespace "my-cloudwatch-namespace"
32
+ metric_name "NumberOfProcesses"
33
+ dimensions "name"=>"my-dimension"
34
+ period 300
35
+ statistic :average
36
+ threshold "<=", 5.0
37
+ treat_missing_data :not_breaching
38
+ evaluation_periods 1
39
+ datapoints_to_alarm 1
40
+ unit :seconds
41
+ actions_enabled true
42
+ alarm_actions ["arn:aws:sns:ap-northeast-1:1234567890:sns_alert"]
43
+ ok_actions ["arn:aws:sns:ap-northeast-1:1234567890:sns_alert"]
44
+ insufficient_data_actions ["arn:aws:sns:ap-northeast-1:1234567890:sns_alert"]
45
+ end
46
+ EOF
47
+ exported = exporter.export
48
+ converter = Radiosonde::DSL::Converter.new(exported, {})
49
+ actual = converter.convert
50
+ expect(actual).to eq(dsl)
51
+ end
52
+ end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,49 @@
1
1
  require 'radiosonde'
2
+
3
+ Aws.config.update({
4
+ region: 'us-east-1',
5
+ credentials: Aws::Credentials.new(
6
+ 'akid',
7
+ 'secret')
8
+ })
9
+
10
+ Aws.config[:cloudwatch] = {
11
+ stub_responses: {
12
+ describe_alarms: {
13
+ metric_alarms: [
14
+ {
15
+ alarm_name: 'my-cloudwatch-alarm',
16
+ alarm_arn: 'arn:aws:cloudwatch:ap-northeast-1:1234567890:alarm:my_NumberOfProcesses',
17
+ alarm_description: 'my_NumberOfProcesses',
18
+ alarm_configuration_updated_timestamp: Time.new(2015, 1, 2, 10, 00, 00, '+00:00'),
19
+ actions_enabled: true,
20
+ ok_actions: ['arn:aws:sns:ap-northeast-1:1234567890:sns_alert'],
21
+ alarm_actions: ['arn:aws:sns:ap-northeast-1:1234567890:sns_alert'],
22
+ insufficient_data_actions: ['arn:aws:sns:ap-northeast-1:1234567890:sns_alert'],
23
+ state_value: 'OK',
24
+ state_reason: 'Threshold Crossed: 1 datapoint (53.0) was not less than or equal to the threshold (5.0).',
25
+ state_reason_data:
26
+ '{\'version\':\'1.0\',\'queryDate\':\'2015-04-04T01:06:26.904+0000\',\'startDate\':\'2015-04-04T01:01:00.000+0000\',\'statistic\':\'Average\',\'period\':300,\'recentDatapoints\':[53.0],\'threshold\':5.0}',
27
+ state_updated_timestamp: Time.new(2015, 1, 2, 10, 10, 00, '+00:00'),
28
+ metric_name: 'NumberOfProcesses',
29
+ namespace: 'my-cloudwatch-namespace',
30
+ statistic: 'Average',
31
+ dimensions:
32
+ [
33
+ {
34
+ name: 'name',
35
+ value: 'my-dimension'
36
+ }
37
+ ],
38
+ period: 300,
39
+ unit: 'Seconds',
40
+ evaluation_periods: 1,
41
+ datapoints_to_alarm: 1,
42
+ threshold: 5.0,
43
+ treat_missing_data: 'notBreaching',
44
+ comparison_operator: 'LessThanOrEqualToThreshold'
45
+ }
46
+ ]
47
+ }
48
+ }
49
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiosonde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta4
4
+ version: 0.2.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
11
+ date: 2018-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudwatch
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  version: 1.3.1
184
184
  requirements: []
185
185
  rubyforge_project:
186
- rubygems_version: 2.5.2
186
+ rubygems_version: 2.6.13
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: Radiosonde is a tool to manage CloudWatch Alarm.