1 |
import dbsException
|
2 |
import dbsApplication
|
3 |
import dbsProcessingPath
|
4 |
import dbsProcessedDataset
|
5 |
import dbsFile
|
6 |
import dbsEventCollection
|
7 |
import testCaseInterface
|
8 |
|
9 |
class testCreateEventCollection(testCaseInterface.testCaseInterface) :
|
10 |
|
11 |
def __init__(self):
|
12 |
|
13 |
testCaseInterface.testCaseInterface.__init__(self)
|
14 |
self.addTestCase(self.createEventCollection)
|
15 |
self.addTestCase(self.createEvCollWithOneFile)
|
16 |
self.addTestCase(self.createEvCollFilesShouldHaveSameBlockID)
|
17 |
self.addTestCase(self.createEvCollNoFileNoInsertion)
|
18 |
|
19 |
datasetPath = "/ThisIsATestDataset/Digi/ThisIsATestProcDataset"
|
20 |
app = dbsApplication.DbsApplication(
|
21 |
family="CMSAppFam1",
|
22 |
executable="cmsRun1",
|
23 |
version="CMSSW_XYZ1",
|
24 |
parameterSet="pSetDummy1")
|
25 |
|
26 |
processingPath = dbsProcessingPath.DbsProcessingPath(
|
27 |
dataTier="Digi",
|
28 |
application=app)
|
29 |
|
30 |
self.dataset = dbsProcessedDataset.DbsProcessedDataset(
|
31 |
primaryDatasetName="ThisIsATestDataset",
|
32 |
isDatasetOpen="y",
|
33 |
datasetName="ThisIsATestProcDataset",
|
34 |
processingPath=processingPath)
|
35 |
|
36 |
|
37 |
def createEventCollection(self):
|
38 |
funcName = "%s.%s" % (self.__class__.__name__, "createEventCollection: Creates Event Collection with 02 files")
|
39 |
print "Now executing ", funcName
|
40 |
|
41 |
try:
|
42 |
# Test for inserting event collections.
|
43 |
f1 = dbsFile.DbsFile(logicalFileName="myFileF10",
|
44 |
guid = "7C8A55-DE62-D811-892C-00E081250436",
|
45 |
fileType="EVDZip",
|
46 |
fileBlockId=1,
|
47 |
fileSize=100
|
48 |
)
|
49 |
f2 = dbsFile.DbsFile(logicalFileName="myFileF12",
|
50 |
guid = "7C8A55DE62-D811-892C-00E081250436",
|
51 |
fileType="EVDZip",
|
52 |
fileBlockId=1,
|
53 |
fileSize=100
|
54 |
)
|
55 |
fList=dbsFile.DbsFileList([f1, f2])
|
56 |
#fList.append(f2)
|
57 |
|
58 |
ec = dbsEventCollection.DbsEventCollection(
|
59 |
collectionName="myLFN",
|
60 |
numberOfEvents=123,
|
61 |
collectionIndex=100,
|
62 |
isPrimary="y",
|
63 |
fileList=fList)
|
64 |
ecList = dbsEventCollection.DbsEventCollectionList([ec])
|
65 |
print "Inserting event collections for: %s" % self.dataset.getDatasetName()
|
66 |
self.api.insertEventCollections(self.dataset, ecList)
|
67 |
|
68 |
|
69 |
except dbsException.DbsException, ex:
|
70 |
return 1
|
71 |
|
72 |
return 0
|
73 |
|
74 |
def createEvCollFilesShouldHaveSameBlockID(self):
|
75 |
funcName = "%s.%s" % (self.__class__.__name__, "createEvCollFilesShouldHaveSameBlockID : All files in EvColl \n \
|
76 |
Should have Same Block ID, Else they don't get inserted")
|
77 |
print "Now executing ", funcName
|
78 |
|
79 |
try:
|
80 |
#TEST All files in same EvColl should have same blockId
|
81 |
file1 = dbsFile.DbsFile(logicalFileName="myFile5",
|
82 |
guid = "7C8A55-DE62-D811-892C-00E081250436",
|
83 |
fileType="EVDZip",
|
84 |
fileBlockId=11,
|
85 |
fileSize=100
|
86 |
)
|
87 |
file2 = dbsFile.DbsFile(logicalFileName="myFile6",
|
88 |
guid = "7C8A55-DE62-D811-892C-00E081250436a",
|
89 |
fileType="EVDZip",
|
90 |
fileBlockId=10,
|
91 |
fileSize=100
|
92 |
)
|
93 |
fileListDifferentBlockIds=dbsFile.DbsFileList([file1, file2])
|
94 |
|
95 |
ecFileDifferentBlockIds = dbsEventCollection.DbsEventCollection(
|
96 |
collectionName="myLFN",
|
97 |
numberOfEvents=123456,
|
98 |
collectionIndex=1000,
|
99 |
isPrimary="y",
|
100 |
fileList=fileListDifferentBlockIds)
|
101 |
|
102 |
ecListFileDifferentBlockIds = dbsEventCollection.DbsEventCollectionList([ecFileDifferentBlockIds])
|
103 |
self.api.insertEventCollections(self.dataset, ecListFileDifferentBlockIds)
|
104 |
|
105 |
except dbsException.DbsException, ex:
|
106 |
# Return Success, Negative testcase
|
107 |
return 0
|
108 |
|
109 |
return 1
|
110 |
|
111 |
def createEvCollNoFileNoInsertion(self):
|
112 |
funcName = "%s.%s" % (self.__class__.__name__, "createEvCollNoFileNoInsertion: Cannot insert EvColl without files")
|
113 |
print "Now executing ", funcName
|
114 |
|
115 |
try:
|
116 |
|
117 |
#TEST If No FileList is provided EventCollection shouldn't be inserted
|
118 |
ecNoFileTest = dbsEventCollection.DbsEventCollection(
|
119 |
collectionName="myLFN",
|
120 |
numberOfEvents=123,
|
121 |
collectionIndex=100,
|
122 |
isPrimary="y",
|
123 |
fileList=[])
|
124 |
|
125 |
ecListNoFileTest = dbsEventCollection.DbsEventCollectionList([ecNoFileTest])
|
126 |
|
127 |
self.api.insertEventCollections(self.dataset, ecListNoFileTest)
|
128 |
except dbsException.DbsException, ex:
|
129 |
# Return Success. negative testcase
|
130 |
return 0
|
131 |
|
132 |
return 1
|
133 |
|
134 |
|
135 |
def createEvCollWithOneFile(self):
|
136 |
funcName = "%s.%s" % (self.__class__.__name__, "createEvCollWithOneFile ")
|
137 |
print "Now executing ", funcName
|
138 |
|
139 |
try:
|
140 |
#TEST All files in same EvColl should have same blockId
|
141 |
file1 = dbsFile.DbsFile(logicalFileName="myFile11",
|
142 |
guid = "7C8A55-D62-D811-892C-00E0812504361",
|
143 |
fileType="EVDZip",
|
144 |
fileBlockId=11,
|
145 |
fileSize=100
|
146 |
)
|
147 |
fileList=dbsFile.DbsFileList([file1])
|
148 |
|
149 |
ecFileBlockId = dbsEventCollection.DbsEventCollection(
|
150 |
collectionName="collectionWithOneFile",
|
151 |
numberOfEvents=123456,
|
152 |
collectionIndex=2121,
|
153 |
isPrimary="y",
|
154 |
fileList=fileList)
|
155 |
|
156 |
ecListFileBlockId = dbsEventCollection.DbsEventCollectionList([ecFileBlockId])
|
157 |
self.api.insertEventCollections(self.dataset, ecListFileBlockId)
|
158 |
|
159 |
except dbsException.DbsException, ex:
|
160 |
return 1
|
161 |
|
162 |
return 0
|
163 |
|