@@ -88,6 +88,63 @@ var _ = ginkgo.Describe("Upstream", func() {
8888 ExpectStatus : http .StatusOK ,
8989 })
9090 })
91+ ginkgo .It ("create upstream3 success when pass host is 'node' and nodes without port" , func () {
92+ ginkgo .By ("create upstream3" , func () {
93+ createUpstreamBody := make (map [string ]interface {})
94+ createUpstreamBody ["name" ] = "upstream3"
95+ createUpstreamBody ["nodes" ] = map [string ]float64 {base .UpstreamIp : 100 }
96+ createUpstreamBody ["type" ] = "roundrobin"
97+ createUpstreamBody ["pass_host" ] = "node"
98+
99+ _createUpstreamBody , err := json .Marshal (createUpstreamBody )
100+ gomega .Expect (err ).To (gomega .BeNil ())
101+ base .RunTestCase (base.HttpTestCase {
102+ Object : base .ManagerApiExpect (),
103+ Method : http .MethodPut ,
104+ Path : "/apisix/admin/upstreams/3" ,
105+ Body : string (_createUpstreamBody ),
106+ Headers : map [string ]string {"Authorization" : base .GetToken ()},
107+ ExpectStatus : http .StatusOK ,
108+ })
109+ })
110+
111+ ginkgo .By ("create route using the upstream3" , func () {
112+ base .RunTestCase (base.HttpTestCase {
113+ Object : base .ManagerApiExpect (),
114+ Method : http .MethodPut ,
115+ Path : "/apisix/admin/routes/1" ,
116+ Body : `{
117+ "name": "route1",
118+ "uri": "/hello",
119+ "upstream_id": "3"
120+ }` ,
121+ Headers : map [string ]string {"Authorization" : base .GetToken ()},
122+ ExpectStatus : http .StatusOK ,
123+ Sleep : base .SleepTime ,
124+ })
125+ })
126+
127+ ginkgo .By ("hit the route just created" , func () {
128+ base .RunTestCase (base.HttpTestCase {
129+ Object : base .APISIXExpect (),
130+ Method : http .MethodGet ,
131+ Path : "/hello" ,
132+ ExpectStatus : http .StatusOK ,
133+ ExpectBody : "hello" ,
134+ Sleep : base .SleepTime ,
135+ })
136+ })
137+
138+ ginkgo .By ("delete route" , func () {
139+ base .RunTestCase (base.HttpTestCase {
140+ Object : base .ManagerApiExpect (),
141+ Method : http .MethodDelete ,
142+ Path : "/apisix/admin/routes/1" ,
143+ Headers : map [string ]string {"Authorization" : base .GetToken ()},
144+ ExpectStatus : http .StatusOK ,
145+ })
146+ })
147+ })
91148 ginkgo .It ("create upstream failed, name existed" , func () {
92149 createUpstreamBody := make (map [string ]interface {})
93150 createUpstreamBody ["name" ] = "upstream2"
@@ -252,6 +309,15 @@ var _ = ginkgo.Describe("Upstream", func() {
252309 ExpectStatus : http .StatusOK ,
253310 })
254311 })
312+ ginkgo .It ("delete upstream3" , func () {
313+ base .RunTestCase (base.HttpTestCase {
314+ Object : base .ManagerApiExpect (),
315+ Method : http .MethodDelete ,
316+ Path : "/apisix/admin/upstreams/3" ,
317+ Headers : map [string ]string {"Authorization" : base .GetToken ()},
318+ ExpectStatus : http .StatusOK ,
319+ })
320+ })
255321 ginkgo .It ("hit the route just deleted" , func () {
256322 base .RunTestCase (base.HttpTestCase {
257323 Object : base .APISIXExpect (),
0 commit comments