Sha256: 7f33283080efcfc9ce7d6f520dd9c49312536b295036128ca1eeb866e4205559

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'
require 'json'
require 'pp'

class TestUpdatePolicies < Minitest::Test
  def setup
    @template = ::Convection.template do
      description 'UpdatePolicies Test Template'

      ec2_security_group 'MyEC2SecGroup' do
        ingress_rule(:tcp, 80, 'my.ip.address')
      end

      auto_scaling_launch_configuration 'TestLaunchConfig' do
        image_id 'ami-123'
        instance_type 't2.nano'

        security_group fn_ref('MyEC2SecGroup')
      end

      auto_scaling_auto_scaling_group 'TestAutoScalingGroup' do
        launch_configuration_name fn_ref('TestLaunchConfig')

        update_policy do
          pause_time 'test_time'
          min_instances_in_service 10
          max_batch_size 2
        end
      end
    end
  end

  def from_json
    JSON.parse(@template.to_json)
  end

  def test_update_policy
    json = from_json['Resources']['TestAutoScalingGroup']
    type = json['Type']
    assert_equal 'AWS::AutoScaling::AutoScalingGroup', type

    update_policy = json['UpdatePolicy']
    refute update_policy.nil?, 'UpdatePolicy does not exist in the generated template'

    pause_time = json['UpdatePolicy']['AutoScalingRollingUpdate']['PauseTime']
    assert_equal 'test_time', pause_time

    min_in_service = json['UpdatePolicy']['AutoScalingRollingUpdate']['MinInstancesInService']
    assert_equal 10, min_in_service

    max_batch_size = json['UpdatePolicy']['AutoScalingRollingUpdate']['MaxBatchSize']
    assert_equal 2, max_batch_size
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
convection-0.2.32 test/convection/model/test_update_policies.rb
convection-0.2.31 test/convection/model/test_update_policies.rb
convection-0.2.30 test/convection/model/test_update_policies.rb
convection-0.2.29 test/convection/model/test_update_policies.rb
convection-0.2.28 test/convection/model/test_update_policies.rb
convection-0.2.27 test/convection/model/test_update_policies.rb
convection-0.2.26 test/convection/model/test_update_policies.rb
convection-0.2.25 test/convection/model/test_update_policies.rb
convection-0.2.24 test/convection/model/test_update_policies.rb
convection-0.2.23 test/convection/model/test_update_policies.rb
convection-0.2.22 test/convection/model/test_update_policies.rb