(t *testing.T)
| 3067 | } |
| 3068 | |
| 3069 | func TestRevCacheMemoryLimitConfig(t *testing.T) { |
| 3070 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) |
| 3071 | rt := NewRestTester(t, &RestTesterConfig{ |
| 3072 | CustomTestBucket: base.GetTestBucket(t), |
| 3073 | PersistentConfig: true, |
| 3074 | }) |
| 3075 | defer rt.Close() |
| 3076 | |
| 3077 | dbConfig := rt.NewDbConfig() |
| 3078 | RequireStatus(t, rt.CreateDatabase("db1", dbConfig), http.StatusCreated) |
| 3079 | |
| 3080 | resp := rt.SendAdminRequest(http.MethodGet, "/db1/_config", "") |
| 3081 | RequireStatus(t, resp, http.StatusOK) |
| 3082 | |
| 3083 | require.NoError(t, json.Unmarshal(resp.BodyBytes(), &dbConfig)) |
| 3084 | assert.Nil(t, dbConfig.CacheConfig) |
| 3085 | |
| 3086 | dbConfig.CacheConfig = &CacheConfig{} |
| 3087 | dbConfig.CacheConfig.RevCacheConfig = &RevCacheConfig{ |
| 3088 | MaxItemCount: base.Ptr(uint32(100)), |
| 3089 | MaxMemoryCountMB: base.Ptr(uint32(51)), |
| 3090 | } |
| 3091 | RequireStatus(t, rt.UpsertDbConfig("db1", dbConfig), http.StatusCreated) |
| 3092 | |
| 3093 | resp = rt.SendAdminRequest(http.MethodGet, "/db1/_config", "") |
| 3094 | RequireStatus(t, resp, http.StatusOK) |
| 3095 | |
| 3096 | // empty db config struct |
| 3097 | dbConfig = DbConfig{} |
| 3098 | require.NoError(t, json.Unmarshal(resp.BodyBytes(), &dbConfig)) |
| 3099 | assert.NotNil(t, dbConfig.CacheConfig) |
| 3100 | |
| 3101 | assert.Equal(t, uint32(100), *dbConfig.CacheConfig.RevCacheConfig.MaxItemCount) |
| 3102 | if base.IsEnterpriseEdition() { |
| 3103 | assert.Equal(t, uint32(51), *dbConfig.CacheConfig.RevCacheConfig.MaxMemoryCountMB) |
| 3104 | } else { |
| 3105 | assert.Nil(t, dbConfig.CacheConfig.RevCacheConfig.MaxMemoryCountMB) |
| 3106 | } |
| 3107 | |
| 3108 | dbConfig.CacheConfig = &CacheConfig{} |
| 3109 | dbConfig.CacheConfig.RevCacheConfig = &RevCacheConfig{ |
| 3110 | MaxItemCount: base.Ptr(uint32(100)), |
| 3111 | MaxMemoryCountMB: base.Ptr(uint32(4)), |
| 3112 | } |
| 3113 | resp = rt.UpsertDbConfig("db1", dbConfig) |
| 3114 | if base.IsEnterpriseEdition() { |
| 3115 | AssertHTTPErrorReason(t, resp, http.StatusInternalServerError, "Internal error: maximum rev cache memory size cannot be lower than 50 MB") |
| 3116 | } else { |
| 3117 | // CE will roll back to no memory limit as it's an EE ony feature |
| 3118 | RequireStatus(t, resp, http.StatusCreated) |
| 3119 | } |
| 3120 | |
| 3121 | // test turing off the memory based rev cache |
| 3122 | dbConfig.CacheConfig = &CacheConfig{} |
| 3123 | dbConfig.CacheConfig.RevCacheConfig = &RevCacheConfig{ |
| 3124 | MaxItemCount: base.Ptr(uint32(100)), |
| 3125 | MaxMemoryCountMB: base.Ptr(uint32(0)), |
| 3126 | } |
nothing calls this directly
no test coverage detected