@@ -22,18 +22,20 @@ import {
2222 readLog ,
2323 clearLog ,
2424 currentVersion ,
25+ nextMinor ,
2526} from '../kibana_migrator_test_kit' ;
2627import {
28+ BASELINE_COMPLEX_DOCUMENTS_500K_AFTER ,
2729 BASELINE_DOCUMENTS_PER_TYPE_500K ,
2830 BASELINE_TEST_ARCHIVE_500K ,
2931} from '../kibana_migrator_archive_utils' ;
3032import {
31- baselineTypes ,
3233 getReindexingBaselineTypes ,
3334 getReindexingMigratorTestKit ,
3435 getUpToDateMigratorTestKit ,
3536} from '../kibana_migrator_test_kit.fixtures' ;
3637import { delay } from '../test_utils' ;
38+ import { expectDocumentsMigratedToHighestVersion } from '../kibana_migrator_test_kit.expect' ;
3739
3840const logFilePath = join ( __dirname , 'v2_migration.log' ) ;
3941
@@ -83,11 +85,11 @@ describe('v2 migration', () => {
8385 expect ( migrationResults . map ( ( result ) => omit ( result , 'elapsedMs' ) ) ) . toMatchInlineSnapshot ( `
8486 Array [
8587 Object {
86- "destIndex": ".kibana_migrator_9.0.0_001 ",
88+ "destIndex": ".kibana_migrator_ ${ currentVersion } _001 ",
8789 "status": "patched",
8890 },
8991 Object {
90- "destIndex": ".kibana_migrator_tasks_9.0.0_001 ",
92+ "destIndex": ".kibana_migrator_tasks_ ${ currentVersion } _001 ",
9193 "status": "patched",
9294 },
9395 ]
@@ -214,38 +216,10 @@ describe('v2 migration', () => {
214216 } ) ;
215217
216218 it ( 'migrates documents to the highest version' , async ( ) => {
217- const typeMigrationVersions : Record < string , string > = {
218- basic : '10.1.0' , // did not define any model versions
219- complex : '10.2.0' ,
220- task : '10.2.0' ,
221- } ;
222-
223- const resultSets = await Promise . all (
224- baselineTypes . map ( ( { name : type } ) =>
225- kit . client . search < any > ( {
226- index : [ defaultKibanaIndex , defaultKibanaTaskIndex ] ,
227- query : {
228- bool : {
229- should : [
230- {
231- term : { type } ,
232- } ,
233- ] ,
234- } ,
235- } ,
236- } )
237- )
238- ) ;
239-
240- expect (
241- resultSets
242- . flatMap ( ( result ) => result . hits . hits )
243- . every (
244- ( document ) =>
245- document . _source . typeMigrationVersion ===
246- typeMigrationVersions [ document . _source . type ]
247- )
248- ) . toEqual ( true ) ;
219+ await expectDocumentsMigratedToHighestVersion ( kit . client , [
220+ defaultKibanaIndex ,
221+ defaultKibanaTaskIndex ,
222+ ] ) ;
249223 } ) ;
250224
251225 describe ( 'a migrator performing a compatible upgrade migration' , ( ) => {
@@ -338,11 +312,7 @@ describe('v2 migration', () => {
338312 } ) ;
339313
340314 it ( 'executes the excludeOnUpgrade hook' , ( ) => {
341- // we discard the second half with exclude on upgrade (firstHalf !== true)
342- // then we discard half all multiples of 100 (1% of them)
343- expect ( primaryIndexCounts . complex ) . toEqual (
344- BASELINE_DOCUMENTS_PER_TYPE_500K / 2 - BASELINE_DOCUMENTS_PER_TYPE_500K / 2 / 100
345- ) ;
315+ expect ( primaryIndexCounts . complex ) . toEqual ( BASELINE_COMPLEX_DOCUMENTS_500K_AFTER ) ;
346316 } ) ;
347317 } ) ;
348318
@@ -352,13 +322,13 @@ describe('v2 migration', () => {
352322 . toMatchInlineSnapshot ( `
353323 Array [
354324 Object {
355- "destIndex": ".kibana_migrator_9.1.0_001 ",
356- "sourceIndex": ".kibana_migrator_9.0.0_001 ",
325+ "destIndex": ".kibana_migrator_ ${ nextMinor } _001 ",
326+ "sourceIndex": ".kibana_migrator_ ${ currentVersion } _001 ",
357327 "status": "migrated",
358328 },
359329 Object {
360- "destIndex": ".kibana_migrator_tasks_9.0.0_001 ",
361- "sourceIndex": ".kibana_migrator_tasks_9.0.0_001 ",
330+ "destIndex": ".kibana_migrator_tasks_ ${ currentVersion } _001 ",
331+ "sourceIndex": ".kibana_migrator_tasks_ ${ currentVersion } _001 ",
362332 "status": "migrated",
363333 },
364334 ]
0 commit comments