-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove pagination from the repair step #30989
Conversation
Please add a unit test that proves that it works. The test should fail without this commit. You could add an attribute to set pagination to smaller values if it makes it easier to test. |
|
f8e668b
to
12b0d54
Compare
Codecov Report
@@ Coverage Diff @@
## master #30989 +/- ##
============================================
+ Coverage 62.3% 62.45% +0.14%
- Complexity 18208 18229 +21
============================================
Files 1142 1145 +3
Lines 68229 68275 +46
Branches 1234 1234
============================================
+ Hits 42511 42641 +130
+ Misses 25357 25273 -84
Partials 361 361
Continue to review full report at Codecov.
|
Added unit tests:
Will see how the tests progress in the CI. |
c8f303f
to
25a6225
Compare
* This test will have more orphan shares and will check if the repair | ||
* test is working properly. | ||
*/ | ||
public function testOrphanSharesFailsWithPagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test is only testing pagination itself, not a failure
71d3fe2
to
63ab8a4
Compare
958c7aa
to
11b82ee
Compare
$this->missingParents->where($this->missingParents->expr()->isNotNull('parent')); | ||
$this->missingParents->andWhere($this->missingParents->expr()->notIn('parent', $this->missingParents->createFunction($qb->getSQL()))); | ||
$this->missingParents->andWhere($this->missingParents->createFunction('NOT EXISTS (' . $qb->getSQL() . ')')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated query builder from -> #30989 (comment).
Also resumed $this->deleteOrphanReshares
( which was omitted in the previous version of the PR).
//Check if the row is there before deleting | ||
$result = $qb->select('id') | ||
->from('share') | ||
->where($qb->expr()->eq('id', $qb->createNamedParameter($randomRow + $pareReshareCountRest))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very unreliable and will likely not work on Oracle: please store the ids of all inserted entries from the above query and then delete a few selected ones.
you cannot assume that the share ids will start at 1 here as not all DBs reset their autoincrement to zero
please implement this in a proper way.
also see owncloud-archive/documentation#3805 (comment) when retrieving inserted ids
'stime' => $qb->expr()->literal($time), | ||
]) | ||
->execute(); | ||
if (($parentReshareCount - $pareReshareCountRest) >= 3000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ?
$randomRow++; | ||
} | ||
|
||
//Now run the repair step and prove that this test fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, we don't prove that a test fail. a test must always pass.
what I said about failing tests is based on Test Driven Development (TDD) where you first write a test that reproduces an issue. the test will fail at first and then you implement the code to make it pass.
it doesn't mean that the test exists to prove that something fails
$this->assertTrue($testFail); | ||
} | ||
|
||
public function mockRepairOrphanShareMethodWithPagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks wrong as you reimplemented the same code as the repair step
a much better approach is to keep track of what entries you "destroyed" when creating your test set and then writing a query that checks that exactly these entries were cleant up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example if your test code destroyed the parents of the share ids 5, 15, 18 then in your assertion code after running the repair step, you'll query whether the sub-shares with parents 5, 15 and 18 are gone.
this is better than using count. Maybe we should move away from just counting as it's not accurate enough.
6edd6ec
to
5ee7920
Compare
We need to consider following PR's: The backport PR should be considered last: #31004 |
The pagination is not required as the rows are deleted during the operation. Signed-off-by: Sujith H <[email protected]>
5ee7920
to
8fb942f
Compare
Added commit: #31014 to this PR. |
@@ -286,4 +286,128 @@ public function testLargeSharesWithOrphans() { | |||
} while(count($results) > 0); | |||
$this->assertEquals($totalParents - 20, $result); | |||
} | |||
|
|||
/** | |||
* A new approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the approach is not new, this is "the" approach
if you want to write "new approach" the text needs to be in the PR comment
please replace the comment with whatever the test is testing
what does "no more pagination" means ? no more compared to what ?
} | ||
|
||
//Lets check rance of 1 to 9 | ||
foreach (range(1, 9) as $adminIndex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like the same loop code like line 391, maybe you can put these together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention here was to see the first 9 indexes are there or not. A proof that first 9 parents are not deleted according to the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the duplicated code and updated with a loop so that it look better. So if one has to check if the index is there or not in this large scenario, appending the array $checkRandomAvailableEntries
is enough.
/** | ||
* A new approach | ||
*/ | ||
public function testOrphanSharesNoMorePagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test is not testing a code change, it's testing a behavior: what behavior are you testing ?
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
8fb942f
to
14edb80
Compare
@PVince81 Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@sharidas please backport as part of #30653 (comment), all in a single PR |
Updated the backport PR : #31004 to a single PR. It includes the changes we have made so far mentioned here... #30653 (comment) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The pagination is not required as the
rows are deleted during the operation.
Signed-off-by: Sujith H [email protected]
Description
The pagination should be removed from this repair step. Because if the pagination is there, then the changes will not be taken after the first removal in the loop. The second iteration might omit changes which have broken links.
Related Issue
#30653 (comment)
Motivation and Context
If the rows are deleted on the fly, then its better to avoid pagination and use the pagelimit .
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: