Module: Ey::Core::TestHelpers::AutoScalingHelpers

Included in:
Ey::Core::TestHelpers
Defined in:
lib/ey-core/test_helpers/auto_scaling_helpers.rb

Instance Method Summary collapse

Instance Method Details

#create_auto_scaling_group(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ey-core/test_helpers/auto_scaling_helpers.rb', line 5

def create_auto_scaling_group(options = {})
  environment = options[:environment] || create_environment

  groups = client.auto_scaling_groups

  groups.create!(
    minimum_size: 2,
    maximum_size: 6,
    environment: environment
  ).resource!
end

#create_auto_scaling_policy(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ey-core/test_helpers/auto_scaling_helpers.rb', line 17

def create_auto_scaling_policy(options = {})
  group = options.delete(:auto_scaling_group) || create_auto_scaling_group
  policies = client.auto_scaling_policies

  policies.create!(
    {
      auto_scaling_group_id: group.id,
      action_value: 2,
      action_unit: "instances",
      action_type: "add",
      name: SecureRandom.hex(16),
      type: "simple"
    }.merge(options)
  ).resource!
end