@@ -347,3 +347,100 @@ GET /t
347
347
reconnected to etcd
348
348
-- - response_body
349
349
passed
350
+
351
+
352
+
353
+ === TEST 11 : reloaded data may be in res. body . node (special kvs structure)
354
+ -- - yaml_config
355
+ deployment:
356
+ role: traditional
357
+ role_traditional:
358
+ config_provider: etcd
359
+ admin:
360
+ admin_key: null
361
+ -- - config
362
+ location / t {
363
+ content_by_lua_block {
364
+ local config_etcd = require (" apisix.core.config_etcd" )
365
+ local etcd_cli = {}
366
+ function etcd_cli. readdir ()
367
+ return {
368
+ status = 200 ,
369
+ headers = {},
370
+ body = {
371
+ header = {revision = 1 },
372
+ kvs = {{key = " foo" , value = " bar" }},
373
+ }
374
+ }
375
+ end
376
+ config_etcd. test_sync_data({
377
+ etcd_cli = etcd_cli,
378
+ key = " fake" ,
379
+ single_item = true,
380
+ -- need_reload because something wrong happened before
381
+ need_reload = true,
382
+ upgrade_version = function() end ,
383
+ conf_version = 1 ,
384
+ })
385
+ }
386
+ }
387
+ -- - request
388
+ GET / t
389
+ -- - log_level: debug
390
+ -- - grep_error_log eval
391
+ qr/ readdir key : fake res: .+/
392
+ -- - grep_error_log_out eval
393
+ qr/ readdir key : fake res: \{(" value" : " bar" ," key" : " foo" | " key" : " foo" ," value" : " bar" )\}/
394
+ -- - wait : 1
395
+ -- - no_error_log
396
+ [error]
397
+
398
+
399
+
400
+ === TEST 12 : reloaded data may be in res. body . node (admin_api_version is v2)
401
+ -- - yaml_config
402
+ deployment:
403
+ role: traditional
404
+ role_traditional:
405
+ config_provider: etcd
406
+ admin:
407
+ admin_key: null
408
+ admin_api_version: v2
409
+ -- - config
410
+ location / t {
411
+ content_by_lua_block {
412
+ local config_etcd = require (" apisix.core.config_etcd" )
413
+ local etcd_cli = {}
414
+ function etcd_cli. readdir ()
415
+ return {
416
+ status = 200 ,
417
+ headers = {},
418
+ body = {
419
+ header = {revision = 1 },
420
+ kvs = {
421
+ {key = " /foo" },
422
+ {key = " /foo/bar" , value = {" bar" }}
423
+ },
424
+ }
425
+ }
426
+ end
427
+ config_etcd. test_sync_data({
428
+ etcd_cli = etcd_cli,
429
+ key = " fake" ,
430
+ -- need_reload because something wrong happened before
431
+ need_reload = true,
432
+ upgrade_version = function() end ,
433
+ conf_version = 1 ,
434
+ })
435
+ }
436
+ }
437
+ -- - request
438
+ GET / t
439
+ -- - log_level: debug
440
+ -- - grep_error_log eval
441
+ qr/ readdir key : fake res: .+/
442
+ -- - grep_error_log_out eval
443
+ qr/ readdir key : fake res: \{.* " nodes" : \[\{.* " value" : \[" bar" \].* \}\].* \}/
444
+ -- - wait : 1
445
+ -- - no_error_log
446
+ [error]
0 commit comments