diff options
author | Scott Moser <smoser@brickies.net> | 2017-11-06 17:39:00 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-11-06 17:39:00 -0500 |
commit | 8622491c29f30862a1a1d7ad2cba023981acc8ce (patch) | |
tree | 597b08c4ca66575cc9567263030876814999beeb /tests/cloud_tests/collect.py | |
parent | be8e3d3c5b5d3d6a3d222383a58fd5feecead7b7 (diff) | |
download | vyos-cloud-init-8622491c29f30862a1a1d7ad2cba023981acc8ce.tar.gz vyos-cloud-init-8622491c29f30862a1a1d7ad2cba023981acc8ce.zip |
tests: integration test cleanup and full pass of nocloud-kvm.
Integration test harness changes:
* Enable collection of console log in nocloud-kvm and lxd.
* Collect the console log to results for all test runs.
* change 'tmpfile' to pick name locally instead of using 'mktemp'.
* drop the 'instance' attribute from nocloud-kvm Image and
demote LXDImage.instance to a private attribute.
This is because Images do not actually have instances.
(LXDImage internally uses a booted system to modify the image).
* Add 'TargetBase' as a superclass of Image and Instance providing
implementations of execute, read_data, write_data, pull_file,
and push_file. These all depend on an implementation of _execute.
* Improve '_execute' implementations to support accepting stdin.
* execute supports 'rcs=False' meaning 'do not raise exception'.
* Drop support for pylxd < 2.2. older versions cannot determine
exit code of 'execute', which makes them unusable.
* make NoCloudKVMInstance._execute run as root via sudo. This required
some changes so that 'hostname' could be reverse-looked up in order
to avoid sudo taking a long time (~20 seconds).
* re-use existing ssh connection in nocloud-kvm.
Test changes here:
* do not use /tmp, but rather /var/tmp (LP: #1707222)
* make keys_to_console assertions more strict.
* change user test cases to always add default (ubuntu) user
so that nocloud-kvm's execute which operates over ssh can work.
Diffstat (limited to 'tests/cloud_tests/collect.py')
-rw-r--r-- | tests/cloud_tests/collect.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/cloud_tests/collect.py b/tests/cloud_tests/collect.py index 4a2422ed..71ee7645 100644 --- a/tests/cloud_tests/collect.py +++ b/tests/cloud_tests/collect.py @@ -22,11 +22,21 @@ def collect_script(instance, base_dir, script, script_name): """ LOG.debug('running collect script: %s', script_name) (out, err, exit) = instance.run_script( - script, rcs=range(0, 256), + script.encode(), rcs=False, description='collect: {}'.format(script_name)) c_util.write_file(os.path.join(base_dir, script_name), out) +def collect_console(instance, base_dir): + LOG.debug('getting console log') + try: + data = instance.console_log() + except NotImplementedError as e: + data = 'Not Implemented: %s' % e + with open(os.path.join(base_dir, 'console.log'), "wb") as fp: + fp.write(data) + + def collect_test_data(args, snapshot, os_name, test_name): """Collect data for test case. @@ -79,8 +89,12 @@ 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) + [start_call] + collect_calls + [console_log]) return res |