def setUp(self): self.setConfig(config) self.setCouchDBs([(config.views.data.couch_reqmgr_db, "ReqMgr"), (config.views.data.couch_reqmgr_aux_db, None)]) self.setSchemaModules([]) RESTBaseUnitTestWithDBBackend.setUp(self) self.setFakeDN() # print "%s" % self.test_authz_key.data self.default_status_header = getAuthHeader(self.test_authz_key.data, DEFAULT_STATUS_PERMISSION) requestPath = os.path.join(getWMBASE(), "test", "data", "ReqMgr", "requests", "DMWM") rerecoFile = open(os.path.join(requestPath, "ReReco.json"), "r") rerecoArgs = JsonWrapper.load(rerecoFile) self.rerecoCreateArgs = rerecoArgs["createRequest"] self.rerecoCreateArgs["PrepID"] = "test_prepid" self.rerecoAssignArgs = rerecoArgs["assignRequest"] # overwrite rereco args self.rerecoAssignArgs["AcquisitionEra"] = "test_aqc" lheFile = open(os.path.join(requestPath, "TaskChain_Data.json"), "r") lheArgs = JsonWrapper.load(lheFile) self.lheStep0CreateArgs = lheArgs["createRequest"] self.lheStep0AssignArgs = lheArgs["assignRequest"] self.lheStep0AssignArgs["AcquisitionEra"] = "test_aqc" cmsswDoc = {"_id": "software"} cmsswDoc[self.rerecoCreateArgs["ScramArch"]] = [] cmsswDoc[self.rerecoCreateArgs["ScramArch"]].append(self.rerecoCreateArgs["CMSSWVersion"]) insertDataToCouch(os.getenv("COUCHURL"), config.views.data.couch_reqmgr_aux_db, cmsswDoc)
def setUp(self): self.setConfig(config) self.setCouchDBs([(config.views.data.couch_reqmgr_db, "ReqMgr"), (config.views.data.couch_reqmgr_aux_db, None)]) self.setSchemaModules([]) RESTBaseUnitTestWithDBBackend.setUp(self) self.setFakeDN() #print "%s" % self.test_authz_key.data self.default_status_header = getAuthHeader(self.test_authz_key.data, DEFAULT_STATUS_PERMISSION) requestPath = os.path.join(getWMBASE(), "test", "data", "ReqMgr", "requests") rerecoFile = open(os.path.join(requestPath, "ReReco.json"), 'r') rerecoArgs = JsonWrapper.load(rerecoFile) self.rerecoCreateArgs = rerecoArgs["createRequest"] self.rerecoAssignArgs = rerecoArgs["assignRequest"] # overwrite rereco args self.rerecoAssignArgs["AcquisitionEra"] = "test_aqc" lheFile = open(os.path.join(requestPath, "LHEStep0.json"), 'r') lheArgs = JsonWrapper.load(lheFile) self.lheStep0CreateArgs = lheArgs["createRequest"] self.lheStep0AssignArgs = lheArgs["assignRequest"] self.lheStep0AssignArgs["AcquisitionEra"] = "test_aqc" cmsswDoc = {"_id": "software"} cmsswDoc[self.rerecoCreateArgs["ScramArch"]] = [] cmsswDoc[self.rerecoCreateArgs["ScramArch"]].append(self.rerecoCreateArgs["CMSSWVersion"]) insertDataToCouch(os.getenv("COUCHURL"), config.views.data.couch_reqmgr_aux_db, cmsswDoc)
def setUp(self): self.setConfig(config) self.setCouchDBs([(config.views.data.couch_reqmgr_db, "ReqMgr"), (config.views.data.couch_reqmgr_aux_db, None)]) self.setSchemaModules([]) RESTBaseUnitTestWithDBBackend.setUp(self) self.setFakeDN() requestPath = os.path.join(getWMBASE(), "test", "data", "ReqMgr", "requests", "DMWM") rerecoFile = open(os.path.join(requestPath, "ReReco.json"), 'r') rerecoArgs = JsonWrapper.load(rerecoFile) self.rerecoCreateArgs = rerecoArgs["createRequest"] self.rerecoAssignArgs = rerecoArgs["assignRequest"] cmsswDoc = {"_id": "software"} cmsswDoc[self.rerecoCreateArgs["ScramArch"]] = [] cmsswDoc[self.rerecoCreateArgs["ScramArch"]].append( self.rerecoCreateArgs["CMSSWVersion"]) insertDataToCouch(os.getenv("COUCHURL"), config.views.data.couch_reqmgr_aux_db, cmsswDoc) self.reqSvc = ReqMgr(self.jsonSender["host"]) self.reqSvc._noStale = True self.reqSvc['requests'].additionalHeaders = self.create_header
def setUp(self): filePath = os.path.join(getTestBase(), "WMCore_t/WorkQueue_t/DataStructs_t/wq_available_elements.json") with open(filePath, "r") as f: gqData = JsonWrapper.load(f) self.gqElements = [] for ele in gqData: self.gqElements.append(WorkQueueElement(**ele))
def setUp(self): filePath = os.path.join( getTestBase(), "WMCore_t/WorkQueue_t/DataStructs_t/wq_available_elements.json") with open(filePath, "r") as f: gqData = JsonWrapper.load(f) self.gqElements = [] for ele in gqData: self.gqElements.append(WorkQueueElement(**ele))
def test_file_compare(self): """ _test_file_compare_ """ try: import cjson except: raise nose.SkipTest f = tempfile.NamedTemporaryFile() f.delete = False json_wrap._module = "cjson" #write self.record to a file via cjson json_wrap._module = "cjson" json_wrap.dump(self.record, f) f.close() #read the file with the json f = open(f.name, 'r') json_wrap._module = "json" data = json_wrap.load(f) f.close() self.assertEqual(data, self.record) #Clean up os.remove(f.name) #write self.record to a file via json f = tempfile.NamedTemporaryFile() f.delete = False json_wrap.dump(self.record, f) f.close() #read the file with cjson f = open(f.name, 'r') json_wrap._module = "cjson" data = json_wrap.load(f) f.close() self.assertEqual(data, self.record) #Clean up os.remove(f.name)
def setUp(self): self.setConfig(config) self.setCouchDBs([(config.views.data.couch_reqmgr_db, "ReqMgr"), (config.views.data.couch_reqmgr_aux_db, None)]) self.setSchemaModules([]) RESTBaseUnitTestWithDBBackend.setUp(self) # put into ReqMgr auxiliary database under "software" document scram/cmsms # which we'll need a little for request injection #Warning: this assumes the same structure in jenkins wmcore_root/test requestPath = os.path.join(getWMBASE(), "test", "data", "ReqMgr", "requests") mcFile = open(os.path.join(requestPath, "MonteCarlo.json"), 'r') self.mcArgs = JsonWrapper.load(mcFile)["createRequest"] cmsswDoc = {"_id": "software"} cmsswDoc[self.mcArgs["ScramArch"]] = [] cmsswDoc[self.mcArgs["ScramArch"]].append(self.mcArgs["CMSSWVersion"]) insertDataToCouch(os.getenv("COUCHURL"), config.views.data.couch_reqmgr_aux_db, cmsswDoc)
def _updatePileupPNNs(self, stepHelper, fakeSites): """ Update the workflow copy of the cached pileup file with PNNs forced by TrustPUSitelists flag """ fileName = self._getStepFilePath(stepHelper) fakePNNs = mapSitetoPNN(fakeSites) with open(fileName, 'r') as puO: pileupData = json.load(puO) for dummyPUType, blockDict in pileupData.iteritems(): for dummyBlockName, blockInfo in blockDict.iteritems(): blockInfo['PhEDExNodeNames'].extend([x for x in fakePNNs if x not in blockInfo]) encoder = JSONEncoder() jsonPU = encoder.encode(pileupData) self._writeFile(fileName, jsonPU)
def setUp(self): self.setConfig(config) self.setCouchDBs([(config.views.data.couch_reqmgr_db, "ReqMgr"), (config.views.data.couch_reqmgr_aux_db, None)]) self.setSchemaModules([]) RESTBaseUnitTestWithDBBackend.setUp(self) self.setFakeDN() requestPath = os.path.join(getWMBASE(), "test", "data", "ReqMgr", "requests", "DMWM") rerecoFile = open(os.path.join(requestPath, "ReReco.json"), 'r') rerecoArgs = JsonWrapper.load(rerecoFile) self.rerecoCreateArgs = rerecoArgs["createRequest"] self.rerecoAssignArgs = rerecoArgs["assignRequest"] cmsswDoc = {"_id": "software"} cmsswDoc[self.rerecoCreateArgs["ScramArch"]] = [] cmsswDoc[self.rerecoCreateArgs["ScramArch"]].append(self.rerecoCreateArgs["CMSSWVersion"]) insertDataToCouch(os.getenv("COUCHURL"), config.views.data.couch_reqmgr_aux_db, cmsswDoc) self.reqSvc = ReqMgr(self.jsonSender["host"]) self.reqSvc._noStale = True self.reqSvc['requests'].additionalHeaders = self.create_header