Beispiel #1
0
 def latest_backup_timestamp(self, fileset, is_full):
     """Return the timestamp for the latest backup for a given fileset."""
     existing_blobs_dict = self.existing_backups_for_fileset(
         fileset=fileset, is_full=is_full)
     if not existing_blobs_dict.keys():
         return "19000101_000000"
     return Timing.sort(existing_blobs_dict.keys())[-1:][0]
Beispiel #2
0
 def test_sort(self):
     """Test sort."""
     self.assertEqual(
         Timing.sort(['20180110_120000', '20180105_120000', '20180101_120000']),
         ['20180101_120000', '20180105_120000', '20180110_120000'])
     self.assertEqual(
         Timing.sort(
             ['20180105_120000', '20180110_120000', '20180105_120000', '20180101_120000']),
         ['20180101_120000', '20180105_120000', '20180105_120000', '20180110_120000'])
     pick_start_date = lambda x: x["start_date"]
     self.assertEqual(
         Timing.sort(
             times=self.__recovery_sample_data(),
             selector=pick_start_date),
         [
             {'is_full': True,  'start_date': '20180101_010000'},
             {'is_full': True,  'start_date': '20180101_010000'},
             {'is_full': True,  'start_date': '20180101_010000'},
             {'is_full': False, 'start_date': '20180101_011000'},
             {'is_full': False, 'start_date': '20180101_012000'},
             {'is_full': False, 'start_date': '20180101_013000'},
             {'is_full': True,  'start_date': '20180101_014000'},
             {'is_full': True,  'start_date': '20180101_014000'},
             {'is_full': True,  'start_date': '20180101_014000'},
             {'is_full': False, 'start_date': '20180101_015000'},
             {'is_full': False, 'start_date': '20180101_020000'},
             {'is_full': False, 'start_date': '20180101_021000'},
             {'is_full': False, 'start_date': '20180101_021000'},
             {'is_full': True,  'start_date': '20180101_022000'},
             {'is_full': True,  'start_date': '20180101_022000'},
             {'is_full': True,  'start_date': '20180101_022000'},
             {'is_full': False, 'start_date': '20180101_023000'},
             {'is_full': False, 'start_date': '20180101_024000'},
             {'is_full': False, 'start_date': '20180101_025000'},
             {'is_full': True,  'start_date': '20180101_030000'},
             {'is_full': True,  'start_date': '20180101_030000'},
             {'is_full': True,  'start_date': '20180101_030000'},
             {'is_full': False, 'start_date': '20180101_031000'},
             {'is_full': False, 'start_date': '20180101_032000'},
             {'is_full': False, 'start_date': '20180101_032000'},
             {'is_full': False, 'start_date': '20180101_033000'}
         ])
     self.assertEquals(
         map(pick_start_date, Timing.sort(times=self.__recovery_sample_data(), selector=pick_start_date)),
         ['20180101_010000', '20180101_010000', '20180101_010000', '20180101_011000', '20180101_012000', '20180101_013000', '20180101_014000', '20180101_014000', '20180101_014000', '20180101_015000', '20180101_020000', '20180101_021000', '20180101_021000', '20180101_022000', '20180101_022000', '20180101_022000', '20180101_023000', '20180101_024000', '20180101_025000', '20180101_030000', '20180101_030000', '20180101_030000', '20180101_031000', '20180101_032000', '20180101_032000', '20180101_033000'])