MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestGetConfigAfterFailToStartOnlineProcess

Function TestGetConfigAfterFailToStartOnlineProcess

rest/api_test.go:3671–3705  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3669}
3670
3671func TestGetConfigAfterFailToStartOnlineProcess(t *testing.T) {
3672 rt := NewRestTester(t, &RestTesterConfig{
3673 PersistentConfig: true,
3674 })
3675 defer rt.Close()
3676
3677 dbConfig := rt.NewDbConfig()
3678 dbConfig.StartOffline = base.Ptr(true)
3679 resp := rt.CreateDatabase("db", dbConfig)
3680 RequireStatus(t, resp, http.StatusCreated)
3681
3682 // create invalid user to cause StartOnlineProcesses error
3683 rt.GetDatabase().Options.ConfigPrincipals.Users = map[string]*auth.PrincipalConfig{
3684 "alice": {
3685 JWTChannels: base.SetOf("asdf"),
3686 },
3687 }
3688
3689 // Directly set the database state to DBStarting to simulate regular startup.
3690 // This direct atomic manipulation is required in this test to simulate a state transition.
3691 // This is safe in the context of this test.
3692 atomic.StoreUint32(&rt.GetDatabase().State, db.DBStarting)
3693 rt.WaitForDBState(db.RunStateString[db.DBStarting])
3694
3695 // Can't trigger error case from REST API - call directly
3696 rt.ServerContext().asyncDatabaseOnline(base.NewNonCancelCtx(), rt.GetDatabase(), nil, rt.ServerContext().GetDbVersion("db"))
3697
3698 // Error should cause db to stay offline.
3699 rt.WaitForDBState(db.RunStateString[db.DBOffline])
3700 require.Equal(t, int64(1), rt.GetDatabase().DbStats.Database().TotalOnlineFatalErrors.Value())
3701
3702 // Original bug will trigger panic here on this endpoint
3703 resp = rt.SendAdminRequest(http.MethodGet, "/_config?include_runtime=true", "")
3704 RequireStatus(t, resp, http.StatusOK)
3705}
3706
3707func TestFetchBackupRevisionByCVThroughAPI(t *testing.T) {
3708 rt := NewRestTester(t, &RestTesterConfig{

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
NewDbConfigMethod · 0.95
CreateDatabaseMethod · 0.95
GetDatabaseMethod · 0.95
WaitForDBStateMethod · 0.95
ServerContextMethod · 0.95
SendAdminRequestMethod · 0.95
PtrFunction · 0.92
SetOfFunction · 0.92
NewNonCancelCtxFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85

Tested by

no test coverage detected