You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
242: Make import command resumabe r=brunoocasali a=mkilmanas
# Pull Request
Make it possible to resume import from a mid-point after unsuccessful previous import
## Related issue
Fixes#241
## What does this PR do?
- Makes import resumable:
- Introduce `--skip-batches` parameter
- Enforce entity sorting by primary key (consistent, fast)
- Display the number of processed entities
- Add test case
- Other small improvements:
- Clarify wording of the message telling the number of indexed records
- Update existing tests for modified messages
## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?
Co-authored-by: Marijus Kilmanas <[email protected]>
Copy file name to clipboardExpand all lines: tests/Integration/CommandsTest.php
+46-23Lines changed: 46 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -74,25 +74,25 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
74
74
75
75
$this->assertSame(<<<'EOD'
76
76
Importing for index Meilisearch\Bundle\Tests\Entity\Post
77
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index
78
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index
77
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index (6 indexed since start)
78
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index (6 indexed since start)
79
79
Settings updated.
80
80
Settings updated.
81
81
Settings updated.
82
82
Importing for index Meilisearch\Bundle\Tests\Entity\Comment
83
83
Importing for index Meilisearch\Bundle\Tests\Entity\Tag
84
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index
85
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__aggregated index
84
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index (6 indexed since start)
85
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__aggregated index (6 indexed since start)
86
86
Importing for index Meilisearch\Bundle\Tests\Entity\Link
87
87
Importing for index Meilisearch\Bundle\Tests\Entity\Page
88
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
88
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (6 indexed since start)
89
89
Importing for index Meilisearch\Bundle\Tests\Entity\SelfNormalizable
90
90
Importing for index Meilisearch\Bundle\Tests\Entity\Post
91
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index
92
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index
91
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index (6 indexed since start)
92
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index (6 indexed since start)
93
93
Importing for index Meilisearch\Bundle\Tests\Entity\Tag
94
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index
95
-
Indexed 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__aggregated index
94
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index (6 indexed since start)
95
+
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__aggregated index (6 indexed since start)
96
96
Done!
97
97
98
98
EOD, $importOutput);
@@ -150,12 +150,12 @@ public function testSearchImportWithCustomBatchSize(): void
150
150
151
151
$this->assertSame(<<<'EOD'
152
152
Importing for index Meilisearch\Bundle\Tests\Entity\Page
153
-
Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
154
-
Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
155
-
Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
156
-
Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
157
-
Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
158
-
Indexed 1 / 1 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index
153
+
Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (2 indexed since start)
154
+
Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (4 indexed since start)
155
+
Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (6 indexed since start)
156
+
Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (8 indexed since start)
157
+
Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (10 indexed since start)
158
+
Indexed a batch of 1 / 1 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (11 indexed since start)
159
159
Done!
160
160
161
161
EOD, $importOutput);
@@ -176,7 +176,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
176
176
$output = $importCommandTester->getDisplay();
177
177
178
178
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Page', $output);
179
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index', $output);
179
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index ('.$i.' indexed since start)', $output);
@@ -197,7 +197,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
197
197
$output = $importCommandTester->getDisplay();
198
198
199
199
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Page', $output);
200
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index', $output);
200
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index ('.$i.' indexed since start)', $output);
@@ -221,8 +221,8 @@ public function testImportDifferentEntitiesIntoSameIndex(): void
221
221
222
222
$output = $commandTester->getDisplay();
223
223
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Tag', $output);
224
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index', $output);
225
-
$this->assertStringContainsString('Indexed 2 / 2 Meilisearch\Bundle\Tests\Entity\Link entities into sf_phpunit__tags index', $output);
224
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index ('.$i.' indexed since start)', $output);
225
+
$this->assertStringContainsString('Indexed a batch of 2 / 2 Meilisearch\Bundle\Tests\Entity\Link entities into sf_phpunit__tags index (2 indexed since start)', $output);
@@ -245,7 +245,30 @@ public function testSearchImportAggregator(): void
245
245
246
246
$output = $commandTester->getDisplay();
247
247
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Post', $output);
248
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
248
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index ('.$i.' indexed since start)', $output);
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Page', $output);
269
+
$this->assertStringContainsString('Skipping first 2 batches (6 records)', $output);
270
+
$this->assertStringContainsString('Indexed a batch of 3 / 3 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (3 indexed since start)', $output);
271
+
$this->assertStringContainsString('Indexed a batch of 1 / 1 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (4 indexed since start)', $output);
@@ -264,7 +287,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
264
287
265
288
$output = $commandTester->getDisplay();
266
289
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Post', $output);
267
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
290
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index ('.$i.' indexed since start)', $output);
@@ -283,7 +306,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
283
306
284
307
$output = $commandTester->getDisplay();
285
308
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Post', $output);
286
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
309
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index ('.$i.' indexed since start)', $output);
Copy file name to clipboardExpand all lines: tests/Integration/SearchTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -69,10 +69,10 @@ public function testSearchImportAggregator(): void
69
69
70
70
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Post', $output);
71
71
$this->assertStringContainsString('Importing for index Meilisearch\Bundle\Tests\Entity\Tag', $output);
72
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index', $output);
73
-
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
74
-
$this->assertStringContainsString('Indexed 1 / 1 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index', $output);
75
-
$this->assertStringContainsString('Indexed 1 / 1 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__'.self::$indexName.' index', $output);
72
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index ('.$i.' indexed since start)', $output);
73
+
$this->assertStringContainsString('Indexed a batch of '.$i.' / '.$i.' Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__'.self::$indexName.' index ('.$i.' indexed since start)', $output);
74
+
$this->assertStringContainsString('Indexed a batch of 1 / 1 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index (1 indexed since start)', $output);
75
+
$this->assertStringContainsString('Indexed a batch of 1 / 1 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__'.self::$indexName.' index (1 indexed since start)', $output);
0 commit comments