Beispiel #1
0
class List_t(unittest.TestCase):
    @DaoConfig("DBSReader")
    def __init__(self, methodName="runTest"):
        super(List_t,self).__init__(methodName)
        data_location = os.path.join(os.path.dirname(os.path.abspath(__file__)),'test_data.pkl')
        self.data_provider = create_dbs_data_provider(data_type='transient',data_location=data_location)
        self.data = self.data_provider.get_block_data()

    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.dao = BlockList(self.logger, self.dbi, self.dbowner)

    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def test01(self):
        """dao.Oracle.Block.List: Basic"""
        block_name = self.data[0]['block_name']
        dataset_name = block_name.split("#")[0]
        result = self.dao.execute(self.conn, dataset=dataset_name)
        self.assertEqual(strip_volatile_fields(result), self.data)

    def test02(self):
        """dao.Oracle.Block.List: Basic"""
        result = self.dao.execute(self.conn, block_name=self.data[0]['block_name'])
        self.assertEqual(strip_volatile_fields(result), self.data)

    def test03(self):
        """dao.Oracle.Block.List: Basic"""
        result = self.dao.execute(self.conn, origin_site_name=self.data[0]['origin_site_name'])
        self.assertTrue(type(result) == list)
        self.assertNotEqual(len(result), 0)
Beispiel #2
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
     self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
     self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
     self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
     self.sequence_manager = SequenceManager(self.logger, self.dbi, self.dbowner)
Beispiel #3
0
 def test10(self):
     """Block.List"""
     from dbs.dao.Oracle.Block.List import List as BlockList
     dao = BlockList(self.logger, self.dbi)
     dao.execute("/RelValQCD_Pt_80_120/CMSSW_3_1_3-MC_31X_V5-v1/GEN-SIM-RECO")
     dao.execute("/a/b/c/", "/a/b/c#d")
     dao.execute("a/b/c#d")
Beispiel #4
0
 def test10(self):
     """Block.List"""
     from dbs.dao.Oracle.Block.List import List as BlockList
     dao = BlockList(self.logger, self.dbi)
     dao.execute("/RelValQCD_Pt_80_120/CMSSW_3_1_3-MC_31X_V5-v1/GEN-SIM-RECO")
     dao.execute("/a/b/c/", "/a/b/c#d")
     dao.execute("a/b/c#d")
Beispiel #5
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
     self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
     self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
     self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
     self.sequence_manager = SequenceManager(self.logger, self.dbi,
                                             self.dbowner)
Beispiel #6
0
    def test01(self):
        """dao.Oracle.Block.List: Basic"""
	conn = self.dbi.connection()
        dao = BlockList(self.logger, self.dbi, self.dbowner)
        dao.execute(conn, dataset="*")
        dao.execute(conn, block_name='*')
        dao.execute(conn, site_name='*')
        result = dao.execute(conn, block_name='*')
        self.assertTrue(type(result) == list)
        self.assertEqual(len(result), 0)
	conn.close()
Beispiel #7
0
class List_t(unittest.TestCase):
    @DaoConfig("DBSReader")
    def __init__(self, methodName="runTest"):
        super(List_t, self).__init__(methodName)
        data_location = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'test_data.pkl')
        self.data_provider = create_dbs_data_provider(
            data_type='transient', data_location=data_location)
        self.data = self.data_provider.get_block_data()

    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.dao = BlockList(self.logger, self.dbi, self.dbowner)

    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def test01(self):
        """dao.Oracle.Block.List: Basic"""
        block_name = self.data[0]['block_name']
        dataset_name = block_name.split("#")[0]
        result = self.dao.execute(self.conn, dataset=dataset_name)
        self.assertEqual(strip_volatile_fields(result), self.data)

    def test02(self):
        """dao.Oracle.Block.List: Basic"""
        result = self.dao.execute(self.conn,
                                  block_name=self.data[0]['block_name'])
        self.assertEqual(strip_volatile_fields(result), self.data)

    def test03(self):
        """dao.Oracle.Block.List: Basic"""
        result = self.dao.execute(
            self.conn, origin_site_name=self.data[0]['origin_site_name'])
        self.assertTrue(type(result) == list)
        self.assertNotEqual(len(result), 0)
