Skip to content

Commit

Permalink
tests: Cleanup local meta2 copies after lifecycle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-p authored and AymericDu committed Mar 5, 2025
1 parent 792f472 commit a0f8526
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/functional/crawler/lifecycle/test_lifecycle_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
import json
import os
import time
from datetime import datetime
from enum import Enum
Expand Down Expand Up @@ -115,6 +116,7 @@ def setUp(self):
M2_PROP_BUCKET_NAME: self.container,
M2_PROP_LIFECYCLE_TIME_BYPASS: "1",
}
self.local_copies = []
self.containers_to_process = []
# Create containers
for container in (self.container, self.container_segment):
Expand Down Expand Up @@ -143,6 +145,17 @@ def setUp(self):

self.wait_for_score(("meta2",), score_threshold=2)

def tearDown(self):

for db_copy in self.local_copies:
try:
os.remove(db_copy)
except Exception as exc:
self.logger.error(
"Failed to remove local copy %s, reason: %s", db_copy, exc
)
super().tearDown()

def _wait_n_days(self, days):
wait = days * 86400 / self.TIME_FACTOR
time.sleep(wait)
Expand Down Expand Up @@ -257,6 +270,7 @@ def _make_local_copy(
if create_copy:
# Request a local copy of the meta2 database
self.admin.copy_base_local(**params)
self.local_copies.append(meta2db_env["path"])

def _get_meta2db_env(self, cid):
services = self.conscience.all_services("meta2")
Expand Down Expand Up @@ -1638,7 +1652,7 @@ def callback(status, _msg):
"Status": "Enabled",
"Filter": {"Prefix": "doc/"},
"NoncurrentVersionExpiration": {
"0": {"NoncurrentDays": 2},
"0": {"NoncurrentDays": 3},
"__time_type": "NoncurrentDays",
},
},
Expand Down

0 comments on commit a0f8526

Please sign in to comment.