class AnalysisCollectionService_t(unittest.TestCase): """ Unit tests for AnalysisCollectionService """ def setUp(self): """Set up test couch instance""" self.dbsURL = 'http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet' self.dataset = '/RelValProdTTbar/JobRobot-MC_3XY_V24_JobRobot-v1/GEN-SIM-DIGI-RECO' """Set up couch test environment""" self.testInit = TestInitCouchApp(__file__) self.testInit.setupCouch("wmcore-acdc-acservice", "GroupUser", "ACDC") self.acService = AnalysisCollectionService(url=self.testInit.couchUrl, database = self.testInit.couchDbName) self.collection = self.acService.createCollection('ewv-testcoll', 'ewv2', 'Analysis') def tearDown(self): """Clean up couch instance""" self.testInit.tearDownCouch() def testCreateFilesetFromDBS(self): """Test creating an analysis fileset from DBS""" rangesMask = Mask() rangesMask.addRunWithLumiRanges(run=1, lumiList=[[1, 9], [12, 12], [31, 31], [38, 39], [49, 49], [51, 52], [64, 65], [82, 82], [92, 98]]) fs, fl = self.acService.createFilesetFromDBS(self.collection, filesetName='test_fs', dbsURL=self.dbsURL, dataset=self.dataset, mask=rangesMask) self.assertTrue(fl['_id']) self.assertEqual(len(fl['files']), 21)
def test06UploadACDC(self): # get previous request we can piggyback on for request in reversed(self.__class__.reqmgr.getRequest()): request = request['WMCore.RequestManager.DataStructs.Request.Request']['RequestName'] if 'RequestCancellation_t' in request: self.__class__.requestParams['OriginalRequestName'] = request break else: raise nose.SkipTest("no suitable request in reqmgr to resubmit") self.__class__.requestParams['InitialTaskPath'] = self.__class__.requestParams['InitialTaskPath'] % self.__class__.requestParams['OriginalRequestName'] self.__class__.requestParams['ACDCServer'] = self.__class__.endpoint + '/couchdb' # create and upload acdc service = AnalysisCollectionService(url=self.__class__.endpoint + '/couchdb', database = 'wmagent_acdc') service.createCollection(self.__class__.requestParams['OriginalRequestName'], 'integration', 'DMWM') with open(os.path.join(getTestBase(), '..', 'data', 'ACDC', 'linacre_ACDC_ReReco13JulCosmics_120809_130020_117_120823_200309_5735.json')) as infile: acdc_json = infile.read().replace('linacre_ACDC_ReReco13JulCosmics_120809_130020_117_120823_200309_5735', self.__class__.requestParams['OriginalRequestName']) acdc_json = loads(acdc_json) acdc_database = Database('wmagent_acdc', self.__class__.endpoint + '/couchdb') acdc_database.commit(acdc_json)
def test06UploadACDC(self): # get previous request we can piggyback on for request in reversed(self.__class__.reqmgr.getRequest()): request = request[ 'WMCore.RequestManager.DataStructs.Request.Request'][ 'RequestName'] if 'RequestCancellation_t' in request: self.__class__.requestParams['OriginalRequestName'] = request break else: raise nose.SkipTest("no suitable request in reqmgr to resubmit") self.__class__.requestParams[ 'InitialTaskPath'] = self.__class__.requestParams[ 'InitialTaskPath'] % self.__class__.requestParams[ 'OriginalRequestName'] self.__class__.requestParams[ 'ACDCServer'] = self.__class__.endpoint + '/couchdb' # create and upload acdc service = AnalysisCollectionService(url=self.__class__.endpoint + '/couchdb', database='wmagent_acdc') service.createCollection( self.__class__.requestParams['OriginalRequestName'], 'integration', 'DMWM') with open( os.path.join( getTestBase(), '..', 'data', 'ACDC', 'linacre_ACDC_ReReco13JulCosmics_120809_130020_117_120823_200309_5735.json' )) as infile: acdc_json = infile.read().replace( 'linacre_ACDC_ReReco13JulCosmics_120809_130020_117_120823_200309_5735', self.__class__.requestParams['OriginalRequestName']) acdc_json = loads(acdc_json) acdc_database = Database('wmagent_acdc', self.__class__.endpoint + '/couchdb') acdc_database.commit(acdc_json)
class AnalysisCollectionService_t(unittest.TestCase): """ Unit tests for AnalysisCollectionService """ def setUp(self): """Set up test couch instance""" self.dbsURL = 'https://cmsweb.cern.ch/dbs/prod/global/DBSReader' self.dataset = '/RelValProdTTbar/JobRobot-MC_3XY_V24_JobRobot-v1/GEN-SIM-DIGI-RECO' """Set up couch test environment""" self.testInit = TestInitCouchApp(__file__) self.testInit.setupCouch("wmcore-acdc-acservice", "GroupUser", "ACDC") self.acService = AnalysisCollectionService( url=self.testInit.couchUrl, database=self.testInit.couchDbName) self.collection = self.acService.createCollection( 'ewv-testcoll', 'ewv2', 'Analysis') def tearDown(self): """Clean up couch instance""" self.testInit.tearDownCouch() def testCreateFilesetFromDBS(self): """Test creating an analysis fileset from DBS""" rangesMask = Mask() rangesMask.addRunWithLumiRanges(run=1, lumiList=[[1, 9], [12, 12], [31, 31], [38, 39], [49, 49], [51, 52], [64, 65], [82, 82], [92, 98]]) fs, fl = self.acService.createFilesetFromDBS(self.collection, filesetName='test_fs', dbsURL=self.dbsURL, dataset=self.dataset, mask=rangesMask) self.assertTrue(fl['_id']) self.assertEqual(len(fl['files']), 21) for file in fl['files']: self.assertTrue(fl['files'][file]['merged'])