lin
2025-08-14 dae8bad597b6607a449b32bf76c523423f7720ed
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
 
"""
The job module contains the objects and methods used to
manage jobs in Autotest.
 
The valid actions are:
list:    lists job(s)
create:  create a job
abort:   abort job(s)
stat:    detailed listing of job(s)
 
The common options are:
 
See topic_common.py for a High Level Design and Algorithm.
"""
 
import warnings
 
from autotest_lib.cli import topic_common, action_common
 
 
class suite(topic_common.atest):
    """Suite class
    atest suite [create] [options]"""
    usage_action = '[create]'
    topic = msg_topic = 'suite'
    msg_items = ''
 
 
class suite_help(suite):
    """Just here to get the atest logic working.
    Usage is set by its parent"""
    pass
 
 
class suite_create(action_common.atest_create, suite):
    """Class containing the code for creating a suite."""
    msg_items = 'suite_id'
 
    def __init__(self):
        super(suite_create, self).__init__()
 
        self.parser.add_option('-b', '--board', help='Board to test. Required.',
                               metavar='BOARD')
        self.parser.add_option('-i', '--build',
                               help='OS image to install before running the '
                                    'test, e.g. '
                                    'x86-alex-release/R17-1412.144.0-a1-b115.'
                                    ' Required.',
                               metavar='BUILD')
        self.parser.add_option('-c', '--check_hosts',
                               default=False,
                               help='Check that enough live hosts exist to '\
                                    'run this suite. Default False.',
                               action='store_true',
                               metavar='CHECK_HOSTS')
        self.parser.add_option('-f', '--file_bugs', default=False,
                               help='File bugs on test failures.',
                               action='store_true', metavar='FILE_BUGS')
        self.parser.add_option('-n', '--num', type=int,
                               help='Number of machines to schedule across.',
                               metavar='NUM')
        self.parser.add_option('-p', '--pool', help='Pool of machines to use.',
                               metavar='POOL')
        self.parser.add_option('-w', '--wait_for_results',
                               default=True,
                               help=('Set to False for suite job to exit '
                                     'without waiting for test jobs to finish. '
                                     'Default is True.'),
                               metavar='WAIT_FOR_RESULTS')
        self.parser.add_option('-d', '--delay_minutes', type=int, default=0,
                               help=('Delay the creation of test jobs for a '
                                     'given number of minutes. This argument '
                                     'can be used to force provision jobs '
                                     'being delayed, which helps to distribute '
                                     'loads across devservers.'),
                               metavar='DELAY_MINUTES')
 
 
    def parse(self):
        board_info = topic_common.item_parse_info(attribute_name='board',
                                                  inline_option='board')
        build_info = topic_common.item_parse_info(attribute_name='build',
                                                  inline_option='build')
        pool_info = topic_common.item_parse_info(attribute_name='pool',
                                                 inline_option='pool')
        num_info = topic_common.item_parse_info(attribute_name='num',
                                                inline_option='num')
        check_info = topic_common.item_parse_info(attribute_name='check_hosts',
                                                  inline_option='check_hosts')
        bugs_info = topic_common.item_parse_info(attribute_name='file_bugs',
                                                 inline_option='file_bugs')
        suite_info = topic_common.item_parse_info(attribute_name='name',
                                                  use_leftover=True)
        wait_for_results_info = topic_common.item_parse_info(
                attribute_name='wait_for_results',
                inline_option='wait_for_results')
        delay_minutes_info = topic_common.item_parse_info(
                attribute_name='delay_minutes',
                inline_option='delay_minutes')
 
        options, leftover = suite.parse(
            self,
            [suite_info, board_info, build_info, pool_info, num_info,
             check_info, bugs_info, wait_for_results_info, delay_minutes_info],
            req_items='name')
        self.data = {}
        name = getattr(self, 'name')
        if len(name) > 1:
            self.invalid_syntax('Too many arguments specified, only expected '
                                'to receive suite name: %s' % name)
        self.data['suite_name'] = name[0]
        self.data['pool'] = options.pool  # None is OK.
        if options.num is not None:
            warnings.warn('num is deprecated')
        del options.num
        self.data['check_hosts'] = options.check_hosts
        self.data['file_bugs'] = options.file_bugs
        self.data['wait_for_results'] = options.wait_for_results
        self.data['delay_minutes'] = options.delay_minutes
        if options.board:
            self.data['board'] = options.board
        else:
            self.invalid_syntax('--board is required.')
        if options.build:
            self.data['build'] = options.build
        else:
            self.invalid_syntax('--build is required.')
 
        return options, leftover
 
 
    def execute(self):
        return [self.execute_rpc(op='create_suite_job', **self.data)]