def image(instance): click.echo( 'Warning: the `image` command is being deprecated, please use `make image` instead', err=True) with load_config() as c: validate_instance(instance, c) bc.make_image(instance, c[instance], True)
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 make_image(instance, wait): with load_config_v2() as c: validate_instance(instance, c) try: bc.make_image(instance, c[instance]['image'], wait) except bc.StateError as e: click.echo(e, err=True) raise click.Abort()
def make_image(instance, wait): with load_config() as c: validate_instance(instance, c) ec2 = ec2_connect() try: bc.make_image(ec2, instance, c[instance]['image'], wait) except bc.StateError as e: click.echo(e, err=True) raise click.Abort()
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_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)