Ejemplo n.º 1
0
    def test_compute_test_config_status_scheduled(self):
        self._setup_active_plan()
        self._planner_job.delete()

        self.assertEqual(
                rpc_utils.compute_test_config_status(self._planner_host),
                rpc_utils.ComputeTestConfigStatusResult.SCHEDULED)
Ejemplo n.º 2
0
    def test_compute_test_config_status_running(self):
        self._setup_active_plan()
        self.god.stub_function(models.Job, 'active')
        models.Job.active.expect_call().and_return(True)

        self.assertEqual(
                rpc_utils.compute_test_config_status(self._planner_host),
                rpc_utils.ComputeTestConfigStatusResult.RUNNING)
        self.god.check_playback()
Ejemplo n.º 3
0
def get_test_view_data(plan_id):
    """
    Gets the data for the Test View tab

    @param plan_id: The name or ID of the test plan
    @return A dictionary - Keys are test config aliases, values are dictionaries
                           of data:
                total_machines: Total number of machines scheduled for this test
                                config. Excludes machines that are set to skip
                                this config.
                machine_status: A dictionary:
                    key: The hostname
                    value: The status of the machine: one of 'Scheduled',
                           'Running', 'Pass', or 'Fail'
                total_runs: Total number of runs of this test config. Includes
                            repeated runs (from triage re-run)
                total_passes: Number of runs that resulted in a 'pass', meaning
                              that none of the tests in the test config had any
                              status other than GOOD.
                bugs: List of bugs that were filed under this test config
    """
    plan = models.Plan.smart_get(plan_id)
    result = {}
    for test_config in plan.testconfig_set.all():
        skipped_host_ids = test_config.skipped_hosts.values_list('id',
                                                                 flat=True)
        hosts = plan.host_set.exclude(host__id__in=skipped_host_ids)
        total_machines = hosts.count()

        machine_status = {}
        for host in hosts:
            machine_status[host.host.hostname] = (
                rpc_utils.compute_test_config_status(host, test_config))

        planner_jobs = test_config.job_set.all()
        total_runs = planner_jobs.count()
        total_passes = 0
        for planner_job in planner_jobs:
            if planner_job.all_tests_passed():
                total_passes += 1

        test_runs = plan.testrun_set.filter(
            test_job__in=test_config.job_set.all())
        bugs = set()
        for test_run in test_runs:
            bugs.update(test_run.bugs.values_list('external_uid', flat=True))

        result[test_config.alias] = {
            'total_machines': total_machines,
            'machine_status': machine_status,
            'total_runs': total_runs,
            'total_passes': total_passes,
            'bugs': list(bugs)
        }
    return result
Ejemplo n.º 4
0
def get_test_view_data(plan_id):
    """
    Gets the data for the Test View tab

    @param plan_id: The name or ID of the test plan
    @return A dictionary - Keys are test config aliases, values are dictionaries
                           of data:
                total_machines: Total number of machines scheduled for this test
                                config. Excludes machines that are set to skip
                                this config.
                machine_status: A dictionary:
                    key: The hostname
                    value: The status of the machine: one of 'Scheduled',
                           'Running', 'Pass', or 'Fail'
                total_runs: Total number of runs of this test config. Includes
                            repeated runs (from triage re-run)
                total_passes: Number of runs that resulted in a 'pass', meaning
                              that none of the tests in the test config had any
                              status other than GOOD.
                bugs: List of bugs that were filed under this test config
    """
    plan = models.Plan.smart_get(plan_id)
    result = {}
    for test_config in plan.testconfig_set.all():
        skipped_host_ids = test_config.skipped_hosts.values_list('id',
                                                                 flat=True)
        hosts = plan.host_set.exclude(host__id__in=skipped_host_ids)
        total_machines = hosts.count()

        machine_status = {}
        for host in hosts:
            machine_status[host.host.hostname] = (
                    rpc_utils.compute_test_config_status(host, test_config))

        planner_jobs = test_config.job_set.all()
        total_runs = planner_jobs.count()
        total_passes = 0
        for planner_job in planner_jobs:
            if planner_job.all_tests_passed():
                total_passes += 1

        test_runs = plan.testrun_set.filter(
                test_job__in=test_config.job_set.all())
        bugs = set()
        for test_run in test_runs:
            bugs.update(test_run.bugs.values_list('external_uid', flat=True))

        result[test_config.alias] = {'total_machines': total_machines,
                                     'machine_status': machine_status,
                                     'total_runs': total_runs,
                                     'total_passes': total_passes,
                                     'bugs': list(bugs)}
    return result
