(t *testing.T)
| 3122 | } |
| 3123 | |
| 3124 | func TestDbOfflineConfigPersistent(t *testing.T) { |
| 3125 | importFilter := "function(doc) { return true }" |
| 3126 | syncFunc := "function(doc){ channel(doc.channels); }" |
| 3127 | |
| 3128 | rt := rest.NewRestTester(t, &rest.RestTesterConfig{ |
| 3129 | SyncFn: syncFunc, |
| 3130 | ImportFilter: importFilter, |
| 3131 | PersistentConfig: true, |
| 3132 | }) |
| 3133 | defer rt.Close() |
| 3134 | |
| 3135 | rest.RequireStatus(t, rt.CreateDatabase("db", rt.NewDbConfig()), http.StatusCreated) |
| 3136 | |
| 3137 | // Get config values before taking db offline, locally only |
| 3138 | resp := rt.SendAdminRequest(http.MethodGet, "/{{.db}}/_config", "") |
| 3139 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3140 | dbConfigBeforeOffline := resp.Body.String() |
| 3141 | |
| 3142 | resp = rt.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/_config/import_filter", "") |
| 3143 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3144 | require.Equal(t, importFilter, resp.Body.String()) |
| 3145 | |
| 3146 | resp = rt.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/_config/sync", "") |
| 3147 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3148 | require.Equal(t, syncFunc, resp.Body.String()) |
| 3149 | |
| 3150 | // take db offline, locally online, not using rt.TakeDbOffline which will update the bucket configuration |
| 3151 | rest.RequireStatus(t, rt.SendAdminRequest(http.MethodPost, "/{{.db}}/_offline", ""), http.StatusOK) |
| 3152 | |
| 3153 | require.Equal(t, "Offline", rt.GetDBState()) |
| 3154 | |
| 3155 | // Check offline config matches online config |
| 3156 | resp = rt.SendAdminRequest(http.MethodGet, "/{{.db}}/_config", "") |
| 3157 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3158 | require.Equal(t, dbConfigBeforeOffline, resp.Body.String()) |
| 3159 | |
| 3160 | resp = rt.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/_config/import_filter", "") |
| 3161 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3162 | require.Equal(t, importFilter, resp.Body.String()) |
| 3163 | |
| 3164 | resp = rt.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/_config/sync", "") |
| 3165 | rest.RequireStatus(t, resp, http.StatusOK) |
| 3166 | require.Equal(t, syncFunc, resp.Body.String()) |
| 3167 | } |
| 3168 | |
| 3169 | // TestDbConfigPersistentSGVersions ensures that cluster-wide config updates are not applied to older nodes to avoid pushing invalid configuration. |
| 3170 | func TestDbConfigPersistentSGVersions(t *testing.T) { |
nothing calls this directly
no test coverage detected