Example #1
0
 def test_checkpoint002_no_db_add_one(self):
     ''' 002: Check that a single event checkpoint works '''
     checkpoint_mgr = get_service(SERVICE_CHECKPOINT_MGR)
     self.assertNotEqual(checkpoint_mgr, None)
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 0)
     # Create a new checkpoint 
     k_ckpt = EventCheckpoint('test')
     # Validate it got created correctly 
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 1)
     self.assertEqual(k_ckpt.name, 'test')
     self.assertEqual(k_ckpt.get_status(), CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k_ckpt.status, CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k_ckpt.start_rec_id, None)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (None,'recovery'))
     # Set the status and check it got set
     k_ckpt.set_status(CHECKPOINT_STATUS_FAILED)
     self.assertEqual(k_ckpt.get_status(), CHECKPOINT_STATUS_FAILED)
     # Set the checkpoint and check it got set
     k_ckpt.set_checkpoint(345)
     self.assertEqual(k_ckpt.get_checkpoint(), (345, None))
     self.assertEqual(k_ckpt.start_rec_id, 345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (345, 'recovery'))
     k_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(k_ckpt.get_checkpoint(), (123, 'data'))
     self.assertEqual(k_ckpt.start_rec_id, 123)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (123, 'recovery'))
     # Delete the checkpoint and check 
     k_ckpt.delete()
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 0)
     self.assertEqual(k_ckpt.status, CHECKPOINT_STATUS_DELETED)
     self.assertEqual(k_ckpt.start_rec_id, None)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (None, 'recovery'))
     return 
Example #2
0
 def test_checkpoint_fail003_deleted_checkpoint(self):
     ''' Fail 003: Check bad restart mode caught when overriding on get start event '''
     teal = Teal('data/checkpoint_test/noop_monitor.conf','stderr',msgLevel=self.msglevel, commit_checkpoints=False)
     #checkpoint_mgr = get_service(SERVICE_CHECKPOINT_MGR)
     k1_ckpt = EventCheckpoint('deltest1')
     k1_ckpt.set_checkpoint(123, 'data')
     k1_ckpt.delete()
     # Make sure can't get at stuff
     self.assertEqual(k1_ckpt.get_status(), CHECKPOINT_STATUS_DELETED)
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_status(CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k1_ckpt.get_status(), CHECKPOINT_STATUS_DELETED)
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(555, 'moredata')
     self.assertEqual(k1_ckpt.get_status(), CHECKPOINT_STATUS_DELETED)
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     teal.shutdown()
     return
Example #3
0
 def test_checkpoint003_no_db_add_two(self):
     ''' 003: Check that two event checkpoints work '''
     checkpoint_mgr = get_service(SERVICE_CHECKPOINT_MGR)
     k1_ckpt = EventCheckpoint('test1')
     k2_ckpt = EventCheckpoint('test2')
     # Validate it got created correctly 
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 2)
     self.assertEqual(k1_ckpt.name, 'test1')
     self.assertEqual(k1_ckpt.get_status(), CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k1_ckpt.status, CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k1_ckpt.start_rec_id, None)
     self.assertEqual(k2_ckpt.name, 'test2')
     self.assertEqual(k2_ckpt.get_status(), CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k2_ckpt.status, CHECKPOINT_STATUS_RUNNING)
     self.assertEqual(k2_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k2_ckpt.start_rec_id, None)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (None, 'recovery'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='begin'), (0, 'begin'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='now'), (None, 'now'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='lastproc'), (None, 'lastproc'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='recovery'), (None, 'recovery'))
     # Set the checkpoint and check it got set
     k1_ckpt.set_checkpoint(345)
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     self.assertEqual(k1_ckpt.start_rec_id, 345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (345, 'recovery'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     k1_ckpt.set_checkpoint(345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='begin'), (0, 'begin'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='now'), (None, 'now'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='lastproc'), (345, 'lastproc'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='recovery'), (345, 'recovery'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(k2_ckpt.get_checkpoint(), (123, 'data'))
     self.assertEqual(k2_ckpt.start_rec_id, 123)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (123, 'recovery'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     self.assertEqual(k2_ckpt.get_checkpoint(), (123, 'data'))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='begin'), (0, 'begin'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k2_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='now'), (None, 'now'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k2_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='lastproc'), (345, 'lastproc'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (None, None))
     self.assertEqual(k2_ckpt.get_checkpoint(), (None, None))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='recovery'), (123, 'recovery'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     self.assertEqual(k2_ckpt.get_checkpoint(), (123, 'data'))
     k1_ckpt.set_checkpoint(345)
     k2_ckpt.set_checkpoint(123, 'data')
     # Delete the checkpoint and check 
     k2_ckpt.delete()
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 1)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (345, 'recovery'))
     self.assertEqual(k1_ckpt.get_checkpoint(), (345, None))
     self.assertEqual(k2_ckpt.status, CHECKPOINT_STATUS_DELETED)
     self.assertEqual(k2_ckpt.start_rec_id, None)
     k1_ckpt.delete()
     self.assertEqual(len(checkpoint_mgr.event_checkpoints), 0)
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(), (None, 'recovery'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='begin'), (0, 'begin'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='now'), (None, 'now'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='lastproc'), (None, 'lastproc'))
     self.assertEqual(checkpoint_mgr.get_starting_event_rec_id(override_restart_mode='recovery'), (None, 'recovery'))
     return