(t *testing.T)
| 3669 | } |
| 3670 | |
| 3671 | func 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 | |
| 3707 | func TestFetchBackupRevisionByCVThroughAPI(t *testing.T) { |
| 3708 | rt := NewRestTester(t, &RestTesterConfig{ |
nothing calls this directly
no test coverage detected