Exemplo n.º 1
0
    def testGetSwarmingTaskRequestTemplate(self):
        expected_request = SwarmingTaskRequest(
            created_ts=None,
            expiration_secs='3600',
            name='',
            parent_task_id='',
            priority='150',
            properties=SwarmingTaskProperties(caches=[],
                                              command=None,
                                              dimensions=[],
                                              env=[],
                                              env_prefixes=[],
                                              execution_timeout_secs='3600',
                                              extra_args=ListOfBasestring(),
                                              grace_period_secs='30',
                                              io_timeout_secs='1200',
                                              idempotent=True,
                                              inputs_ref=SwarmingTaskInputsRef(
                                                  isolated=None,
                                                  isolatedserver=None,
                                                  namespace=None)),
            pubsub_auth_token=None,
            pubsub_topic=None,
            pubsub_userdata=None,
            service_account=None,
            tags=ListOfBasestring(),
            user='')

        self.assertEqual(expected_request,
                         SwarmingTaskRequest.GetSwarmingTaskRequestTemplate())
Exemplo n.º 2
0
    def testCreateNewSwarmingTaskRequest(self, mocked_template):
        mocked_template.return_value = SwarmingTaskRequest.FromSerializable(
            _SAMPLE_REQUEST_JSON)

        runner_id = 'pipeline_id'
        ref_task_id = 'ref_task_id'
        ref_request = SwarmingTaskRequest.GetSwarmingTaskRequestTemplate()
        master_name = 'm'
        builder_name = 'b'
        step_name = 's'
        test_name = 't'
        iterations = 50
        timeout_seconds = 3600
        isolate_sha = 'sha1'

        expected_request = SwarmingTaskRequest(
            created_ts=None,
            name='findit/ref_task_id/ref_task_id/2018-03-15 00:00:00 000000',
            tags=ListOfBasestring.FromSerializable([
                'ref_master:m',
                'ref_buildername:b',
                'ref_buildnumber:4',
                'ref_stepname:s',
                'ref_name:test',
                'purpose:identify-regression-range',
            ]),
            pubsub_topic='projects/app-id/topics/swarming',
            properties=SwarmingTaskProperties(
                dimensions=[{
                    'value': 'v',
                    'key': 'k'
                }],
                idempotent=False,
                inputs_ref=SwarmingTaskInputsRef(
                    isolatedserver='isolatedserver',
                    namespace=None,
                    isolated='sha1'),
                extra_args=ListOfBasestring.FromSerializable([
                    '--flag=value', '--gtest_filter=a.b:a.c',
                    '--gtest_repeat=50', '--test-launcher-retry-limit=0',
                    '--gtest_also_run_disabled_tests'
                ]),
                io_timeout_secs='1200',
                command='cmd',
                env=[{
                    'value': '1',
                    'key': 'a'
                }],
                execution_timeout_secs='3600',
                env_prefixes=[],
                grace_period_secs='30',
                caches=None,
                cipd_input=swarming_task_request.CIPDInput(
                    packages=swarming_task_request.CIPDPackages(),
                    client_package=swarming_task_request.CIPDClientPackage(
                        version=None,
                        package_name=None,
                    ),
                    server=None)),
            priority='25',
            parent_task_id='',
            user='',
            service_account=None,
            pubsub_userdata='{"runner_id": "runner_id"}',
            expiration_secs='3600',
            pubsub_auth_token='auth_token')

        self.assertEqual(
            expected_request,
            flake_swarming.CreateNewSwarmingTaskRequest(
                runner_id, ref_task_id, ref_request, master_name, builder_name,
                step_name, test_name, isolate_sha, iterations,
                timeout_seconds))