@@ -3162,6 +3162,140 @@ func TestDatabases_UpdateConfigKafka(t *testing.T) {
3162
3162
require .NoError (t , err )
3163
3163
}
3164
3164
3165
+ func TestDatabases_GetConfigOpensearch (t * testing.T ) {
3166
+ setup ()
3167
+ defer teardown ()
3168
+
3169
+ var (
3170
+ dbSvc = client .Databases
3171
+ dbID = "da4e0206-d019-41d7-b51f-deadbeefbb8f"
3172
+ path = fmt .Sprintf ("/v2/databases/%s/config" , dbID )
3173
+
3174
+ opensearchConfigJSON = `{
3175
+ "config": {
3176
+ "ism_enabled": true,
3177
+ "ism_history_enabled": true,
3178
+ "ism_history_max_age_hours": 24,
3179
+ "ism_history_max_docs": 2500000,
3180
+ "ism_history_rollover_check_period_hours": 8,
3181
+ "ism_history_rollover_retention_period_days": 30,
3182
+ "http_max_content_length_bytes": 100000000,
3183
+ "http_max_header_size_bytes": 8192,
3184
+ "http_max_initial_line_length_bytes": 4096,
3185
+ "indices_query_bool_max_clause_count": 1024,
3186
+ "search_max_buckets": 10000,
3187
+ "indices_fielddata_cache_size_percentage": 0,
3188
+ "indices_memory_index_buffer_size_percentage": 10,
3189
+ "indices_memory_min_index_buffer_size_mb": 48,
3190
+ "indices_memory_max_index_buffer_size_mb": 0,
3191
+ "indices_queries_cache_size_percentage": 10,
3192
+ "indices_recovery_max_mb_per_sec": 40,
3193
+ "indices_recovery_max_concurrent_file_chunks": 2,
3194
+ "action_auto_create_index_enabled": true,
3195
+ "action_destructive_requires_name": false,
3196
+ "plugins_alerting_filter_by_backend_roles_enabled": false,
3197
+ "enable_security_audit": false,
3198
+ "thread_pool_search_size": 0,
3199
+ "thread_pool_search_throttled_size": 0,
3200
+ "thread_pool_search_throttled_queue_size": 0,
3201
+ "thread_pool_search_queue_size": 0,
3202
+ "thread_pool_get_size": 0,
3203
+ "thread_pool_get_queue_size": 0,
3204
+ "thread_pool_analyze_size": 0,
3205
+ "thread_pool_analyze_queue_size": 0,
3206
+ "thread_pool_write_size": 0,
3207
+ "thread_pool_write_queue_size": 0,
3208
+ "thread_pool_force_merge_size": 0,
3209
+ "override_main_response_version": false,
3210
+ "script_max_compilations_rate": "use-context",
3211
+ "cluster_max_shards_per_node": 0,
3212
+ "cluster_routing_allocation_node_concurrent_recoveries": 2
3213
+ }
3214
+ }`
3215
+
3216
+ opensearchConfig = OpensearchConfig {
3217
+ HttpMaxContentLengthBytes : PtrTo (100000000 ),
3218
+ HttpMaxHeaderSizeBytes : PtrTo (8192 ),
3219
+ HttpMaxInitialLineLengthBytes : PtrTo (4096 ),
3220
+ IndicesQueryBoolMaxClauseCount : PtrTo (1024 ),
3221
+ IndicesFielddataCacheSizePercentage : PtrTo (0 ),
3222
+ IndicesMemoryIndexBufferSizePercentage : PtrTo (10 ),
3223
+ IndicesMemoryMinIndexBufferSizeMb : PtrTo (48 ),
3224
+ IndicesMemoryMaxIndexBufferSizeMb : PtrTo (0 ),
3225
+ IndicesQueriesCacheSizePercentage : PtrTo (10 ),
3226
+ IndicesRecoveryMaxMbPerSec : PtrTo (40 ),
3227
+ IndicesRecoveryMaxConcurrentFileChunks : PtrTo (2 ),
3228
+ ThreadPoolSearchSize : PtrTo (0 ),
3229
+ ThreadPoolSearchThrottledSize : PtrTo (0 ),
3230
+ ThreadPoolGetSize : PtrTo (0 ),
3231
+ ThreadPoolAnalyzeSize : PtrTo (0 ),
3232
+ ThreadPoolWriteSize : PtrTo (0 ),
3233
+ ThreadPoolForceMergeSize : PtrTo (0 ),
3234
+ ThreadPoolSearchQueueSize : PtrTo (0 ),
3235
+ ThreadPoolSearchThrottledQueueSize : PtrTo (0 ),
3236
+ ThreadPoolGetQueueSize : PtrTo (0 ),
3237
+ ThreadPoolAnalyzeQueueSize : PtrTo (0 ),
3238
+ ThreadPoolWriteQueueSize : PtrTo (0 ),
3239
+ IsmEnabled : PtrTo (true ),
3240
+ IsmHistoryEnabled : PtrTo (true ),
3241
+ IsmHistoryMaxAgeHours : PtrTo (24 ),
3242
+ IsmHistoryMaxDocs : PtrTo (uint64 (2500000 )),
3243
+ IsmHistoryRolloverCheckPeriodHours : PtrTo (8 ),
3244
+ IsmHistoryRolloverRetentionPeriodDays : PtrTo (30 ),
3245
+ SearchMaxBuckets : PtrTo (10000 ),
3246
+ ActionAutoCreateIndexEnabled : PtrTo (true ),
3247
+ EnableSecurityAudit : PtrTo (false ),
3248
+ ActionDestructiveRequiresName : PtrTo (false ),
3249
+ ClusterMaxShardsPerNode : PtrTo (0 ),
3250
+ OverrideMainResponseVersion : PtrTo (false ),
3251
+ ScriptMaxCompilationsRate : PtrTo ("use-context" ),
3252
+ ClusterRoutingAllocationNodeConcurrentRecoveries : PtrTo (2 ),
3253
+ ReindexRemoteWhitelist : nil ,
3254
+ }
3255
+ )
3256
+
3257
+ mux .HandleFunc (path , func (w http.ResponseWriter , r * http.Request ) {
3258
+ testMethod (t , r , http .MethodGet )
3259
+ fmt .Fprint (w , opensearchConfigJSON )
3260
+ })
3261
+
3262
+ got , _ , err := dbSvc .GetOpensearchConfig (ctx , dbID )
3263
+ require .NoError (t , err )
3264
+ require .Equal (t , & opensearchConfig , got )
3265
+ }
3266
+
3267
+ func TestDatabases_UpdateConfigOpensearch (t * testing.T ) {
3268
+ setup ()
3269
+ defer teardown ()
3270
+
3271
+ var (
3272
+ dbID = "deadbeef-dead-4aa5-beef-deadbeef347d"
3273
+ path = fmt .Sprintf ("/v2/databases/%s/config" , dbID )
3274
+ opensearchConfig = & OpensearchConfig {
3275
+ HttpMaxContentLengthBytes : PtrTo (1 ),
3276
+ HttpMaxHeaderSizeBytes : PtrTo (0 ),
3277
+ }
3278
+ )
3279
+
3280
+ mux .HandleFunc (path , func (w http.ResponseWriter , r * http.Request ) {
3281
+ testMethod (t , r , http .MethodPatch )
3282
+
3283
+ var b databaseOpensearchConfigRoot
3284
+ decoder := json .NewDecoder (r .Body )
3285
+ err := decoder .Decode (& b )
3286
+ require .NoError (t , err )
3287
+
3288
+ assert .Equal (t , b .Config , opensearchConfig )
3289
+ assert .Equal (t , 0 , * b .Config .HttpMaxHeaderSizeBytes , "pointers to zero value should be sent" )
3290
+ assert .Nil (t , b .Config .HttpMaxInitialLineLengthBytes , "excluded value should not be sent" )
3291
+
3292
+ w .WriteHeader (http .StatusNoContent )
3293
+ })
3294
+
3295
+ _ , err := client .Databases .UpdateOpensearchConfig (ctx , dbID , opensearchConfig )
3296
+ require .NoError (t , err )
3297
+ }
3298
+
3165
3299
func TestDatabases_UpgradeMajorVersion (t * testing.T ) {
3166
3300
setup ()
3167
3301
defer teardown ()
0 commit comments