@@ -223,4 +223,75 @@ describe("when CP exits before DP" .. " rpc_sync=" .. rpc_sync, function()
223
223
assert .logfile (" servroot2/logs/error.log" ).has .no .line (" error while receiving frame from peer" , true )
224
224
end )
225
225
end )
226
- end -- for rpc_sync
226
+
227
+ describe (" DP config cache" , function ()
228
+ it (" DP config cache should prioritize over declaritive config #regression" , function ()
229
+ local cjson = require " cjson"
230
+ local config1 = cjson .encode {
231
+ _format_version = " 1.1" ,
232
+ services = {
233
+ {
234
+ name = " my-service" ,
235
+ url = " http://127.0.0.1:15555" ,
236
+ routes = {
237
+ {
238
+ name = " example-route" ,
239
+ hosts = { " example.test" }
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+
246
+
247
+ local config2 = cjson .encode {
248
+ _format_version = " 1.1" ,
249
+ }
250
+
251
+
252
+ assert .truthy (helpers .start_kong ({
253
+ role = " data_plane" ,
254
+ database = " off" ,
255
+ nginx_conf = " spec/fixtures/custom_nginx.template" ,
256
+ prefix = " servroot2" ,
257
+ cluster_rpc = rpc ,
258
+ cluster_rpc_sync = rpc_sync ,
259
+ declarative_config_string = config1 ,
260
+ proxy_listen = " 0.0.0.0:9002" ,
261
+ }))
262
+
263
+ -- do not clean the prefix to preserve the config cache
264
+ helpers .stop_kong (" servroot2" , true )
265
+
266
+ assert (helpers .start_kong ({
267
+ role = " data_plane" ,
268
+ database = " off" ,
269
+ nginx_conf = " spec/fixtures/custom_nginx.template" ,
270
+ prefix = " servroot2" ,
271
+ cluster_rpc = rpc ,
272
+ cluster_rpc_sync = rpc_sync ,
273
+ declarative_config_string = config2 ,
274
+ }))
275
+
276
+ finally (function ()
277
+ -- stop the data plane
278
+ helpers .stop_kong (" servroot2" )
279
+ end )
280
+
281
+ local proxy_client = assert (helpers .proxy_client ({
282
+ prefix = " servroot2" ,
283
+ port = 9002 ,
284
+ }))
285
+
286
+ -- it should use the config cache
287
+ assert .res_status (200 , proxy_client :send ({
288
+ method = " GET" ,
289
+ path = " /" ,
290
+ headers = {
291
+ host = " example.test" ,
292
+ },
293
+ }))
294
+ end )
295
+ end )
296
+
297
+ end -- for rpc_sync
0 commit comments