-
Notifications
You must be signed in to change notification settings - Fork 264
Performance: Keep collections and indexes between GridFS tests #1421
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
Changes from all commits
1d831e2
71c286e
3c5819a
e318798
0365984
3f65868
71c313e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -814,9 +814,22 @@ public function testUploadingFirstFileCreatesIndexes(): void | |
|
||
public function testExistingIndexIsReused(): void | ||
{ | ||
// The collections may exist from other tests, ensure they are removed | ||
// before and after to avoid potential conflicts. | ||
$this->dropCollection($this->getDatabaseName(), 'fs.chunks'); | ||
$this->dropCollection($this->getDatabaseName(), 'fs.files'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious about the mixed use of @alcaeus: it looks like you added this in 79c2993 for PHPLIB-522 ("loosening index equality checks"). Assuming this is still relevant, is there a short comment we can add here explaining what's being tested? I don't think Maybe a multi-line comment:
I'm also curious if there should have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this is admittedly unrelated from this PR, so feel free to disregard. I can also address this in a separate PR myself, but wanted to ask for some context first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a comment and assertions on index existence. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oof, trying to think back to it. I believe the issue was that the shell used slightly different index settings, resulting in valid indexes that weren't recognised. It may have been an issue with using a double for the index direction instead of an int. I don't remember precisely though, indicating that I should've left a comment at the time. |
||
// Create indexes with different numeric types before interacting with | ||
// GridFS to assert that the library respects the existing indexes and | ||
// does not attempt to create its own. | ||
$this->filesCollection->createIndex(['filename' => 1.0, 'uploadDate' => 1], ['name' => 'test']); | ||
$this->chunksCollection->createIndex(['files_id' => 1.0, 'n' => 1], ['name' => 'test', 'unique' => true]); | ||
|
||
$this->assertIndexExists('fs.files', 'test'); | ||
$this->assertIndexExists('fs.chunks', 'test', function (IndexInfo $info): void { | ||
$this->assertTrue($info->isUnique()); | ||
}); | ||
|
||
$this->bucket->uploadFromStream('filename', self::createStream('foo')); | ||
|
||
$this->assertIndexNotExists($this->filesCollection->getCollectionName(), 'filename_1_uploadDate_1'); | ||
|
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.
By calling
dropCollection
, the collection is also removed ontearDown
.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.
My suggestion to explain the optimization in a comment within
tearDown()
would pair nicely with this comment.