def removeDataSets(self, dataSetIdList): try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) return cfds.removeDataSets(dataSetIdList) except Exception as e: self.__lfh.write("removeDataSets failing %s\n" % str(e)) traceback.print_exc(file=self.__lfh)
def setLocations(self, siteId, dataSetIdList): """Set the site location for the input data list.""" try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) return cfds.writeLocationList(siteId, dataSetIdList) except Exception as e: self.__lfh.write("setLocations failing for site %r - %r\n" % (siteId, str(e))) traceback.print_exc(file=self.__lfh)
def testGetSiteId(self): """Test case - translate data set id to site id.""" try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) for testId in self.__testIdList: siteId = cfds.getSiteId(depSetId=testId) logger.info(" testId %-12s siteId %20s", testId, siteId) self.assertEqual(siteId, self.__testIdLoc[testId]) except Exception as e: # pragma: no cover logger.exception("Update to get site id for dataset %s", str(e)) self.fail()
def testGetSiteIdTestRange(self): """Test case - return default id ranges selected sites.""" try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) for siteId in self.__siteIdTestRanges: (lId, uId) = cfds.getTestIdRange(siteId=siteId) logger.info(" siteId %-30s lower %-12d upper %-12d", siteId, lId, uId) (refLid, refUid) = self.__siteIdTestRanges[siteId] if siteId in self.__siteIdTestRanges: self.assertEqual(lId, refLid) self.assertEqual(uId, refUid) except Exception as e: # pragma: no cover logger.exception("Failre to get SiteIdTestRange %s", str(e)) self.fail()
def checkConfig(self): """Perform read check for the data set configuration file.""" try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) d = cfds.getDataSetLocationDict() self.__lfh.write( "Alternate site location dictionary length = %d\n" % len(d)) sD = {} for ky in d: if d[ky] not in sD: sD[d[ky]] = 0 sD[d[ky]] += 1 # for ky in sD: self.__lfh.write(" Site %-40r count %8d\n" % (ky, sD[ky])) except Exception as e: self.__lfh.write("checkConfig failing %r\n" % str(e)) traceback.print_exc(file=self.__lfh)
def printConfig(self, siteId): """Print the configuration options for the input site.""" try: cfds = ConfigInfoDataSet(self.__verbose, self.__lfh) (lId, uId) = cfds.getDefaultIdRange(siteId=siteId) self.__lfh.write( " Default data set range for site %-30s lower %-12d upper %-12d \n" % (siteId, lId, uId)) # dataSetIdL = cfds.getDataSetLocations(siteId) nDataSets = len(dataSetIdL) for ii, dataSetId in enumerate(sorted(dataSetIdL)): self.__lfh.write(" %-8d - %12s\n" % (ii, dataSetId)) self.__lfh.write(" Total alternate data set locations = %d" % nDataSets) except Exception as e: self.__lfh.write("printConfig failing for site %r - %r\n" % (siteId, str(e))) traceback.print_exc(file=self.__lfh)
def testSetRemoveLocations(self): cidse = ConfigInfoDataSetExec() tset = ["D_800002", "D_800003"] status = cidse.setLocations("WWPDB_DEPLOY_DUMMY_RU", tset) self.assertTrue(status) # Check response cids = ConfigInfoDataSet() for d in tset: self.assertEqual(cids.getSiteId(d), "WWPDB_DEPLOY_DUMMY_RU") self.assertIsNone(cids.getSiteId("D_9999")) self.assertEqual(cids.getSiteId("D_1000200001"), "WWPDB_DEPLOY_PRODUCTION_RU") # Removal status = cidse.removeDataSets([tset[0]]) self.assertTrue(status) # Reinstantiate to load list again cids = ConfigInfoDataSet() self.assertEqual(cids.getSiteId(tset[0]), "UNASSIGNED", "Removal failed")