def test_make_test(): config = bc.load_config('tests/resources/boss.yml') instance = 'amz-2015092-default' ec2 = ec2_connect() with assert_raises(bc.StateError) as r: bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal( r.exception.message, 'Cannot run `make test` before `make image`' ) bc.make_build(ec2, instance, config[instance]['build'], 1) # Should get another StateError because `make image` has not been run with assert_raises(bc.StateError) as r: bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal( r.exception.message, 'Cannot run `make test` before `make image`' ) bc.make_image(ec2, instance, config[instance]['image'], True) reset_probes(['create_instance', 'run_ansible']) bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(probe.called, ['create_instance', 'run_ansible']) # As with `build`, a second run should create no new resources reset_probes(['create_instance', 'run_ansible']) bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(probe.called, ['run_ansible']) for f in bc.instance_files(instance).values(): os.unlink(f)
def test_make_test(): config = bc.load_config('tests/resources/boss.yml') instance = 'amz-2015092-default' ec2 = ec2_connect() with assert_raises(bc.StateError) as r: bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(r.exception.message, 'Cannot run `make test` before `make image`') bc.make_build(ec2, instance, config[instance]['build'], 1) # Should get another StateError because `make image` has not been run with assert_raises(bc.StateError) as r: bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(r.exception.message, 'Cannot run `make test` before `make image`') bc.make_image(ec2, instance, config[instance]['image'], True) reset_probes(['create_instance', 'run_ansible']) bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(probe.called, ['create_instance', 'run_ansible']) # As with `build`, a second run should create no new resources reset_probes(['create_instance', 'run_ansible']) bc.make_test(ec2, instance, config[instance]['test'], 1) assert_equal(probe.called, ['run_ansible']) for f in bc.instance_files(instance).values(): os.unlink(f)
def test_make_build(): config = bc.load_config_v2('tests/resources/boss-v2.yml') instance = 'amz-2015092-default' reset_probes(['create_keypair', 'create_instance_v2', 'write_playbook', 'run_ansible']) bc.make_build(instance, config[instance]['build'], 1) assert_equal(probe.called, ['create_keypair', 'create_instance_v2', 'write_playbook', 'run_ansible']) # Ensure that a second run only runs ansible without creating new resources reset_probes(['create_keypair', 'create_instance_v2', 'write_playbook', 'run_ansible']) bc.make_build(instance, config[instance]['build'], 1) assert_equal(probe.called, ['run_ansible'])
def test_create_instance_tags(): config = bc.load_config_v2('tests/resources/boss-v2.yml') # win-2012r2 config has no tags reset_probes(['create_instances', 'create_tags']) bc.create_instance_v2(config['win-2012r2-default']['build'], 'ami-00000000', 'mykey') assert_equal(probe.called, ['create_instances']) # amz-2015092 config has tags reset_probes(['create_instances', 'create_tags']) bc.create_instance_v2(config['amz-2015092-default']['build'], 'ami-00000000', 'mykey') assert_equal(probe.called, ['create_instances', 'create_tags'])
def test_make_image_no_wait(): config = bc.load_config_v2('tests/resources/boss-v2.yml') instance = 'amz-2015092-default' wait = False bc.make_build(instance, config[instance]['build'], 1) reset_probes(['ec2_connect', 'wait_for_image']) bc.make_image(instance, config[instance]['image'], wait) assert_equal(probe.called, ['ec2_connect']) reset_probes(['ec2_connect', 'wait_for_image']) bc.make_image(instance, config[instance]['image'], wait) assert_equal(probe.called, [])
def test_make_image_no_wait(): config = bc.load_config('tests/resources/boss.yml') instance = 'amz-2015092-default' ec2 = ec2_connect() wait = False bc.make_build(ec2, instance, config[instance]['build'], 1) reset_probes(['wait_for_image']) bc.make_image(ec2, instance, config[instance]['image'], wait) assert_equal(probe.called, []) reset_probes(['wait_for_image']) bc.make_image(ec2, instance, config[instance]['image'], wait) assert_equal(probe.called, [])
def test_create_instance_tags(): config = bc.load_config('tests/resources/boss.yml') ec2 = ec2_connect() # win-2012r2 config has no tags reset_probes(['create_instances', 'create_tags']) bc.create_instance( ec2, config['win-2012r2-default']['build'], 'ami-00000000', 'mykey' ) assert_equal(probe.called, ['create_instances']) # amz-2015092 config has tags reset_probes(['create_instances', 'create_tags']) bc.create_instance( ec2, config['amz-2015092-default']['build'], 'ami-00000000', 'mykey' ) assert_equal(probe.called, ['create_instances', 'create_tags'])
def test_make_build(): config = bc.load_config('tests/resources/boss.yml') instance = 'amz-2015092-default' ec2 = ec2_connect() reset_probes([ 'create_keypair', 'create_instance', 'write_playbook', 'run_ansible' ]) bc.make_build(ec2, instance, config[instance]['build'], 1) assert_equal(probe.called, [ 'create_keypair', 'create_instance', 'write_playbook', 'run_ansible' ]) # Ensure that a second run only runs ansible without creating new resources reset_probes([ 'create_keypair', 'create_instance', 'write_playbook', 'run_ansible' ]) bc.make_build(ec2, instance, config[instance]['build'], 1) assert_equal(probe.called, ['run_ansible'])
def test_make_image_wait(): config = bc.load_config('tests/resources/boss.yml') instance = 'amz-2015092-default' ec2 = ec2_connect() wait = True bc.make_build(ec2, instance, config[instance]['build'], 1) reset_probes(['wait_for_image']) bc.make_image(ec2, instance, config[instance]['image'], wait) assert_equal(probe.called, ['wait_for_image']) reset_probes(['wait_for_image']) bc.make_image(ec2, instance, config[instance]['image'], wait) assert_equal(probe.called, []) wait = False reset_probes(['wait_for_image']) bc.make_image(ec2, instance, config[instance]['image'], wait) assert_equal(probe.called, []) for f in bc.instance_files(instance).values(): os.unlink(f)