(t *testing.T)
| 25 | const testUseLegacySyncDocsIndex = false |
| 26 | |
| 27 | func TestDatabaseInitManager(t *testing.T) { |
| 28 | RequireN1QLIndexes(t) |
| 29 | |
| 30 | sc, closeFn := StartBootstrapServer(t) |
| 31 | defer closeFn() |
| 32 | |
| 33 | initMgr := sc.DatabaseInitManager |
| 34 | |
| 35 | ctx := base.TestCtx(t) |
| 36 | // Get a test bucket for bootstrap testing, and create dbconfig targeting that bucket |
| 37 | tb := base.GetTestBucket(t) |
| 38 | defer tb.Close(ctx) |
| 39 | dbName := "dbName" |
| 40 | var scopesConfig ScopesConfig |
| 41 | if base.TestsUseNamedCollections() { |
| 42 | scopesConfig = GetCollectionsConfig(t, tb, 1) |
| 43 | } |
| 44 | dbConfig := makeDbConfig(tb.GetName(), dbName, scopesConfig) |
| 45 | require.NoError(t, dbConfig.setup(ctx, dbName, sc.Config.Bootstrap, nil, nil, false)) |
| 46 | |
| 47 | // Drop indexes |
| 48 | dropAllNonPrimaryIndexes(t, tb.GetSingleDataStore()) |
| 49 | |
| 50 | // Async index creation |
| 51 | doneChan, err := initMgr.InitializeDatabase(ctx, sc.Config, dbConfig.ToDatabaseConfig(), testUseLegacySyncDocsIndex) |
| 52 | require.NoError(t, err) |
| 53 | |
| 54 | select { |
| 55 | case err := <-doneChan: |
| 56 | require.NoError(t, err) |
| 57 | case <-time.After(30 * time.Second): |
| 58 | require.Fail(t, "InitializeDatabase didn't complete in 30s") |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | // TestDatabaseInitConfigChangeSameCollections tests modifications made to the database config while init is running. |
| 64 | // Uses initManager callbacks to simulate slow index creation and build. Tests the following two scenarios: |
nothing calls this directly
no test coverage detected