Skip to content

Commit 8d6d1c7

Browse files
authored
fix: remove cases external service dependency (#2697)
1 parent d168119 commit 8d6d1c7

File tree

3 files changed

+96
-108
lines changed

3 files changed

+96
-108
lines changed

api/test/docker/docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ services:
5757
apisix_dashboard_e2e:
5858
ipv4_address: 172.16.238.21
5959

60+
upstream_httpbin:
61+
image: kennethreitz/httpbin
62+
networks:
63+
apisix_dashboard_e2e:
64+
ipv4_address: 172.16.238.22
65+
6066
apisix:
6167
hostname: apisix_server1
6268
image: apache/apisix:2.15.1-debian

api/test/e2e/base/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939

4040
UpstreamIp = "upstream"
4141
UpstreamGrpcIp = "upstream_grpc"
42+
UpstreamHTTPBinIp = "upstream_httpbin"
4243
APISIXHost = "http://127.0.0.1:9080"
4344
APISIXAdminAPIHost = "http://127.0.0.1:9180"
4445
APISIXInternalUrl = "http://apisix:9080"

api/test/e2e/upstream/upstream_test.go

Lines changed: 89 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -329,114 +329,95 @@ var _ = Describe("Upstream", func() {
329329
})
330330
})
331331

332-
var _ = Describe("Upstream update with domain", func() {
333-
It("create upstream success", func() {
334-
createUpstreamBody := make(map[string]interface{})
335-
createUpstreamBody["name"] = "upstream1"
336-
createUpstreamBody["nodes"] = []map[string]interface{}{
337-
{
338-
"host": base.UpstreamIp,
339-
"port": 1980,
340-
"weight": 1,
341-
"priority": 10,
342-
},
343-
}
344-
createUpstreamBody["type"] = "roundrobin"
345-
_createUpstreamBody, err := json.Marshal(createUpstreamBody)
346-
Expect(err).To(BeNil())
347-
base.RunTestCase(base.HttpTestCase{
348-
Object: base.ManagerApiExpect(),
349-
Method: http.MethodPut,
350-
Path: "/apisix/admin/upstreams/1",
351-
Body: string(_createUpstreamBody),
352-
Headers: map[string]string{"Authorization": base.GetToken()},
353-
ExpectStatus: http.StatusOK,
354-
ExpectBody: `"code":0`,
355-
})
356-
})
357-
It("create route using the upstream(use proxy rewriteproxy rewrite plugin)", func() {
358-
base.RunTestCase(base.HttpTestCase{
359-
Object: base.ManagerApiExpect(),
360-
Method: http.MethodPut,
361-
Path: "/apisix/admin/routes/1",
362-
Body: `{
363-
"name": "route1",
364-
"uri": "/*",
365-
"upstream_id": "1",
366-
"plugins": {
367-
"proxy-rewrite": {
368-
"uri": "/",
369-
"scheme": "https"
370-
}
371-
}
372-
}`,
373-
Headers: map[string]string{"Authorization": base.GetToken()},
374-
ExpectStatus: http.StatusOK,
375-
Sleep: base.SleepTime,
376-
})
377-
})
378-
It("update upstream with domain", func() {
379-
createUpstreamBody := make(map[string]interface{})
380-
createUpstreamBody["nodes"] = []map[string]interface{}{
381-
{
382-
"host": "www.google.com",
383-
"port": 443,
384-
"weight": 1,
385-
"priority": 10,
386-
},
387-
}
388-
createUpstreamBody["type"] = "roundrobin"
389-
createUpstreamBody["pass_host"] = "node"
390-
_createUpstreamBody, err := json.Marshal(createUpstreamBody)
391-
Expect(err).To(BeNil())
392-
base.RunTestCase(base.HttpTestCase{
393-
Object: base.ManagerApiExpect(),
394-
Method: http.MethodPut,
395-
Path: "/apisix/admin/upstreams/1",
396-
Body: string(_createUpstreamBody),
397-
Headers: map[string]string{"Authorization": base.GetToken()},
398-
ExpectStatus: http.StatusOK,
399-
})
400-
})
401-
It("hit the route using upstream 1", func() {
402-
base.RunTestCase(base.HttpTestCase{
403-
Object: base.APISIXExpect(),
404-
Method: http.MethodGet,
405-
Path: "/",
406-
ExpectStatus: http.StatusOK,
407-
ExpectBody: "google",
408-
Sleep: base.SleepTime,
409-
})
410-
})
411-
It("delete route", func() {
412-
base.RunTestCase(base.HttpTestCase{
413-
Object: base.ManagerApiExpect(),
414-
Method: http.MethodDelete,
415-
Path: "/apisix/admin/routes/1",
416-
Headers: map[string]string{"Authorization": base.GetToken()},
417-
ExpectStatus: http.StatusOK,
418-
})
419-
})
420-
It("delete upstream", func() {
421-
base.RunTestCase(base.HttpTestCase{
422-
Object: base.ManagerApiExpect(),
423-
Method: http.MethodDelete,
424-
Path: "/apisix/admin/upstreams/1",
425-
Headers: map[string]string{"Authorization": base.GetToken()},
426-
ExpectStatus: http.StatusOK,
427-
})
428-
})
429-
It("hit the route just deleted", func() {
430-
base.RunTestCase(base.HttpTestCase{
431-
Object: base.APISIXExpect(),
432-
Method: http.MethodGet,
433-
Path: "/get",
434-
ExpectStatus: http.StatusNotFound,
435-
ExpectBody: "{\"error_msg\":\"404 Route Not Found\"}\n",
436-
Sleep: base.SleepTime,
437-
})
438-
})
439-
})
332+
var _ = DescribeTable("Upstream update with domain",
333+
func(tc base.HttpTestCase) {
334+
base.RunTestCase(tc)
335+
},
336+
Entry("create upstream success", base.HttpTestCase{
337+
Object: base.ManagerApiExpect(),
338+
Method: http.MethodPut,
339+
Path: "/apisix/admin/upstreams/1",
340+
Body: `{
341+
"name": "upstream1",
342+
"nodes": [{
343+
"host": "` + base.UpstreamIp + `",
344+
"port": 1980,
345+
"weight": 1,
346+
"priority": 10
347+
}],
348+
"type": "roundrobin"
349+
}`,
350+
Headers: map[string]string{"Authorization": base.GetToken()},
351+
ExpectStatus: http.StatusOK,
352+
ExpectBody: `"code":0`,
353+
Sleep: base.SleepTime,
354+
}),
355+
Entry("create route using the upstream(use proxy rewriteproxy rewrite plugin)", base.HttpTestCase{
356+
Object: base.ManagerApiExpect(),
357+
Method: http.MethodPut,
358+
Path: "/apisix/admin/routes/1",
359+
Body: `{
360+
"name": "route1",
361+
"uri": "/*",
362+
"upstream_id": "1"
363+
}`,
364+
Headers: map[string]string{"Authorization": base.GetToken()},
365+
ExpectStatus: http.StatusOK,
366+
Sleep: base.SleepTime,
367+
}),
368+
Entry("update upstream with domain", base.HttpTestCase{
369+
Object: base.ManagerApiExpect(),
370+
Method: http.MethodPut,
371+
Path: "/apisix/admin/upstreams/1",
372+
Body: `{
373+
"name": "upstream1",
374+
"nodes": [{
375+
"host": "` + base.UpstreamHTTPBinIp + `",
376+
"port": 80,
377+
"weight": 1,
378+
"priority": 10
379+
}],
380+
"type": "roundrobin",
381+
"pass_host": "node"
382+
}`,
383+
Headers: map[string]string{"Authorization": base.GetToken()},
384+
ExpectStatus: http.StatusOK,
385+
Sleep: base.SleepTime,
386+
}),
387+
Entry("hit the route using upstream 1", base.HttpTestCase{
388+
Object: base.APISIXExpect(),
389+
Method: http.MethodGet,
390+
Headers: map[string]string{
391+
"Host": "iamhttpbin.org",
392+
},
393+
Path: "/anything",
394+
ExpectStatus: http.StatusOK,
395+
ExpectBody: "http://iamhttpbin.org/anything",
396+
Sleep: base.SleepTime,
397+
}),
398+
Entry("delete route", base.HttpTestCase{
399+
Object: base.ManagerApiExpect(),
400+
Method: http.MethodDelete,
401+
Path: "/apisix/admin/routes/1",
402+
Headers: map[string]string{"Authorization": base.GetToken()},
403+
ExpectStatus: http.StatusOK,
404+
}),
405+
Entry("delete upstream", base.HttpTestCase{
406+
Object: base.ManagerApiExpect(),
407+
Method: http.MethodDelete,
408+
Path: "/apisix/admin/upstreams/1",
409+
Headers: map[string]string{"Authorization": base.GetToken()},
410+
ExpectStatus: http.StatusOK,
411+
}),
412+
Entry("hit the route just deleted", base.HttpTestCase{
413+
Object: base.APISIXExpect(),
414+
Method: http.MethodGet,
415+
Path: "/get",
416+
ExpectStatus: http.StatusNotFound,
417+
ExpectBody: `{"error_msg":"404 Route Not Found"}`,
418+
Sleep: base.SleepTime,
419+
}),
420+
)
440421

441422
var _ = Describe("Upstream chash remote addr", func() {
442423
It("create chash upstream with key (remote_addr)", func() {

0 commit comments

Comments
 (0)