@@ -3488,6 +3488,29 @@ local function get_grpc_target_port()
3488
3488
return 15010
3489
3489
end
3490
3490
3491
+ local function kong_conf_args (env )
3492
+ local prefix = env .prefix or conf .prefix
3493
+ local nginx_conf = " "
3494
+
3495
+
3496
+ local nginx_conf_flags = { " test" }
3497
+ if env .nginx_conf then
3498
+ nginx_conf = " --nginx-conf " .. env .nginx_conf
3499
+ end
3500
+
3501
+ if TEST_COVERAGE_MODE == " true" then
3502
+ -- render `coverage` blocks in the templates
3503
+ nginx_conf_flags [# nginx_conf_flags + 1 ] = ' coverage'
3504
+ end
3505
+
3506
+ local nginx_conf_flags_str = " "
3507
+ if next (nginx_conf_flags ) then
3508
+ nginx_conf_flags_str = " --nginx-conf-flags " .. table.concat (nginx_conf_flags , " ," )
3509
+ end
3510
+
3511
+ return prefix , " --conf " .. TEST_CONF_PATH , nginx_conf , nginx_conf_flags_str
3512
+ end
3513
+
3491
3514
3492
3515
--- Start the Kong instance to test against.
3493
3516
-- The fixtures passed to this function can be 3 types:
@@ -3556,7 +3579,8 @@ local function start_kong(env, tables, preserve_prefix, fixtures)
3556
3579
error (" arg #2 must be a list of tables to truncate" )
3557
3580
end
3558
3581
env = env or {}
3559
- local prefix = env .prefix or conf .prefix
3582
+
3583
+ local prefix , conf_args , nginx_conf , flags = kong_conf_args (env )
3560
3584
3561
3585
-- go plugins are enabled
3562
3586
-- compile fixture go plugins if any setting mentions it
@@ -3577,23 +3601,6 @@ local function start_kong(env, tables, preserve_prefix, fixtures)
3577
3601
3578
3602
truncate_tables (db , tables )
3579
3603
3580
- local nginx_conf = " "
3581
- local nginx_conf_flags = { " test" }
3582
- if env .nginx_conf then
3583
- nginx_conf = " --nginx-conf " .. env .nginx_conf
3584
- end
3585
-
3586
- if TEST_COVERAGE_MODE == " true" then
3587
- -- render `coverage` blocks in the templates
3588
- nginx_conf_flags [# nginx_conf_flags + 1 ] = ' coverage'
3589
- end
3590
-
3591
- if next (nginx_conf_flags ) then
3592
- nginx_conf_flags = " --nginx-conf-flags " .. table.concat (nginx_conf_flags , " ," )
3593
- else
3594
- nginx_conf_flags = " "
3595
- end
3596
-
3597
3604
if dcbp and not env .declarative_config and not env .declarative_config_string then
3598
3605
if not config_yml then
3599
3606
config_yml = prefix .. " /config.yml"
@@ -3609,7 +3616,7 @@ local function start_kong(env, tables, preserve_prefix, fixtures)
3609
3616
end
3610
3617
3611
3618
assert (render_fixtures (TEST_CONF_PATH .. nginx_conf , env , prefix , fixtures ))
3612
- return kong_exec (" start --conf " .. TEST_CONF_PATH .. nginx_conf .. nginx_conf_flags , env )
3619
+ return kong_exec (" start " .. conf_args .. nginx_conf .. flags , env )
3613
3620
end
3614
3621
3615
3622
@@ -3774,6 +3781,35 @@ local function reload_kong(strategy, ...)
3774
3781
end
3775
3782
3776
3783
3784
+ local DEFAULT_WAIT_OPT = {
3785
+ timeout = 10 ,
3786
+ step = 2 ,
3787
+ }
3788
+
3789
+
3790
+ --- Reload the Kong instance.
3791
+ local function reload_kong_ex (env , wait_opts )
3792
+ env = env or {}
3793
+ local _ , conf_args , nginx_conf , flags = kong_conf_args (env )
3794
+
3795
+ wait_opts = wait_opts or DEFAULT_WAIT_OPT
3796
+ local no_wait = wait_opts .no_wait
3797
+
3798
+ local workers , ret , err
3799
+ if not no_wait then
3800
+ workers = get_kong_workers ()
3801
+ end
3802
+
3803
+ ret , err = kong_exec (" reload " .. conf_args .. nginx_conf .. flags , env )
3804
+
3805
+ if (not no_wait ) and ret then
3806
+ wait_until_no_common_workers (workers , wait_opts .expected_total , wait_opts )
3807
+ end
3808
+
3809
+ return ret , err
3810
+ end
3811
+
3812
+
3777
3813
--- Simulate a Hybrid mode DP and connect to the CP specified in `opts`.
3778
3814
-- @function clustering_client
3779
3815
-- @param opts Options to use, the `host`, `port`, `cert` and `cert_key` fields
@@ -4049,6 +4085,7 @@ end
4049
4085
cleanup_kong = cleanup_kong ,
4050
4086
restart_kong = restart_kong ,
4051
4087
reload_kong = reload_kong ,
4088
+ reload_kong_ex = reload_kong_ex ,
4052
4089
get_kong_workers = get_kong_workers ,
4053
4090
wait_until_no_common_workers = wait_until_no_common_workers ,
4054
4091
0 commit comments