示例#1
0
 def test_valid_write_SyncData(self) :
     """
         Write out a valid file - should be no exceptions
     """
     sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     sync_data.set_last_stored()
     self.assertIsNone(None)
示例#2
0
def run_originator_tests(hostname, testdir) :
    """
    hostname - us
    testlist - contains details of the tests to be run
    
    pick out those tests that apply and generate/update the file
    """

    logging.debug('sync_tests.py::run_originator_tests -> %s', hostname)

    # Run through the list and look for ones applicable to this host
    for testname, sync_test in testdir.items():
        try:
            logging.debug('checking %s -> %s', testname, sync_test)
            
            if hostname == sync_test.origination_host :
                # We've found one - update the status
                logging.info('Updating source for %s', sync_test.testname)
                sync_data = SyncData(
                    hostname,
                    sync_test.origination_path,
                    sync_test.testname )
                
                # @todo determin whether to add a reverse check option for
                # syncs rather than backups
                sync_data.set_last_stored()
        except UtilError as util_error :
            logging.error('run_originator_test - failed -> %s\n%s',
                          str(util_error), str(sync_test))
示例#3
0
 def test_corrupted_salt_SyncData(self):
     """ Corrupt the salt before writing
     """
     sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     sync_data.salt = CORRUPT_SALT
     sync_data.set_last_stored()
     self.assertRaises(UtilError, SyncData,
                       host = HOST_NAME,
                       dir_path = GOOD_TEST_PATH,
                       testname = TEST_NAME)
示例#4
0
    def test_good_write1_SyncData(self) :
        """ Write a good file based on last_stored and check its restored ok
        """
        sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
        sync_data.set_last_stored()

        last_stored = sync_data.last_stored

        sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
        self.assertEquals(last_stored, sync_data.last_stored)
示例#5
0
    def test_delay_SyncData(self) :
        """ Check that delay value is set correctly
        """
        sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)

        self.assertEquals(sync_data.delay(), 0)
        
        sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
        sync_data.set_last_stored()
        
        sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
        self.assertNotEquals(sync_data.delay(), 0)
示例#6
0
 def test_clockdrift_SyncData(self) :
     """ Check that delay checks are properly implemented
     """
     sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     sync_data.set_last_stored()
     
     sync_data.last_stored = sync_data.last_stored + GOOD_DIFF_TIME
     sync_data.variable = sync_data.last_stored
     sync_data.write()
     
     sync_data = SyncData(
         HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     self.assertEquals(sync_data.is_sync_late(2),
                       POTENTIAL_CLOCK_DRIFT)
示例#7
0
 def test_islate_SyncData(self) :
     """ Check that delay checks are properly implemented
     """
     sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     self.assertEquals(sync_data.is_sync_late(2), SYNC_LATE)
     
     sync_data.set_last_stored()
     
     self.assertEquals(sync_data.is_sync_late(2), SYNC_OK)
     
     sync_data.last_stored = sync_data.last_stored - GOOD_DIFF_TIME
     sync_data.variable = sync_data.last_stored
     sync_data.write()
     
     sync_data = SyncData(
         HOST_NAME, GOOD_TEST_PATH, TEST_NAME)
     self.assertEquals(sync_data.is_sync_late(1.9), SYNC_LATE)
示例#8
0
def generate_status_file(testname, host, source_file) :
    """
    update the status file
    """

    logging.debug('Set status for %s@%s -> %s', testname, host, source_file)

    ret_code = 0

    try:
        sync = SyncData(source_file)
        sync.set_last_stored()
    except UtilError as e:
        logging.error('run_test_part1 (%s@%s) - status update failed -> %s',
                      testname, host, str(e))
        ret_code = -1

    return ret_code