(t *testing.T)
| 950 | } |
| 951 | |
| 952 | func TestDatabaseStartupFailure(t *testing.T) { |
| 953 | if !base.IsEnterpriseEdition() { |
| 954 | t.Skip("EE only test, requires heartbeater error") |
| 955 | } |
| 956 | if !base.UnitTestUrlIsWalrus() { |
| 957 | t.Skip("LeakyBucketConfig not supported on CBS") |
| 958 | } |
| 959 | |
| 960 | touchErr := errors.New("touch error") |
| 961 | rt := NewRestTester(t, &RestTesterConfig{ |
| 962 | LeakyBucketConfig: &base.LeakyBucketConfig{ |
| 963 | TouchCallback: func(key string) error { |
| 964 | if strings.Contains(key, "heartbeat_timeout") { |
| 965 | return touchErr |
| 966 | } |
| 967 | return nil |
| 968 | }, |
| 969 | }, |
| 970 | PersistentConfig: true, |
| 971 | }) |
| 972 | defer rt.Close() |
| 973 | |
| 974 | dbConfig := DatabaseConfig{ |
| 975 | DbConfig: rt.NewDbConfig(), |
| 976 | } |
| 977 | |
| 978 | // this call does use the leaky bucket |
| 979 | dbContext, err := rt.ServerContext().AddDatabaseFromConfigWithBucket(rt.Context(), t, dbConfig, rt.Bucket()) |
| 980 | require.ErrorIs(t, err, touchErr) |
| 981 | require.Nil(t, dbContext) |
| 982 | require.Equal(t, "Offline", rt.GetDBState()) |
| 983 | |
| 984 | require.Equal(t, int64(1), rt.GetDatabase().DbStats.Database().TotalOnlineFatalErrors.Value()) |
| 985 | require.Equal(t, int64(0), rt.GetDatabase().DbStats.Database().TotalInitFatalErrors.Value()) |
| 986 | // assert that the db is reported with appropriate error state in all dbs |
| 987 | allDbs := rt.ServerContext().allDatabaseSummaries() |
| 988 | require.Len(t, allDbs, 1) |
| 989 | invalDb := allDbs[0] |
| 990 | require.NotNil(t, invalDb.DatabaseError) |
| 991 | assert.Equal(t, db.RunStateString[db.DBOffline], invalDb.State) |
| 992 | assert.Equal(t, invalDb.DatabaseError.ErrMsg, db.DatabaseErrorMap[db.DatabaseOnlineProcessError]) |
| 993 | |
| 994 | // assert that you can attempt again to bring db back online again after failure |
| 995 | resp := rt.SendAdminRequest(http.MethodPost, "/"+invalDb.Bucket+"/_online", "") |
| 996 | RequireStatus(t, resp, http.StatusOK) |
| 997 | rt.WaitForDBOnline() |
| 998 | } |
| 999 | |
| 1000 | func TestDatabaseCollectionDeletedErrorState(t *testing.T) { |
| 1001 | if base.UnitTestUrlIsWalrus() { |
nothing calls this directly
no test coverage detected