コード例 #1
0
def main():
    triggerer = base_test_triggerer.BaseTestTriggerer()
    args, additional_args = parse_args(triggerer)

    current_lkgm = read_current_lkgm()
    if not current_lkgm:
        return 1

    new_args = additional_args[:1]
    # Insert our modified dimension args in between the 1st and 2nd args of the
    # initial `swarming.py` invocation. This avoids the presence of the special
    # `--` arg from causing swarming.py to ignore them.
    needs_device_status = True
    for k, v in args.dimensions:
        new_args.extend(['--dimension', k, v])
        if k == 'device_status':
            needs_device_status = False

    # Only CrOS device bots with a device_status dimension of "available" should
    # run tests. So target those explicitly if we aren't already.
    if needs_device_status:
        new_args.extend(['--dimension', 'device_status', 'available'])

    new_args.extend([
        '--optional-dimension',
        'device_os',
        current_lkgm,
        str(args.primary_expiration),
    ])
    new_args += additional_args[1:]

    return triggerer.run_swarming(new_args, True)
コード例 #2
0
 def test_list_bots(self):
     # This just checks list_bots runs without error.
     triggerer = base_test_triggerer.BaseTestTriggerer()
     with fake_filesystem_unittest.Pause(self):
         tasks = triggerer.list_tasks(('pool:luci.flex.ci', ), limit=1)
     self.assertGreater(len(tasks), 0)
     task = tasks[0]
     self.assertIn('task_id', task)
コード例 #3
0
 def test_list_bots(self):
     # This just checks list_bots runs without error.
     triggerer = base_test_triggerer.BaseTestTriggerer()
     with fake_filesystem_unittest.Pause(self):
         bots = triggerer.list_bots({'pool': 'luci.flex.ci'}, True)
     self.assertGreater(len(bots), 0)
     bot = bots[0]
     self.assertIn('bot_id', bot)
コード例 #4
0
    def test_trigger_tasks(self):
        parser = base_test_triggerer.BaseTestTriggerer.setup_parser_contract(
            argparse.ArgumentParser())
        dump_json = 'dump.json'
        args, remaining = parser.parse_known_args([
            '--multiple-dimension-script-verbose', 'True', 'trigger',
            '--shards', '1', '--dump-json', dump_json
        ])
        triggerer = base_test_triggerer.BaseTestTriggerer()

        def mock_subprocess_call(args):
            # write json file generated by 'swarming trigger' command.
            json_path = args[args.index('--dump-json') + 1]
            with open(json_path, 'w') as f:
                f.write(
                    json.dumps({
                        'tasks': [{
                            'request': {
                                'task_id': 'f0',
                            },
                            'task_result': {
                                'resultdb_info': {
                                    'invocation': 'task-f0',
                                },
                            },
                        }],
                    }))

        # make some not important functions nop.
        with mock.patch.object(triggerer,
                               'parse_bot_configs'), mock.patch.object(
                                   triggerer, '_bot_configs',
                                   []), mock.patch.object(
                                       triggerer,
                                       'select_config_indices',
                                       return_value=[(0, 0)]), mock.patch(
                                           'subprocess.call',
                                           side_effect=mock_subprocess_call):
            triggerer.trigger_tasks(args, remaining)

        with open(dump_json) as f:
            self.assertEqual(
                json.load(f), {
                    u'tasks': {
                        u'f0:0:1': {
                            u'shard_index': 0,
                            u'task_id': u'f0',
                            u'invocation': u'task-f0',
                        }
                    }
                })
コード例 #5
0
def main():
    args, additional_args = parse_args()

    current_lkgm = read_current_lkgm()
    if not current_lkgm:
        return 1

    new_args = additional_args[:1]
    # Insert our modified dimension args in between the 1st and 2nd args of the
    # initial `swarming.py` invocation. This avoids the presence of the special
    # `--` arg from causing swarming.py to ignore them.
    for k, v in args.dimensions:
        new_args.extend(['--dimension', k, v])
    new_args.extend([
        '--optional-dimension',
        'device_os',
        current_lkgm,
        str(args.primary_expiration),
    ])
    new_args += additional_args[1:]

    return base_test_triggerer.BaseTestTriggerer().run_swarming(new_args, True)