s3-pit-restore
s3-pit-restore copied to clipboard
Avoid duplicate with testcase
This is the addition to the PR - #10 Added test case over the existing commit.
I just ran a test of this an it worked as expected. Here's the steps I followed:
- Upload 9 files to my bucket with versioning enabled at 11:45
- Wait one minute
- Delete one file
- Upload a 10th file
- Run
s3-pit-restore -b bucketname -B bucketname -t "11:46:00 14-02-2022 +0" --avoid-duplicates
- Result: The deleted file is restored, the extra file is set to a delete marker. All other files are left as a single version. Only the changed files are output.
We are working with buckets holding 4 million objects and 6TB of data, so this feature is an absolute must for us. Thank you for working on it!
@marxjohnson Could you also do a run of the software testing suite?
I ran:
py ./s3-pit-restore -b mj5982-pit -B mj5982-pit -P restore-path --test
And I got:
======================================================================
FAIL: test_avoid_duplicates (__main__.TestS3PitRestore)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\mj5982\src\s3-pit-restore\s3-pit-restore", line 257, in test_avoid_duplicates
self.assertTrue(self.compare_versions(version_before, version_after))
AssertionError: False is not true
----------------------------------------------------------------------
Ran 3 tests in 273.167s
FAILED (failures=1)
So something might not be quite right there. @vikas-nautiyal Any thoughts on why it's failing?
@marxjohnson could you do a test run with the testing suite?
Hi @marxjohnson, added a fix to the code. It was failing because the -P
option would restore the files in a different directory i.e dest_prefix
. added fix to verify if the restore directory is different than the root of the bucket and act accordingly.
@vikas-nautiyal could you rebase the MR, I'll have a run and merge if it's ok. Thanks!
@vikas-nautiyal It would be nice if you could rebase this PR resolving conflicts so I can merge it. Thanks!