@@ -79,38 +79,39 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
79
79
local res , err = db .connector :query (sql )
80
80
assert .is_nil (err )
81
81
assert .is_nil (res [1 ].generator )
82
-
83
82
res = admin_client :get (" /plugins" )
84
83
res = cjson .decode (assert .res_status (200 , res ))
85
84
assert .equals (res .data [1 ].config .generator , " uuid#counter" )
86
85
end )
87
86
end )
88
87
89
- for _ , rpc_sync in ipairs { " off" , " on" } do
90
- for _ , cluster_rpc in ipairs { " off " , " on " } do
88
+ for _ , v in ipairs ({ { " off " , " off" }, { " on" , " off " }, { " on " , " on " }, }) do
89
+ local rpc , rpc_sync = v [ 1 ], v [ 2 ]
91
90
describe (" in hybrid mode" .. " rpc_sync=" .. rpc_sync , function ()
92
91
local route
93
92
local plugin_name = " correlation-id"
94
- local bp , db = helpers .get_db_utils (strategy , { " plugins" , " workspaces" , })
95
- local ws = db .workspaces :select_by_name (" default" )
96
- local plugin_id = uuid .generate_v4 ()
97
- plugin_id = uuid .generate_v4 ()
98
- local sql = render ([[
99
- INSERT INTO plugins (id, name, config, enabled, ws_id) VALUES
100
- ('$(ID)', '$(PLUGIN_NAME)', $(CONFIG)::jsonb, TRUE, '$(WS_ID)');
101
- COMMIT;
102
- ]] , {
103
- ID = plugin_id ,
104
- PLUGIN_NAME = plugin_name ,
105
- CONFIG = pgmoon_json .encode_json (plugin_config ),
106
- WS_ID = ws .id ,
107
- })
108
-
109
- local res , err = db .connector :query (sql )
110
- assert .is_nil (err )
111
- assert .is_not_nil (res )
93
+ local bp , db , ws , plugin_id
112
94
113
95
lazy_setup (function ()
96
+ -- copy from outer lazy_setup, to avoid database reused.
97
+ bp , db = helpers .get_db_utils (strategy , { " plugins" , " workspaces" , })
98
+ ws = db .workspaces :select_by_name (" default" )
99
+ plugin_id = uuid .generate_v4 ()
100
+ local sql = render ([[
101
+ INSERT INTO plugins (id, name, config, enabled, ws_id) VALUES
102
+ ('$(ID)', '$(PLUGIN_NAME)', $(CONFIG)::jsonb, TRUE, '$(WS_ID)');
103
+ COMMIT;
104
+ ]] , {
105
+ ID = plugin_id ,
106
+ PLUGIN_NAME = plugin_name ,
107
+ CONFIG = pgmoon_json .encode_json (plugin_config ),
108
+ WS_ID = ws .id ,
109
+ })
110
+
111
+ local res , err = db .connector :query (sql )
112
+ assert .is_nil (err )
113
+ assert .is_not_nil (res )
114
+
114
115
route = bp .routes :insert ({
115
116
hosts = {" example.com" },
116
117
})
@@ -145,7 +146,7 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
145
146
cluster_listen = " 127.0.0.1:9005" ,
146
147
nginx_conf = " spec/fixtures/custom_nginx.template" ,
147
148
cluster_rpc_sync = rpc_sync ,
148
- cluster_rpc = cluster_rpc
149
+ cluster_rpc = rpc
149
150
}))
150
151
151
152
assert (helpers .start_kong ({
@@ -158,7 +159,7 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
158
159
proxy_listen = " 0.0.0.0:9002" ,
159
160
status_listen = " 127.0.0.1:9100" ,
160
161
cluster_rpc_sync = rpc_sync ,
161
- cluster_rpc = cluster_rpc
162
+ cluster_rpc = rpc
162
163
}))
163
164
end )
164
165
@@ -208,6 +209,5 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
208
209
proxy_client :close ()
209
210
end )
210
211
end )
211
- end -- for rpc_sync
212
- end -- for cluster_sync
212
+ end -- for rpc, rpc_sync
213
213
end )
0 commit comments