def testCreateDeleteExists(self): """ _testCreateDeleteExists_ Create a JobGroup and then delete it. Use the JobGroup's exists() method to determine if it exists before it is created, after it is created and after it is deleted. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") testWorkflow.create() testFileset = WMBSFileset(name="TestFileset") testFileset.create() testSubscription = Subscription(fileset=testFileset, workflow=testWorkflow) testSubscription.create() testJobGroup = JobGroup(subscription=testSubscription) self.assertFalse(testJobGroup.exists()) testJobGroup.create() self.assertTrue(testJobGroup.exists()) testJobGroup.delete() self.assertFalse(testJobGroup.exists()) testSubscription.delete() testFileset.delete() testWorkflow.delete() return
def testCreateDeleteExists(self): """ _testCreateDeleteExists_ Test the create(), delete() and exists() methods of the workflow class by creating and deleting a workflow. The exists() method will be called before and after creation and after deletion. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task='Test', wfType="ReReco") self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists before it was created") testWorkflow.create() self.assertTrue(testWorkflow.exists() > 0, "ERROR: Workflow does not exist after it has been created") testWorkflow.create() testWorkflow.delete() self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists after it has been deleted") return
def testCreateDeleteExists(self): """ _testCreateDeleteExists_ Test the create(), delete() and exists() methods of the workflow class by creating and deleting a workflow. The exists() method will be called before and after creation and after deletion. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task='Test', wfType="ReReco") self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists before it was created") testWorkflow.create() self.assertTrue( testWorkflow.exists() > 0, "ERROR: Workflow does not exist after it has been created") testWorkflow.create() testWorkflow.delete() self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists after it has been deleted") return
def testDeleteTransaction(self): """ _testDeleteTransaction_ Create a workflow and commit it to the database. Begin a transaction and delete the workflow, then rollback the transaction. Use the workflow's exists() method to verify that the workflow doesn't exist in the database before create() is called, it does exist after create() is called, it doesn't exist after delete() is called and it does exist after the transaction is rolled back. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists before it was created") testWorkflow.create() self.assertTrue(testWorkflow.exists() > 0, "ERROR: Workflow does not exist after it has been created") myThread = threading.currentThread() myThread.transaction.begin() testWorkflow.delete() self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists after it has been deleted") myThread.transaction.rollback() self.assertTrue(testWorkflow.exists() > 0, "ERROR: Workflow does not exist transaction was rolled back") return
def testCreateTransaction(self): """ _testCreateTransaction_ Create a JobGroup and commit it to the database. Rollback the database transaction and verify that the JobGroup is no longer in the database. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") testWorkflow.create() testFileset = WMBSFileset(name="TestFileset") testFileset.create() testSubscription = Subscription(fileset=testFileset, workflow=testWorkflow) testSubscription.create() testJobGroup = JobGroup(subscription=testSubscription) assert testJobGroup.exists() == False, "ERROR: Job group exists before it was created" myThread = threading.currentThread() myThread.transaction.begin() testJobGroup.create() assert testJobGroup.exists() >= 0, "ERROR: Job group does not exist after it was created" myThread.transaction.rollback() assert testJobGroup.exists() == False, "ERROR: Job group exists after transaction was rolled back." testSubscription.delete() testFileset.delete() testWorkflow.delete() return
def testLoad(self): """ _testLoad_ Create a workflow and then try to load it from the database using the following load methods: Workflow.LoadFromName Workflow.LoadFromID Workflow.LoadFromSpecOwner """ testWorkflowA = Workflow( spec="spec.xml", owner="Simon", name="wf001", task="Test", wfType="ReReco", priority=1000 ) testWorkflowA.create() testWorkflowB = Workflow(name="wf001", task="Test") testWorkflowB.load() self.assertTrue( (testWorkflowA.id == testWorkflowB.id) and (testWorkflowA.name == testWorkflowB.name) and (testWorkflowA.spec == testWorkflowB.spec) and (testWorkflowA.task == testWorkflowB.task) and (testWorkflowA.wfType == testWorkflowB.wfType) and (testWorkflowA.owner == testWorkflowB.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromName Failed", ) testWorkflowC = Workflow(id=testWorkflowA.id) testWorkflowC.load() self.assertTrue( (testWorkflowA.id == testWorkflowC.id) and (testWorkflowA.name == testWorkflowC.name) and (testWorkflowA.spec == testWorkflowC.spec) and (testWorkflowA.task == testWorkflowC.task) and (testWorkflowA.wfType == testWorkflowC.wfType) and (testWorkflowA.owner == testWorkflowC.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromID Failed", ) testWorkflowD = Workflow(spec="spec.xml", owner="Simon", task="Test") testWorkflowD.load() self.assertTrue( (testWorkflowA.id == testWorkflowD.id) and (testWorkflowA.name == testWorkflowD.name) and (testWorkflowA.spec == testWorkflowD.spec) and (testWorkflowA.task == testWorkflowD.task) and (testWorkflowA.wfType == testWorkflowD.wfType) and (testWorkflowA.owner == testWorkflowD.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromSpecOwner Failed", ) testWorkflowA.delete() return
def testLoad(self): """ _testLoad_ Create a workflow and then try to load it from the database using the following load methods: Workflow.LoadFromName Workflow.LoadFromID Workflow.LoadFromSpecOwner """ testWorkflowA = Workflow(spec="spec.xml", owner="Simon", name="wf001", task='Test', wfType="ReReco", priority=1000) testWorkflowA.create() testWorkflowB = Workflow(name="wf001", task='Test') testWorkflowB.load() self.assertTrue((testWorkflowA.id == testWorkflowB.id) and (testWorkflowA.name == testWorkflowB.name) and (testWorkflowA.spec == testWorkflowB.spec) and (testWorkflowA.task == testWorkflowB.task) and (testWorkflowA.wfType == testWorkflowB.wfType) and (testWorkflowA.owner == testWorkflowB.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromName Failed") testWorkflowC = Workflow(id=testWorkflowA.id) testWorkflowC.load() self.assertTrue((testWorkflowA.id == testWorkflowC.id) and (testWorkflowA.name == testWorkflowC.name) and (testWorkflowA.spec == testWorkflowC.spec) and (testWorkflowA.task == testWorkflowC.task) and (testWorkflowA.wfType == testWorkflowC.wfType) and (testWorkflowA.owner == testWorkflowC.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromID Failed") testWorkflowD = Workflow(spec="spec.xml", owner="Simon", task='Test') testWorkflowD.load() self.assertTrue((testWorkflowA.id == testWorkflowD.id) and (testWorkflowA.name == testWorkflowD.name) and (testWorkflowA.spec == testWorkflowD.spec) and (testWorkflowA.task == testWorkflowD.task) and (testWorkflowA.wfType == testWorkflowD.wfType) and (testWorkflowA.owner == testWorkflowD.owner) and (testWorkflowA.priority == testWorkflowB.priority), "ERROR: Workflow.LoadFromSpecOwner Failed") testWorkflowA.delete() return
def testDeleteTransaction(self): """ _testDeleteTransaction_ Create a JobGroup and then commit it to the database. Begin a transaction and the delete the JobGroup from the database. Using the exists() method verify that the JobGroup is not in the database. Finally, roll back the transaction and verify that the JobGroup is in the database. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") testWorkflow.create() testFileset = WMBSFileset(name="TestFileset") testFileset.create() testSubscription = Subscription(fileset=testFileset, workflow=testWorkflow) testSubscription.create() testJobGroup = JobGroup(subscription=testSubscription) assert testJobGroup.exists() == False, \ "ERROR: Job group exists before it was created" testJobGroup.create() assert testJobGroup.exists() >= 0, \ "ERROR: Job group does not exist after it was created" myThread = threading.currentThread() myThread.transaction.begin() testJobGroup.delete() assert testJobGroup.exists() == False, \ "ERROR: Job group exists after it was deleted" myThread.transaction.rollback() assert testJobGroup.exists() >= 0, \ "ERROR: Job group does not exist after transaction was rolled back." testSubscription.delete() testFileset.delete() testWorkflow.delete() return
def notestCreateDeleteExists(self): """ Create and then delete a job and workflow. Use the workunit class's exists() method to determine if the workunit has been written to the database before the job is created, after the job has been created, and after the workflow has been deleted. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") testWorkflow.create() testWMBSFileset = Fileset(name="TestFileset") testWMBSFileset.create() testSubscription = Subscription(fileset=testWMBSFileset, workflow=testWorkflow) testSubscription.create() testJobGroup = JobGroup(subscription=testSubscription) testJobGroup.create() testFileA = File(lfn="/this/is/a/lfnA", size=1024, events=10) testFileA.addRun(Run(1, *[45])) testFileB = File(lfn="/this/is/a/lfnB", size=1024, events=10) testFileB.addRun(Run(1, *[46])) testFileA.create() testFileB.create() testJob = Job(name="TestJob", files=[testFileA, testFileB]) testWU1 = WorkUnit(taskID=testWorkflow.id, fileid=testFileA['id'], runLumi=Run(1, *[45])) testWU2 = WorkUnit(taskID=testWorkflow.id, fileid=testFileB['id'], runLumi=Run(1, *[46])) self.assertFalse(testWU1.exists(), "WorkUnit exists before job was created") self.assertFalse(testWU2.exists(), "WorkUnit exists before job was created") testJob.create(group=testJobGroup) self.assertTrue(testWU1.exists(), "WorkUnit does not exist after job was created") self.assertTrue(testWU2.exists(), "WorkUnit does not exist after job was created") testJob.delete() self.assertTrue(testWU1.exists(), "WorkUnit does not exist after job is deleted") self.assertTrue(testWU2.exists(), "WorkUnit does not exist after job is deleted") testWorkflow.delete() self.assertFalse(testWU1.exists(), "WorkUnit exists after workflow is deleted") self.assertFalse(testWU2.exists(), "WorkUnit exists after workflow is deleted") return
def testDeleteTransaction(self): """ _testDeleteTransaction_ Create a JobGroup and then commit it to the database. Begin a transaction and the delete the JobGroup from the database. Using the exists() method verify that the JobGroup is not in the database. Finally, roll back the transaction and verify that the JobGroup is in the database. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task="Test") testWorkflow.create() testFileset = WMBSFileset(name="TestFileset") testFileset.create() testSubscription = Subscription(fileset=testFileset, workflow=testWorkflow) testSubscription.create() testJobGroup = JobGroup(subscription=testSubscription) self.assertFalse(testJobGroup.exists()) testJobGroup.create() self.assertTrue(testJobGroup.exists()) myThread = threading.currentThread() myThread.transaction.begin() testJobGroup.delete() self.assertFalse(testJobGroup.exists()) myThread.transaction.rollback() self.assertTrue(testJobGroup.exists()) testSubscription.delete() testFileset.delete() testWorkflow.delete() return
def testDeleteTransaction(self): """ _testDeleteTransaction_ Create a workflow and commit it to the database. Begin a transaction and delete the workflow, then rollback the transaction. Use the workflow's exists() method to verify that the workflow doesn't exist in the database before create() is called, it does exist after create() is called, it doesn't exist after delete() is called and it does exist after the transaction is rolled back. """ testWorkflow = Workflow(spec="spec.xml", owner="Simon", name="wf001", task='Test') self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists before it was created") testWorkflow.create() self.assertTrue( testWorkflow.exists() > 0, "ERROR: Workflow does not exist after it has been created") myThread = threading.currentThread() myThread.transaction.begin() testWorkflow.delete() self.assertEqual(testWorkflow.exists(), False, "ERROR: Workflow exists after it has been deleted") myThread.transaction.rollback() self.assertTrue( testWorkflow.exists() > 0, "ERROR: Workflow does not exist transaction was rolled back") return
def testCreateLoadWithUserAtt(self): """ _testLoad_ Create a workflow and then try to load it from the database using the following load methods: Workflow.LoadFromNameAndTask Workflow.LoadFromID Workflow.LoadFromSpecOwner Test if the Workflow is created correctly. """ testWorkflowA = Workflow(spec="spec.xml", owner="Simon", owner_vogroup='integration', owner_vorole='priority', name="wf001", task='Test', wfType="ReReco") testWorkflowA.create() testWorkflowB = Workflow(name="wf001", task='Test') testWorkflowB.load() self.assertTrue((testWorkflowA.id == testWorkflowB.id) and (testWorkflowA.name == testWorkflowB.name) and (testWorkflowA.spec == testWorkflowB.spec) and (testWorkflowA.task == testWorkflowB.task) and (testWorkflowA.wfType == testWorkflowB.wfType) and (testWorkflowA.owner == testWorkflowB.owner), "ERROR: Workflow.LoadFromNameAndTask Failed") testWorkflowC = Workflow(id=testWorkflowA.id) testWorkflowC.load() self.assertTrue((testWorkflowA.id == testWorkflowC.id) and (testWorkflowA.name == testWorkflowC.name) and (testWorkflowA.spec == testWorkflowC.spec) and (testWorkflowA.task == testWorkflowC.task) and (testWorkflowA.wfType == testWorkflowC.wfType) and (testWorkflowA.owner == testWorkflowC.owner), "ERROR: Workflow.LoadFromID Failed") testWorkflowD = Workflow(spec="spec.xml", owner="Simon", task='Test') testWorkflowD.load() self.assertTrue((testWorkflowA.id == testWorkflowD.id) and (testWorkflowA.name == testWorkflowD.name) and (testWorkflowA.spec == testWorkflowD.spec) and (testWorkflowA.task == testWorkflowD.task) and (testWorkflowA.wfType == testWorkflowD.wfType) and (testWorkflowA.owner == testWorkflowD.owner), "ERROR: Workflow.LoadFromSpecOwner Failed") testWorkflowE = Workflow(spec="spec_1.xml", owner="Simon", owner_vogroup='t1access', owner_vorole='t1access', name="wf002", task='Test_1', wfType="ReReco") testWorkflowE.create() self.assertTrue((testWorkflowE.id != testWorkflowA.id) and (testWorkflowE.name != testWorkflowA.name) and (testWorkflowE.spec != testWorkflowA.spec) and (testWorkflowE.vogroup != testWorkflowA.vogroup) and (testWorkflowE.vorole != testWorkflowA.vorole) and (testWorkflowE.task != testWorkflowA.task) and (testWorkflowE.wfType == testWorkflowA.wfType) and (testWorkflowE.owner == testWorkflowA.owner), "ERROR: Workflow.LoadFromSpecOwner Failed") testWorkflowA.delete() return
def testCreateLoadWithUserAtt(self): """ _testLoad_ Create a workflow and then try to load it from the database using the following load methods: Workflow.LoadFromName Workflow.LoadFromID Workflow.LoadFromSpecOwner Test if the Workflow is created correctly. """ testWorkflowA = Workflow(spec="spec.xml", owner="Simon", owner_vogroup='integration', owner_vorole='priority', name="wf001", task='Test', wfType="ReReco") testWorkflowA.create() testWorkflowB = Workflow(name="wf001", task='Test') testWorkflowB.load() self.assertTrue((testWorkflowA.id == testWorkflowB.id) and (testWorkflowA.name == testWorkflowB.name) and (testWorkflowA.spec == testWorkflowB.spec) and (testWorkflowA.task == testWorkflowB.task) and (testWorkflowA.wfType == testWorkflowB.wfType) and (testWorkflowA.owner == testWorkflowB.owner), "ERROR: Workflow.LoadFromName Failed") testWorkflowC = Workflow(id=testWorkflowA.id) testWorkflowC.load() self.assertTrue((testWorkflowA.id == testWorkflowC.id) and (testWorkflowA.name == testWorkflowC.name) and (testWorkflowA.spec == testWorkflowC.spec) and (testWorkflowA.task == testWorkflowC.task) and (testWorkflowA.wfType == testWorkflowC.wfType) and (testWorkflowA.owner == testWorkflowC.owner), "ERROR: Workflow.LoadFromID Failed") testWorkflowD = Workflow(spec="spec.xml", owner="Simon", task='Test') testWorkflowD.load() self.assertTrue((testWorkflowA.id == testWorkflowD.id) and (testWorkflowA.name == testWorkflowD.name) and (testWorkflowA.spec == testWorkflowD.spec) and (testWorkflowA.task == testWorkflowD.task) and (testWorkflowA.wfType == testWorkflowD.wfType) and (testWorkflowA.owner == testWorkflowD.owner), "ERROR: Workflow.LoadFromSpecOwner Failed") testWorkflowE = Workflow(spec="spec_1.xml", owner="Simon", owner_vogroup='t1access', owner_vorole='t1access', name="wf002", task='Test_1', wfType="ReReco") testWorkflowE.create() self.assertTrue((testWorkflowE.id != testWorkflowA.id) and (testWorkflowE.name != testWorkflowA.name) and (testWorkflowE.spec != testWorkflowA.spec) and (testWorkflowE.vogroup != testWorkflowA.vogroup) and (testWorkflowE.vorole != testWorkflowA.vorole) and (testWorkflowE.task != testWorkflowA.task) and (testWorkflowE.wfType == testWorkflowA.wfType) and (testWorkflowE.owner == testWorkflowA.owner), "ERROR: Workflow.LoadFromSpecOwner Failed") testWorkflowA.delete() return