Beispiel #8
0
class Insert_t(unittest.TestCase):
    @DaoConfig("DBSWriter")
    def __init__(self, methodName='runTest'):
        super(Insert_t,self).__init__(methodName)
        data_location = os.path.join(os.path.dirname(os.path.abspath(__file__)),'test_data.pkl')
        self.data_provider = create_dbs_data_provider(data_type='transient',data_location=data_location)
        self.data = self.data_provider.get_file_data(regenerate=True)[0]
        self.child_data = self.data_provider.get_child_file_data(regenerate=True)[0]
        
    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
        self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
        self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
        self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
        self.sequence_manager = SequenceManager(self.logger, self.dbi, self.dbowner)
                
    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def _insertFile(self, data):
        tran = self.conn.begin()
        
        try:
            data["file_id"] = self.sequence_manager.increment(self.conn, "SEQ_FL", transaction=tran)
            #insert needs an id not the name, whereas list will return the name
            data["dataset_id"] = self.dataset_id.execute(self.conn, dataset=data["dataset"], transaction=tran)
            del data["dataset"]

            #insert needs an id not the name, whereas list will return the name
            block_info = self.block_list.execute(self.conn, block_name=data["block_name"], transaction=tran)
            data["block_id"] = block_info[0]["block_id"]
            del data["block_name"]
            
            #insert needs an id not the name, whereas list will return the name
            data["file_type_id"] = self.file_type_id.execute(self.conn, data["file_type"], transaction=tran)
            del data["file_type"]

            #No more supported, see Ticket #965 YG 
            del data["creation_date"]
            del data["create_by"]
            
            self.file_insert.execute(self.conn, data, transaction=tran)

        except Exception as ex:
            tran.rollback()
            raise ex
        else:
            tran.commit()
        finally:
            if tran:
                tran.close()
    def test01(self):
        """dao.Oracle.File.Insert: Basic"""
        self._insertFile(self.data)

    def test02(self):
        """dao.Oracle.File.Insert: ChildFile"""
        self._insertFile(self.child_data)
Beispiel #9
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.dao = BlockList(self.logger, self.dbi, self.dbowner)
Beispiel #10
0
class Insert_t(unittest.TestCase):
    @DaoConfig("DBSWriter")
    def __init__(self, methodName='runTest'):
        super(Insert_t, self).__init__(methodName)
        data_location = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'test_data.pkl')
        self.data_provider = create_dbs_data_provider(
            data_type='transient', data_location=data_location)
        self.data = self.data_provider.get_file_data(regenerate=True)[0]
        self.child_data = self.data_provider.get_child_file_data(
            regenerate=True)[0]

    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
        self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
        self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
        self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
        self.sequence_manager = SequenceManager(self.logger, self.dbi,
                                                self.dbowner)

    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def _insertFile(self, data):
        tran = self.conn.begin()

        try:
            data["file_id"] = self.sequence_manager.increment(self.conn,
                                                              "SEQ_FL",
                                                              transaction=tran)
            #insert needs an id not the name, whereas list will return the name
            data["dataset_id"] = self.dataset_id.execute(
                self.conn, dataset=data["dataset"], transaction=tran)
            del data["dataset"]

            #insert needs an id not the name, whereas list will return the name
            block_info = self.block_list.execute(self.conn,
                                                 block_name=data["block_name"],
                                                 transaction=tran)
            for b in block_info:
                data["block_id"] = b["block_id"]
            del data["block_name"]

            #insert needs an id not the name, whereas list will return the name
            data["file_type_id"] = self.file_type_id.execute(self.conn,
                                                             data["file_type"],
                                                             transaction=tran)
            del data["file_type"]

            #No more supported, see Ticket #965 YG
            del data["creation_date"]
            del data["create_by"]

            self.file_insert.execute(self.conn, data, transaction=tran)

        except Exception as ex:
            tran.rollback()
            raise ex
        else:
            tran.commit()
        finally:
            if tran:
                tran.close()

    def test01(self):
        """dao.Oracle.File.Insert: Basic"""
        self._insertFile(self.data)

    def test02(self):
        """dao.Oracle.File.Insert: ChildFile"""
        self._insertFile(self.child_data)
Beispiel #11
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.dao = BlockList(self.logger, self.dbi, self.dbowner)