Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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()
Example #5
0
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()
Example #6
0
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, [])
Example #7
0
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, [])
Example #8
0
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)
Example #9
0
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)