~andrewjbeach/juju-ci-tools/make-local-patcher

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
from __future__ import print_function

__metaclass__ = type

from argparse import ArgumentParser

from jujupy import (
    make_client,
)
from deploy_stack import (
    boot_context,
    prepare_environment,
)
from utility import (
    add_basic_testing_arguments
)


TEST_HUMAN_NAME="<YOUR TEST HUMAN READABLE HERE>"


def parse_args():
    """Parse all arguments."""
    parser = ArgumentParser(TEST_HUMAN_NAME)
    # Add your positional arguments
    add_basic_testing_arguments(parser)
    # Add your optional arguments.
    return parser.parse_args()


def main():
    args = parse_args()
    log_dir = args.logs

    client = make_client(
        args.juju_path, args.debug, args.env_name, args.temp_env_name)
    client.destroy_environment()
    series = args.series
    if series is None:
        series = 'precise'
    with boot_context(args.temp_env_name, client, args.bootstrap_host,
                      args.machine, series, args.agent_url, args.agent_stream,
                      log_dir, args.keep_env, args.upload_tools):
        prepare_environment(
            client, already_bootstrapped=True, machines=args.machine)

        client.get_status(60)
        # Deploy charms, there are several under ./repository
        client.juju("deploy", ('local:trusty/my-charm',))
        # Wait for the deployment to finish.
        client.wait_for_started()

        #----------------- CALL YOUR TESTS HERE
        # At this point you have a juju bootstraped with my-charm
        # deployed and active with the agent idle.
        #----------------- TESTS END HERE


if __name__ == '__main__':
    main()