def test_delete_old_indices_other_indices_are_not_deleted(self): """Verify that non-week-based indices are not removed""" # Create a temporary index. self.index_creator.create_index('socorro_test_temp', {}) api = IndexCleaner(self.config) api.delete_old_indices() # Verify the email index is still there. assert self.index_client.exists('socorro_test_temp')
def test_delete_old_indices_other_indices_are_not_deleted(self): """Verify that non-week-based indices are not removed. """ # Create a temporary index. self.index_creator.create_index('socorro_test_temp', {}) api = IndexCleaner(self.config) api.delete_old_indices() # Verify the email index is still there. assert self.index_client.exists('socorro_test_temp')
def test_delete_old_indices(self): # Create old indices to be deleted. self.index_client.create('socorro200142', {}) self.indices.append('socorro200142') self.index_client.create('socorro200000', {}) self.indices.append('socorro200000') # Create an old aliased index. self.index_client.create('socorro200201_20030101', {}) self.indices.append('socorro200201_20030101') self.index_client.put_alias( index='socorro200201_20030101', name='socorro200201', ) # Create a recent aliased index. last_week_index = self.get_index_for_date( utc_now() - datetime.timedelta(weeks=1) ) self.index_client.create('socorro_some_aliased_index', {}) self.indices.append('socorro_some_aliased_index') self.index_client.put_alias( index='socorro_some_aliased_index', name=last_week_index, ) # Create a recent index that should not be deleted. now_index = self.get_index_for_date(utc_now()) self.index_client.create(now_index, {}) self.indices.append(now_index) # These will raise an error if an index was not correctly created. assert self.index_client.exists('socorro200142') assert self.index_client.exists('socorro200000') assert self.index_client.exists('socorro200201') assert self.index_client.exists(now_index) assert self.index_client.exists(last_week_index) api = IndexCleaner(self.config) api.delete_old_indices() # Verify the recent index is still there. ok_(self.index_client.exists(now_index)) ok_(self.index_client.exists(last_week_index)) # Verify the old indices are gone. ok_(not self.index_client.exists('socorro200142')) ok_(not self.index_client.exists('socorro200000')) ok_(not self.index_client.exists('socorro200201'))
def test_other_indices_are_not_deleted(self): """Verify that non-week-based indices are not removed. For example, the socorro_email index should not be deleted by the cron job. """ # Create the socorro emails index. self.index_creator.create_emails_index() self.indices.append('socorro_emails') assert self.index_client.exists('socorro_emails') api = IndexCleaner(self.config) api.delete_old_indices() # Verify the email index is still there. ok_(self.index_client.exists('socorro_emails'))