~canonical-platform-qa/ubuntu-system-tests/qemu-build-snap

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/systemtests/utils.py

  • Committer: Tarmac
  • Author(s): Heber Parrucci
  • Date: 2016-12-06 20:07:18 UTC
  • mfrom: (489.1.5 fix-import-issues)
  • Revision ID: tarmac-20161206200718-bmjos3hd3zfi5roj
fixing import errors.

Approved by Richard Huddie, platform-qa-bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
 
 
3
#
 
4
# Ubuntu System Tests
 
5
# Copyright (C) 2016 Canonical
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation, either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
 
 
21
import os
 
22
 
 
23
from ubuntu_system_tests.common import (
 
24
    config,
 
25
    ssh
 
26
)
 
27
 
 
28
DEFAULT_TEST_TIMEOUT = '1200'  # 20 minutes.
 
29
 
 
30
 
 
31
def get_artifacts_directory():
 
32
    """Returns path to the directory in which results should be written to."""
 
33
    return os.environ.get('ADT_ARTIFACTS')
 
34
 
 
35
 
 
36
def build_autopilot_command_list(config_stack):
 
37
    """Return a list containing the base autopilot command to run."""
 
38
    test_config_string = config.get_test_config_values(config_stack)
 
39
 
 
40
    return [
 
41
        'python3',
 
42
        '-m',
 
43
        'autopilot.run',
 
44
        'run',
 
45
        '-v',
 
46
        '-f',
 
47
        'subunit',
 
48
        '--config',
 
49
        test_config_string,
 
50
        '--test-timeout',
 
51
        DEFAULT_TEST_TIMEOUT
 
52
    ]
 
53
 
 
54
 
 
55
def append_subunit_results(destination_file_path, results_file_path):
 
56
    """Append the subunit results into another subunit file."""
 
57
    with open(destination_file_path, 'ab') as destination_file:
 
58
        with open(results_file_path, 'rb') as results_file:
 
59
            destination_file.write(results_file.read())
 
60
 
 
61
 
 
62
def ensure_keyfile_deleted():
 
63
    """Delete the keypair file after the tests are executed"""
 
64
    ssh.ensure_device_keyfile_deleted()