def get_next_test_configs(plan_id): """ Gets information about the next planner test configs that need to be run @param plan_id: the ID or name of the test plan @return a dictionary: complete: True or False, shows test plan completion next_configs: a list of dictionaries: host: ID of the host next_test_config_id: ID of the next Planner test to run """ plan = models.Plan.smart_get(plan_id) result = {'next_configs': []} rpc_utils.update_hosts_table(plan) for host in models.Host.objects.filter(plan=plan): next_test_config = rpc_utils.compute_next_test_config(plan, host) if next_test_config: config = { 'next_test_config_id': next_test_config.id, 'next_test_config_alias': next_test_config.alias, 'host': host.host.hostname } result['next_configs'].append(config) rpc_utils.check_for_completion(plan) result['complete'] = plan.complete return result
def get_next_test_configs(plan_id): """ Gets information about the next planner test configs that need to be run @param plan_id: the ID or name of the test plan @return a dictionary: complete: True or False, shows test plan completion next_configs: a list of dictionaries: host: ID of the host next_test_config_id: ID of the next Planner test to run """ plan = models.Plan.smart_get(plan_id) result = {'next_configs': []} rpc_utils.update_hosts_table(plan) for host in models.Host.objects.filter(plan=plan): next_test_config = rpc_utils.compute_next_test_config(plan, host) if next_test_config: config = {'next_test_config_id': next_test_config.id, 'next_test_config_alias': next_test_config.alias, 'host': host.host.hostname} result['next_configs'].append(config) rpc_utils.check_for_completion(plan) result['complete'] = plan.complete return result
def test_compute_next_test_config(self): self._setup_active_plan() test_config = models.TestConfig.objects.create( plan=self._plan, alias='config2', control_file=self._control, execution_order=2, estimated_runtime=1) self.assertEqual(1, self._afe_job.hostqueueentry_set.count()) self.assertEqual( None, rpc_utils.compute_next_test_config(self._plan, self._planner_host)) self.assertFalse(self._planner_host.complete) hqe = self._afe_job.hostqueueentry_set.all()[0] hqe.status = host_queue_entry_states.Status.COMPLETED hqe.save() self.assertEqual( test_config, rpc_utils.compute_next_test_config(self._plan, self._planner_host)) self.assertFalse(self._planner_host.complete) afe_job = self._create_job(hosts=(1,)) planner_job = models.Job.objects.create(plan=self._plan, test_config=test_config, afe_job=afe_job) self.assertEqual( None, rpc_utils.compute_next_test_config(self._plan, self._planner_host)) self.assertFalse(self._planner_host.complete) hqe = afe_job.hostqueueentry_set.all()[0] hqe.status = host_queue_entry_states.Status.COMPLETED hqe.save() self.assertEqual( None, rpc_utils.compute_next_test_config(self._plan, self._planner_host)) self.assertTrue(self._planner_host.complete)