diff options
author | Joshua Powers <josh.powers@canonical.com> | 2017-12-07 12:54:46 -0800 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2018-01-05 20:30:33 -0500 |
commit | 34595e9b4abacc10ac599aad97c95861af34ea54 (patch) | |
tree | 36461e98bad6e31737188a000c796d0ce73458c9 /tests/cloud_tests/collect.py | |
parent | 0b5bacb1761aefa74adb79bd1683d614bdf8c998 (diff) | |
download | vyos-cloud-init-34595e9b4abacc10ac599aad97c95861af34ea54.tar.gz vyos-cloud-init-34595e9b4abacc10ac599aad97c95861af34ea54.zip |
tests: Enable AWS EC2 Integration Testing
This enables integration tests to utilize AWS EC2 as a testing platform by
utilizing the boto3 Python library.
Usage will create and delete a custom VPC for every run. All resources
will be tagged with the ec2 tag, 'cii', and the date (e.g.
cii-20171220-102452). The VPC is setup with both IPv4 and IPv6
capabilities, but will only hand out IPv4 addresses by default. Instances
will have complete Internet access and have full ingress and egress access
(i.e. no firewall).
SSH keys are generated with each run of the integration tests with the key
getting uploaded to AWS at the start of tests and deleted on exit. To
enable creation when the platform is setup the SSH generation code is
moved to be completed by the platform setup and not during image setup.
The nocloud-kvm platform was updated with this change.
Creating a custom image will utilize the same clean script,
boot_clean_script, that the LXD platform uses as well. The custom AMI is
generated, used, and de-registered after a test run.
The default instance type is set to t2.micro. This is one of the smallest
instance types and is free tier eligible.
The default timeout for ec2 was increased to 300 from 120 as many tests
hit up against the 2 minute timeout and depending on region load can
go over.
Documentation for the AWS platform was added with the expected
configuration files for the platform to be used. There are some
additional whitespace changes included as well.
pylint exception was added for paramiko and simplestreams. In the past
these were not already flagged due to no __init__.py in the subdirectories
of files that used these. boto3 was added to the list of dependencies in
the tox ci-test runner.
In order to grab console logs on EC2 the harness will now shut down an
instance before terminating and before collecting the console log. This
is to address a behavior of EC2 where the console log is refreshed very
infrequently, but one point when it is refreshed is after shutdown.
Diffstat (limited to 'tests/cloud_tests/collect.py')
-rw-r--r-- | tests/cloud_tests/collect.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/cloud_tests/collect.py b/tests/cloud_tests/collect.py index bb722457..33acbb1e 100644 --- a/tests/cloud_tests/collect.py +++ b/tests/cloud_tests/collect.py @@ -28,12 +28,18 @@ def collect_script(instance, base_dir, script, script_name): def collect_console(instance, base_dir): - LOG.debug('getting console log') + """Collect instance console log. + + @param instance: instance to get console log for + @param base_dir: directory to write console log to + """ + logfile = os.path.join(base_dir, 'console.log') + LOG.debug('getting console log for %s to %s', instance, logfile) try: data = instance.console_log() except NotImplementedError: data = b'instance.console_log: not implemented' - with open(os.path.join(base_dir, 'console.log'), "wb") as fp: + with open(logfile, "wb") as fp: fp.write(data) @@ -89,12 +95,11 @@ def collect_test_data(args, snapshot, os_name, test_name): test_output_dir, script, script_name)) for script_name, script in test_scripts.items()] - console_log = partial( - run_single, 'collect console', - partial(collect_console, instance, test_output_dir)) - res = run_stage('collect for test: {}'.format(test_name), - [start_call] + collect_calls + [console_log]) + [start_call] + collect_calls) + + instance.shutdown() + collect_console(instance, test_output_dir) return res |