Confirms that when the database config is not in sc.dbConfigs, the fetch callback is check if the config is in a bucket
(t *testing.T)
| 348 | |
| 349 | // Confirms that when the database config is not in sc.dbConfigs, the fetch callback is check if the config is in a bucket |
| 350 | func TestServerlessUnsuspendFetchFallback(t *testing.T) { |
| 351 | RequireBucketSpecificCredentials(t) |
| 352 | ctx := base.TestCtx(t) |
| 353 | tb := base.GetTestBucket(t) |
| 354 | defer tb.Close(ctx) |
| 355 | |
| 356 | rt := NewRestTester(t, &RestTesterConfig{ |
| 357 | CustomTestBucket: tb.NoCloseClone(), |
| 358 | serverless: true, |
| 359 | PersistentConfig: true, |
| 360 | MutateStartupConfig: func(config *StartupConfig) { |
| 361 | config.Bootstrap.ConfigUpdateFrequency = base.NewConfigDuration(0) |
| 362 | }, |
| 363 | }) |
| 364 | defer rt.Close() |
| 365 | sc := rt.ServerContext() |
| 366 | |
| 367 | resp := rt.SendAdminRequest(http.MethodPut, "/db/", |
| 368 | fmt.Sprintf( |
| 369 | `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t}`, |
| 370 | tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(), |
| 371 | ), |
| 372 | ) |
| 373 | RequireStatus(t, resp, http.StatusCreated) |
| 374 | |
| 375 | // Suspend the database and remove it from dbConfigs, forcing unsuspendDatabase to fetch config from the bucket |
| 376 | err := sc.suspendDatabase(t, rt.Context(), "db") |
| 377 | assert.NoError(t, err) |
| 378 | delete(sc._dbConfigs, "db") |
| 379 | delete(sc._dbRegistry, "db") |
| 380 | assert.Nil(t, sc._databases["db"]) |
| 381 | |
| 382 | // Unsuspend db and confirm unsuspending worked |
| 383 | dbCtx, err := sc.GetDatabase(rt.Context(), "db") |
| 384 | assert.NoError(t, err) |
| 385 | assert.NotNil(t, dbCtx) |
| 386 | assert.NotNil(t, sc._databases["db"]) |
| 387 | |
| 388 | // Attempt to get invalid database |
| 389 | _, err = sc.GetDatabase(rt.Context(), "invalid") |
| 390 | assert.Contains(t, err.Error(), "no such database") |
| 391 | } |
| 392 | |
| 393 | // Confirms that ServerContext.fetchConfigsWithTTL works correctly |
| 394 | func TestServerlessFetchConfigsLimited(t *testing.T) { |
nothing calls this directly
no test coverage detected