Ejemplo n.º 5
0
    def test_compute_test_config_status_bad(self):
        self._setup_active_plan()
        tko_test = self._tko_job.test_set.create(kernel=self._tko_kernel,
                                                 status=self._fail_status,
                                                 machine=self._tko_machine)
        self._plan.testrun_set.create(test_job=self._planner_job,
                                      tko_test=tko_test,
                                      host=self._planner_host)
        self._planner_host.complete = True
        self._planner_host.save()
        self.god.stub_function(models.Job, 'active')
        models.Job.active.expect_call().and_return(False)

        self.assertEqual(
                rpc_utils.compute_test_config_status(self._planner_host),
                rpc_utils.ComputeTestConfigStatusResult.FAIL)
        self.god.check_playback()
Ejemplo n.º 6
0
def get_overview_data(plan_ids):
    """
    Gets the data for the Overview tab

    @param plan_ids: A list of the plans, by id or name
    @return A dictionary - keys are plan names, values are dictionaries of data:
                machines: A list of dictionaries:
                hostname: The machine's hostname
                status: The host's status
                passed: True if the machine passed the test plan. A 'pass' means
                        that, for every test configuration in the plan, the
                        machine had at least one AFE job with no failed tests.
                        'passed' could also be None, meaning that this host is
                        still running tests.
                bugs: A list of the bugs filed
                test_configs: A list of dictionaries, each representing a test
                              config:
                    complete: Number of hosts that have completed this test
                              config
                    estimated_runtime: Number of hours this test config is
                                       expected to run on each host
    """
    plans = models.Plan.smart_get_bulk(plan_ids)
    result = {}

    for plan in plans:
        machines = []
        for host in plan.host_set.all():
            pass_status = rpc_utils.compute_test_config_status(host)
            if pass_status == rpc_utils.ComputeTestConfigStatusResult.PASS:
                passed = True
            elif pass_status == rpc_utils.ComputeTestConfigStatusResult.FAIL:
                passed = False
            else:
                passed = None
            machines.append({
                'hostname': host.host.hostname,
                'status': host.status(),
                'passed': passed
            })

        bugs = set()
        for testrun in plan.testrun_set.all():
            bugs.update(testrun.bugs.values_list('external_uid', flat=True))

        test_configs = []
        for test_config in plan.testconfig_set.all():
            complete_jobs = test_config.job_set.filter(
                afe_job__hostqueueentry__complete=True)
            complete_afe_jobs = afe_models.Job.objects.filter(
                id__in=complete_jobs.values_list('afe_job', flat=True))

            complete_hosts = afe_models.Host.objects.filter(
                hostqueueentry__job__in=complete_afe_jobs)
            complete_hosts |= test_config.skipped_hosts.all()

            test_configs.append({
                'complete':
                complete_hosts.distinct().count(),
                'estimated_runtime':
                test_config.estimated_runtime
            })

        plan_data = {
            'machines': machines,
            'bugs': list(bugs),
            'test_configs': test_configs
        }
        result[plan.name] = plan_data

    return result
Ejemplo n.º 7
0
def get_overview_data(plan_ids):
    """
    Gets the data for the Overview tab

    @param plan_ids: A list of the plans, by id or name
    @return A dictionary - keys are plan names, values are dictionaries of data:
                machines: A list of dictionaries:
                hostname: The machine's hostname
                status: The host's status
                passed: True if the machine passed the test plan. A 'pass' means
                        that, for every test configuration in the plan, the
                        machine had at least one AFE job with no failed tests.
                        'passed' could also be None, meaning that this host is
                        still running tests.
                bugs: A list of the bugs filed
                test_configs: A list of dictionaries, each representing a test
                              config:
                    complete: Number of hosts that have completed this test
                              config
                    estimated_runtime: Number of hours this test config is
                                       expected to run on each host
    """
    plans = models.Plan.smart_get_bulk(plan_ids)
    result = {}

    for plan in plans:
        machines = []
        for host in plan.host_set.all():
            pass_status = rpc_utils.compute_test_config_status(host)
            if pass_status == rpc_utils.ComputeTestConfigStatusResult.PASS:
                passed = True
            elif pass_status == rpc_utils.ComputeTestConfigStatusResult.FAIL:
                passed = False
            else:
                passed = None
            machines.append({'hostname': host.host.hostname,
                             'status': host.status(),
                             'passed': passed})

        bugs = set()
        for testrun in plan.testrun_set.all():
            bugs.update(testrun.bugs.values_list('external_uid', flat=True))

        test_configs = []
        for test_config in plan.testconfig_set.all():
            complete_jobs = test_config.job_set.filter(
                    afe_job__hostqueueentry__complete=True)
            complete_afe_jobs = afe_models.Job.objects.filter(
                    id__in=complete_jobs.values_list('afe_job', flat=True))

            complete_hosts = afe_models.Host.objects.filter(
                    hostqueueentry__job__in=complete_afe_jobs)
            complete_hosts |= test_config.skipped_hosts.all()

            test_configs.append(
                    {'complete': complete_hosts.distinct().count(),
                     'estimated_runtime': test_config.estimated_runtime})

        plan_data = {'machines': machines,
                     'bugs': list(bugs),
                     'test_configs': test_configs}
        result[plan.name] = plan_data

    return result