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_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_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)
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)
def make_build(instance, verbosity): with load_config() as c: validate_instance(instance, c) ec2 = ec2_connect() sys.exit(bc.make_build(ec2, instance, c[instance]['build'], verbosity))
def make_build(instance, verbosity): with load_config() as c: validate_instance(instance, c) ec2 = ec2_connect() sys.exit(bc.make_build(ec2, instance, c[instance]['build'], verbosity))
def make_build(instance, verbosity): with load_config_v2() as c: validate_instance(instance, c) sys.exit(bc.make_build(instance, c[instance]['build'], verbosity))