(t *testing.T)
| 245 | } |
| 246 | |
| 247 | func TestConfigValidationImportPartitions(t *testing.T) { |
| 248 | |
| 249 | if !base.IsEnterpriseEdition() { |
| 250 | t.Skip("Import partitions config validation is enterprise edition only") |
| 251 | } |
| 252 | |
| 253 | tests := []struct { |
| 254 | name string |
| 255 | config string |
| 256 | err string |
| 257 | }{ |
| 258 | { |
| 259 | name: "Import enabled, shared bucket disabled", |
| 260 | config: `{"databases": {"db": {"import_docs":true, "enable_shared_bucket_access":false}}}`, |
| 261 | err: "Invalid configuration - import_docs enabled, but enable_shared_bucket_access not enabled", |
| 262 | }, |
| 263 | { |
| 264 | name: "Import partitions set, shared bucket disabled", |
| 265 | config: `{"databases": {"db": {"import_partitions":32, "enable_shared_bucket_access":false}}}`, |
| 266 | err: "Invalid configuration - import_partitions set, but enable_shared_bucket_access not enabled", |
| 267 | }, |
| 268 | { |
| 269 | name: "Import disabled, but partitions set", |
| 270 | config: `{"databases": {"db": {"enable_shared_bucket_access":true,"import_docs":false,"import_partitions":32}}}`, |
| 271 | err: "Invalid configuration - import_partitions set, but import_docs disabled", |
| 272 | }, |
| 273 | { |
| 274 | name: "Too many partitions", |
| 275 | config: `{"databases": {"db": {"enable_shared_bucket_access":true,"import_partitions":2048}}}`, |
| 276 | err: "valid range for import_partitions is: 1-1024", |
| 277 | }, |
| 278 | { |
| 279 | name: "Not enough partitions", |
| 280 | config: `{"databases": {"db": {"enable_shared_bucket_access":true,"import_partitions":0}}}`, |
| 281 | err: "valid range for import_partitions is: 1-1024", |
| 282 | }, |
| 283 | { |
| 284 | name: "Valid partitions", |
| 285 | config: `{"databases": {"db": {"enable_shared_bucket_access":true,"import_partitions":32}}}`, |
| 286 | }, |
| 287 | { |
| 288 | name: "Valid partitions, enable_shared_bucket_access default value (true)", |
| 289 | config: `{"databases": {"db": {"import_partitions":32}}}`, |
| 290 | }, |
| 291 | } |
| 292 | |
| 293 | for _, test := range tests { |
| 294 | t.Run(test.name, func(t *testing.T) { |
| 295 | ctx := base.TestCtx(t) |
| 296 | buf := bytes.NewBufferString(test.config) |
| 297 | config, err := readLegacyServerConfig(ctx, buf) |
| 298 | assert.NoError(t, err) |
| 299 | errorMessages := config.setupAndValidateDatabases(ctx) |
| 300 | if test.err != "" { |
| 301 | require.NotNil(t, errorMessages) |
| 302 | multiError, ok := errorMessages.(*base.MultiError) |
| 303 | require.True(t, ok) |
| 304 | require.Equal(t, multiError.Len(), 1) |
nothing calls this directly
no test coverage detected