From 1acc511518e54c01c7dfc346568f51e27ac477c0 Mon Sep 17 00:00:00 2001 From: Abhishek Choudhary Date: Wed, 27 Sep 2023 14:53:11 +0545 Subject: [PATCH] use real upstream instead of upstream id --- t/plugin/traffic-split2.t | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/t/plugin/traffic-split2.t b/t/plugin/traffic-split2.t index 47d041e9b45f..746d7441bac5 100644 --- a/t/plugin/traffic-split2.t +++ b/t/plugin/traffic-split2.t @@ -809,32 +809,25 @@ failed to find upstream by id: invalid-id local json = require("toolkit.json") local t = require("lib.test_admin") - local code, body = t.test('/apisix/admin/upstreams/1', - ngx.HTTP_PUT, - [[{ - "nodes": { - "127.0.0.1:1983": 1 - }, - "type": "roundrobin", - "desc": "port 1983 is served under https", - "scheme": "https" - }]] - ) - - if code >= 300 then - ngx.status = code - ngx.say(body) - end - local data = { uri = "/hello", plugins = { ["traffic-split"] = { rules = { { + match = { { + vars = { { "arg_scheme", "==", "https" } } + } }, weighted_upstreams = { { - upstream_id = 1, + upstream = { + type = "roundrobin", + pass_host = "node", + nodes = { + ["127.0.0.1:1983"] = 1, + }, + scheme = "https" + }, weight = 1 } } @@ -867,7 +860,5 @@ passed === TEST 22: hit route --- request -GET /hello +GET /hello?scheme=https --- error_code: 200 ---- response_body -hello world