def _spawn_job(job): log.debug("functional spawn job") thread = RunJobThread(self.job_scheduler.progress, self.job_scheduler._db_quota, job, job.get_steps()) self.job_scheduler._run_threads[job.id] = thread thread._run()
def test_validation_missing_lnd_type_ok(self): log.debug("Checking when lnd_type is missing from lnet info but lnd_network == -1") self.api_post( self.RESOURCE_PATH, data={"lnd_network": -1, "network_interface": self._lnetinfo.network_interfaces[0]["resource_uri"]}, )
def test_validation_missing(self): for missing in ["lnd_type", "lnd_network", "network_interface"]: # Now create nids on each interface. objects = [] for lnd_network, interface in enumerate( self._lnetinfo.network_interfaces, start=99): log.debug("Checking when %s is missing from lnet info" % missing) info = { "lnd_type": "tcp", "lnd_network": lnd_network, "network_interface": interface['resource_uri'] } del info[missing] objects.append(info) # Now post these of values, this will wait for the command to complete. response = self.api_post(self.RESOURCE_PATH, data={'objects': objects}, assertion_test=lambda self, response: self .assertHttpBadRequest(response)) self.assertEqual( response, {missing: ['Field %s not present in data' % missing]})
def _get_lnet_info(self, host): """ :return: Returns a named tuple of network and lnet configuration or None if lnet configuration is not provided by the version of the manager """ # We fetch the host again so that it's state is updated. hosts = self.api_get_list("/api/host/", data={"fqdn": host["fqdn"]}) self.assertEqual(len(hosts), 1, "Expected a single host to be returned got %s" % len(hosts)) host = hosts[0] lnet_configuration = self.api_get_list( "/api/lnet_configuration/", data={"host__id": host["id"], "dehydrate__nids": True, "dehydrate__host": True} ) self.assertEqual( len(lnet_configuration), 1, "Expected a single lnet configuration to be returned got %s" % len(lnet_configuration), ) lnet_configuration = lnet_configuration[0] network_interfaces = self.api_get_list("/api/network_interface/", data={"host__id": host["id"]}) nids = self.api_get_list("/api/nid/", data={"lnet_configuration__id": lnet_configuration["id"]}) log.debug("Fetched Lnet info for %s" % host["fqdn"]) log.debug("Nid info %s" % nids) log.debug("NetworkInterfaces info %s" % network_interfaces) log.debug("LNetConfiguration info %s" % lnet_configuration) return self.LNetInfo(nids, network_interfaces, lnet_configuration, host)
def set_and_assert_state(self, obj, state, check=True, run=True): command = Command.set_state([(obj, state)], "Unit test transition %s to %s" % (obj, state), run=run) log.debug("calling drain_progress") self.drain_progress() if check: if command: self.assertEqual( Command.objects.get(pk=command.id).complete, True) try: return self.assertState(obj, state) except obj.__class__.DoesNotExist: return obj else: return command
def spawn_job(job): log.debug("neutered spawn_job") thread = mock.Mock() self.job_scheduler._run_threads[job.id] = thread