From 5c95f94d6430eab5c2c9f166ec07ae209befb06c Mon Sep 17 00:00:00 2001 From: nic-chen Date: Thu, 10 Dec 2020 23:56:47 +0800 Subject: [PATCH 1/7] ci: display more meaningful information when running E2E test cases fail --- api/test/e2e/balancer_test.go | 10 +- api/test/e2e/base.go | 104 +++++++++--------- api/test/e2e/consumer_test.go | 12 +- api/test/e2e/id_compatible_test.go | 6 +- api/test/e2e/route_remote_addr_test.go | 2 +- api/test/e2e/route_service_upstream_test.go | 10 +- api/test/e2e/route_test.go | 8 +- api/test/e2e/route_with_auth_plugin_test.go | 4 +- api/test/e2e/route_with_limit_plugin_test.go | 6 +- api/test/e2e/route_with_log_plugin_test.go | 6 +- .../e2e/route_with_management_fileds_test.go | 8 +- api/test/e2e/route_with_methods_test.go | 2 +- api/test/e2e/route_with_metric_plugin_test.go | 2 +- api/test/e2e/route_with_plugin_cors_test.go | 10 +- .../route_with_plugin_orchestration_test.go | 2 +- .../route_with_plugin_proxy_rewrite_test.go | 2 +- api/test/e2e/route_with_priority_test.go | 2 +- api/test/e2e/route_with_trace_plugin_test.go | 6 +- api/test/e2e/route_with_uri_uris_test.go | 2 +- .../e2e/route_with_valid_remote_addr_test.go | 2 +- api/test/e2e/route_with_vars_test.go | 2 +- api/test/e2e/ssl_test.go | 5 +- api/test/e2e/upstream_chash_hash_on_test.go | 14 +-- ...pstream_chash_query_string_arg_xxx_test.go | 6 +- api/test/e2e/upstream_test.go | 14 +-- 25 files changed, 124 insertions(+), 123 deletions(-) diff --git a/api/test/e2e/balancer_test.go b/api/test/e2e/balancer_test.go index 1801d959bd..283c9fa919 100644 --- a/api/test/e2e/balancer_test.go +++ b/api/test/e2e/balancer_test.go @@ -69,7 +69,7 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -125,7 +125,7 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -171,7 +171,7 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -210,7 +210,7 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -261,6 +261,6 @@ func TestBalancer_Delete(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/base.go b/api/test/e2e/base.go index 8f4116acb3..cd5510d717 100644 --- a/api/test/e2e/base.go +++ b/api/test/e2e/base.go @@ -134,66 +134,68 @@ type HttpTestCase struct { Sleep time.Duration //ms } -func testCaseCheck(tc HttpTestCase) { - //init - expectObj := tc.Object - var req *httpexpect.Request - switch tc.Method { - case http.MethodGet: - req = expectObj.GET(tc.Path) - case http.MethodPut: - req = expectObj.PUT(tc.Path) - case http.MethodPost: - req = expectObj.POST(tc.Path) - case http.MethodDelete: - req = expectObj.DELETE(tc.Path) - case http.MethodPatch: - req = expectObj.PATCH(tc.Path) - case http.MethodOptions: - req = expectObj.OPTIONS(tc.Path) - default: - } +func testCaseCheck(tc HttpTestCase, t *testing.T) { + t.Run(tc.caseDesc, func(t *testing.T) { + //init + expectObj := tc.Object + var req *httpexpect.Request + switch tc.Method { + case http.MethodGet: + req = expectObj.GET(tc.Path) + case http.MethodPut: + req = expectObj.PUT(tc.Path) + case http.MethodPost: + req = expectObj.POST(tc.Path) + case http.MethodDelete: + req = expectObj.DELETE(tc.Path) + case http.MethodPatch: + req = expectObj.PATCH(tc.Path) + case http.MethodOptions: + req = expectObj.OPTIONS(tc.Path) + default: + } - if req == nil { - panic("fail to init request") - } + if req == nil { + panic("fail to init request") + } - if tc.Sleep != 0 { - time.Sleep(tc.Sleep) - } + if tc.Sleep != 0 { + time.Sleep(tc.Sleep) + } - if tc.Query != "" { - req.WithQueryString(tc.Query) - } + if tc.Query != "" { + req.WithQueryString(tc.Query) + } - //set header - for key, val := range tc.Headers { - req.WithHeader(key, val) - } + //set header + for key, val := range tc.Headers { + req.WithHeader(key, val) + } - //set body - if tc.Body != "" { - req.WithText(tc.Body) - } + //set body + if tc.Body != "" { + req.WithText(tc.Body) + } - //respond check - resp := req.Expect() + //respond check + resp := req.Expect() - //match http status - if tc.ExpectStatus != 0 { - resp.Status(tc.ExpectStatus) - } + //match http status + if tc.ExpectStatus != 0 { + resp.Status(tc.ExpectStatus) + } - //match headers - if tc.ExpectHeaders != nil { - for key, val := range tc.ExpectHeaders { - resp.Header(key).Equal(val) + //match headers + if tc.ExpectHeaders != nil { + for key, val := range tc.ExpectHeaders { + resp.Header(key).Equal(val) + } } - } - //match body - if tc.ExpectBody != "" { - resp.Body().Contains(tc.ExpectBody) - } + //match body + if tc.ExpectBody != "" { + resp.Body().Contains(tc.ExpectBody) + } + }) } diff --git a/api/test/e2e/consumer_test.go b/api/test/e2e/consumer_test.go index e7ba2316b5..e237fdc3cc 100644 --- a/api/test/e2e/consumer_test.go +++ b/api/test/e2e/consumer_test.go @@ -134,7 +134,7 @@ func TestConsumer_with_key_auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -170,7 +170,7 @@ func TestConsumer_with_notexist_plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -258,7 +258,7 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -279,7 +279,7 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } basepath := "http://127.0.0.1:9000/apisix/admin/consumers" @@ -317,7 +317,7 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // get the consumer @@ -355,6 +355,6 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/id_compatible_test.go b/api/test/e2e/id_compatible_test.go index d9ad70d0dc..3cd55660f4 100644 --- a/api/test/e2e/id_compatible_test.go +++ b/api/test/e2e/id_compatible_test.go @@ -150,7 +150,7 @@ func TestID_Using_Int(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -231,7 +231,7 @@ func TestID_Using_String(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -332,6 +332,6 @@ func TestID_Crossing(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_remote_addr_test.go b/api/test/e2e/route_remote_addr_test.go index 8cdf6e3225..81725ad94b 100644 --- a/api/test/e2e/route_remote_addr_test.go +++ b/api/test/e2e/route_remote_addr_test.go @@ -116,6 +116,6 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_service_upstream_test.go b/api/test/e2e/route_service_upstream_test.go index d29964f9e7..4656c22fa1 100644 --- a/api/test/e2e/route_service_upstream_test.go +++ b/api/test/e2e/route_service_upstream_test.go @@ -119,7 +119,7 @@ func TestRoute_Invalid_Service_And_Service(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -178,7 +178,7 @@ func TestRoute_Create_Service(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for etcd sync @@ -219,7 +219,7 @@ func TestRoute_Delete_Service(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -276,7 +276,7 @@ func TestRoute_Create_Upstream(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for etcd sync @@ -317,6 +317,6 @@ func TestRoute_Delete_Upstream(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_test.go b/api/test/e2e/route_test.go index 5338ffafa4..9445cf200e 100644 --- a/api/test/e2e/route_test.go +++ b/api/test/e2e/route_test.go @@ -99,7 +99,7 @@ func TestRoute_Invalid_Host(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -174,7 +174,7 @@ func TestRoute_Create_With_Hosts(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -220,7 +220,7 @@ func TestRoute_Update_Routes_With_Hosts(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -255,6 +255,6 @@ func TestRoute_Delete_Routes_With_Hosts(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_auth_plugin_test.go b/api/test/e2e/route_with_auth_plugin_test.go index 4b8195dcb4..fc3f46ef60 100644 --- a/api/test/e2e/route_with_auth_plugin_test.go +++ b/api/test/e2e/route_with_auth_plugin_test.go @@ -87,7 +87,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } time.Sleep(sleepTime) @@ -170,7 +170,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_limit_plugin_test.go b/api/test/e2e/route_with_limit_plugin_test.go index 58bd57d36f..14ce2cdc25 100644 --- a/api/test/e2e/route_with_limit_plugin_test.go +++ b/api/test/e2e/route_with_limit_plugin_test.go @@ -114,7 +114,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -299,7 +299,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -450,6 +450,6 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_log_plugin_test.go b/api/test/e2e/route_with_log_plugin_test.go index b770d621dc..faaa6a628b 100644 --- a/api/test/e2e/route_with_log_plugin_test.go +++ b/api/test/e2e/route_with_log_plugin_test.go @@ -108,7 +108,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for process log @@ -167,7 +167,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for process log @@ -221,6 +221,6 @@ func TestRoute_With_Log_Plugin(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_management_fileds_test.go b/api/test/e2e/route_with_management_fileds_test.go index faa7c998db..23e7fb137c 100644 --- a/api/test/e2e/route_with_management_fileds_test.go +++ b/api/test/e2e/route_with_management_fileds_test.go @@ -71,7 +71,7 @@ func TestRoute_with_name_desc(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } //get the route @@ -127,7 +127,7 @@ func TestRoute_with_name_desc(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } //get the route (updated) @@ -156,7 +156,7 @@ func TestRoute_with_name_desc(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -225,6 +225,6 @@ func TestRoute_with_lable(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_methods_test.go b/api/test/e2e/route_with_methods_test.go index a3d9d1ca77..a47b31eee2 100644 --- a/api/test/e2e/route_with_methods_test.go +++ b/api/test/e2e/route_with_methods_test.go @@ -292,6 +292,6 @@ func TestRoute_with_methods(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_metric_plugin_test.go b/api/test/e2e/route_with_metric_plugin_test.go index 027e9ea18c..698d7d679e 100644 --- a/api/test/e2e/route_with_metric_plugin_test.go +++ b/api/test/e2e/route_with_metric_plugin_test.go @@ -138,6 +138,6 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_plugin_cors_test.go b/api/test/e2e/route_with_plugin_cors_test.go index d8afb919d1..278fe4a6f1 100644 --- a/api/test/e2e/route_with_plugin_cors_test.go +++ b/api/test/e2e/route_with_plugin_cors_test.go @@ -135,11 +135,11 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route with options method", - Object: APISIXExpect(t), - Method: http.MethodOptions, + caseDesc: "verify route with options method", + Object: APISIXExpect(t), + Method: http.MethodOptions, Headers: map[string]string{ - "Origin": "http://sub2.domain.com", + "Origin": "http://sub2.domain.com", }, Path: "/hello", ExpectStatus: http.StatusOK, @@ -223,7 +223,7 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_plugin_orchestration_test.go b/api/test/e2e/route_with_plugin_orchestration_test.go index c6d729b52b..cd2dcd3557 100644 --- a/api/test/e2e/route_with_plugin_orchestration_test.go +++ b/api/test/e2e/route_with_plugin_orchestration_test.go @@ -108,6 +108,6 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_plugin_proxy_rewrite_test.go b/api/test/e2e/route_with_plugin_proxy_rewrite_test.go index 7f091612e1..e5d2e60511 100644 --- a/api/test/e2e/route_with_plugin_proxy_rewrite_test.go +++ b/api/test/e2e/route_with_plugin_proxy_rewrite_test.go @@ -189,7 +189,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_priority_test.go b/api/test/e2e/route_with_priority_test.go index 34860b4fa1..d94b84b8ed 100644 --- a/api/test/e2e/route_with_priority_test.go +++ b/api/test/e2e/route_with_priority_test.go @@ -103,6 +103,6 @@ func TestRoute_with_priority(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_trace_plugin_test.go b/api/test/e2e/route_with_trace_plugin_test.go index c51718befa..cba099cb4e 100644 --- a/api/test/e2e/route_with_trace_plugin_test.go +++ b/api/test/e2e/route_with_trace_plugin_test.go @@ -70,7 +70,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for process log @@ -120,7 +120,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sleep for process log @@ -154,6 +154,6 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_uri_uris_test.go b/api/test/e2e/route_with_uri_uris_test.go index c538b19505..8b2a6a1098 100644 --- a/api/test/e2e/route_with_uri_uris_test.go +++ b/api/test/e2e/route_with_uri_uris_test.go @@ -111,6 +111,6 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_valid_remote_addr_test.go b/api/test/e2e/route_with_valid_remote_addr_test.go index 445fce1c1a..245d3826d0 100644 --- a/api/test/e2e/route_with_valid_remote_addr_test.go +++ b/api/test/e2e/route_with_valid_remote_addr_test.go @@ -192,6 +192,6 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_vars_test.go b/api/test/e2e/route_with_vars_test.go index c0b40d7ed3..e12b1a0700 100644 --- a/api/test/e2e/route_with_vars_test.go +++ b/api/test/e2e/route_with_vars_test.go @@ -312,6 +312,6 @@ func TestRoute_with_vars(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/ssl_test.go b/api/test/e2e/ssl_test.go index 85a332e36b..fd7effd713 100644 --- a/api/test/e2e/ssl_test.go +++ b/api/test/e2e/ssl_test.go @@ -122,7 +122,7 @@ func TestSSL_Basic(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // try again after deleting SSL, make a HTTPS request @@ -141,6 +141,5 @@ func TestSSL_Basic(t *testing.T) { Headers: map[string]string{"Authorization": token}, ExpectStatus: http.StatusOK, } - testCaseCheck(delRoute) - + testCaseCheck(delRoute, t) } diff --git a/api/test/e2e/upstream_chash_hash_on_test.go b/api/test/e2e/upstream_chash_hash_on_test.go index c0c927c974..b93495e614 100644 --- a/api/test/e2e/upstream_chash_hash_on_test.go +++ b/api/test/e2e/upstream_chash_hash_on_test.go @@ -68,7 +68,7 @@ func TestUpstream_chash_hash_on_custom_header(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -127,7 +127,7 @@ func TestUpstream_chash_hash_on_cookie(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -206,7 +206,7 @@ func TestUpstream_key_contains_uppercase_letters_and_hyphen(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -287,7 +287,7 @@ func TestUpstream_chash_hash_on_consumer(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -355,7 +355,7 @@ func TestUpstream_chash_hash_on_wrong_key(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -421,7 +421,7 @@ func TestUpstream_chash_hash_on_vars(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -485,6 +485,6 @@ func TestUpstream_Delete_hash_on(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go b/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go index 08a60350f9..d01d0e8924 100644 --- a/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go +++ b/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go @@ -72,7 +72,7 @@ func TestUpstream_chash_query_string(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -135,7 +135,7 @@ func TestUpstream_chash_arg_xxx(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // hit routes @@ -196,6 +196,6 @@ func TestUpstream_Delete_chash(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/upstream_test.go b/api/test/e2e/upstream_test.go index e61e024340..093430d19c 100644 --- a/api/test/e2e/upstream_test.go +++ b/api/test/e2e/upstream_test.go @@ -80,7 +80,7 @@ func TestUpstream_Create(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -114,7 +114,7 @@ func TestUpstream_Update(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -188,7 +188,7 @@ func TestRoute_Node_Host(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -238,7 +238,7 @@ func TestUpstream_chash_remote_addr(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } //hit routes @@ -309,7 +309,7 @@ func TestUpstream_chash_remote_addr(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } //hit routes @@ -378,7 +378,7 @@ func TestUpstream_chash_remote_addr(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -421,6 +421,6 @@ func TestUpstream_Delete(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } From 49f472432b0fdec9fb174b44f48fe45ea48530f0 Mon Sep 17 00:00:00 2001 From: nic-chen Date: Fri, 11 Dec 2020 10:27:55 +0800 Subject: [PATCH 2/7] ci: go test -v --- .github/workflows/backend-e2e-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-e2e-test.yml b/.github/workflows/backend-e2e-test.yml index 12d7767268..a5c8a30e04 100644 --- a/.github/workflows/backend-e2e-test.yml +++ b/.github/workflows/backend-e2e-test.yml @@ -29,4 +29,4 @@ jobs: - name: run test working-directory: ./api/test/e2e - run: go test + run: go test -v From ef518e8134b0ede25b4e11512a4921641b917243 Mon Sep 17 00:00:00 2001 From: nic-chen Date: Fri, 11 Dec 2020 10:30:21 +0800 Subject: [PATCH 3/7] fix: naming style --- api/test/e2e/balancer_test.go | 46 +++---- api/test/e2e/base.go | 4 +- api/test/e2e/consumer_test.go | 84 ++++++------ api/test/e2e/id_compatible_test.go | 104 +++++++-------- api/test/e2e/route_remote_addr_test.go | 30 ++--- api/test/e2e/route_service_upstream_test.go | 78 +++++------ api/test/e2e/route_test.go | 70 +++++----- api/test/e2e/route_with_auth_plugin_test.go | 34 ++--- api/test/e2e/route_with_limit_plugin_test.go | 108 ++++++++-------- api/test/e2e/route_with_log_plugin_test.go | 30 ++--- .../e2e/route_with_management_fileds_test.go | 40 +++--- api/test/e2e/route_with_methods_test.go | 78 +++++------ api/test/e2e/route_with_metric_plugin_test.go | 32 ++--- api/test/e2e/route_with_plugin_cors_test.go | 62 ++++----- .../route_with_plugin_orchestration_test.go | 16 +-- .../route_with_plugin_proxy_rewrite_test.go | 46 +++---- api/test/e2e/route_with_priority_test.go | 24 ++-- api/test/e2e/route_with_trace_plugin_test.go | 26 ++-- api/test/e2e/route_with_uri_uris_test.go | 26 ++-- .../e2e/route_with_valid_remote_addr_test.go | 54 ++++---- api/test/e2e/route_with_vars_test.go | 74 +++++------ api/test/e2e/ssl_test.go | 18 +-- api/test/e2e/upstream_chash_hash_on_test.go | 86 ++++++------ ...pstream_chash_query_string_arg_xxx_test.go | 30 ++--- api/test/e2e/upstream_test.go | 122 +++++++++--------- 25 files changed, 661 insertions(+), 661 deletions(-) diff --git a/api/test/e2e/balancer_test.go b/api/test/e2e/balancer_test.go index 283c9fa919..79c8be922b 100644 --- a/api/test/e2e/balancer_test.go +++ b/api/test/e2e/balancer_test.go @@ -28,10 +28,10 @@ import ( func TestBalancer_roundrobin_with_weight(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create upstream (roundrobin with same weight)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream (roundrobin with same weight)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -54,10 +54,10 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -98,10 +98,10 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create upstream (roundrobin with different weight)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream (roundrobin with different weight)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -149,10 +149,10 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create upstream (roundrobin with weight 1 and 0) ", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream (roundrobin with weight 1 and 0) ", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -193,10 +193,10 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create upstream (roundrobin with weight only 1 ) ", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream (roundrobin with weight only 1 ) ", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -234,7 +234,7 @@ func TestBalancer_roundrobin_with_weight(t *testing.T) { func TestBalancer_Delete(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/1", @@ -242,7 +242,7 @@ func TestBalancer_Delete(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete upstream", + Desc: "delete upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -250,7 +250,7 @@ func TestBalancer_Delete(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", diff --git a/api/test/e2e/base.go b/api/test/e2e/base.go index cd5510d717..96a85c1346 100644 --- a/api/test/e2e/base.go +++ b/api/test/e2e/base.go @@ -118,7 +118,7 @@ func APISIXHTTPSExpect(t *testing.T) *httpexpect.Expect { var sleepTime = time.Duration(300) * time.Millisecond type HttpTestCase struct { - caseDesc string + Desc string Object *httpexpect.Expect Method string Path string @@ -135,7 +135,7 @@ type HttpTestCase struct { } func testCaseCheck(tc HttpTestCase, t *testing.T) { - t.Run(tc.caseDesc, func(t *testing.T) { + t.Run(tc.Desc, func(t *testing.T) { //init expectObj := tc.Object var req *httpexpect.Request diff --git a/api/test/e2e/consumer_test.go b/api/test/e2e/consumer_test.go index e237fdc3cc..d6079577b9 100644 --- a/api/test/e2e/consumer_test.go +++ b/api/test/e2e/consumer_test.go @@ -30,10 +30,10 @@ import ( func TestConsumer_with_key_auth(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -52,7 +52,7 @@ func TestConsumer_with_key_auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit route without apikey", + Desc: "hit route without apikey", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -61,10 +61,10 @@ func TestConsumer_with_key_auth(t *testing.T) { Sleep: sleepTime * 2, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -78,7 +78,7 @@ func TestConsumer_with_key_auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit route with correct apikey", + Desc: "hit route with correct apikey", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -88,7 +88,7 @@ func TestConsumer_with_key_auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit route with incorrect apikey", + Desc: "hit route with incorrect apikey", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -98,7 +98,7 @@ func TestConsumer_with_key_auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -106,7 +106,7 @@ func TestConsumer_with_key_auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete consumer (as delete not exist consumer)", + Desc: "delete consumer (as delete not exist consumer)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -114,7 +114,7 @@ func TestConsumer_with_key_auth(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "hit route (consumer deleted)", + Desc: "hit route (consumer deleted)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -124,7 +124,7 @@ func TestConsumer_with_key_auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -141,10 +141,10 @@ func TestConsumer_with_key_auth(t *testing.T) { func TestConsumer_with_notexist_plugin(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create consumer with not exist plugin", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer with not exist plugin", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -159,7 +159,7 @@ func TestConsumer_with_notexist_plugin(t *testing.T) { ExpectBody: "schema validate failed: schema not found, path: plugins.key-authaa", }, { - caseDesc: "verify the consumer", + Desc: "verify the consumer", Object: ManagerApiExpect(t), Path: "/apisix/admin/consumers/jack", Method: http.MethodGet, @@ -177,10 +177,10 @@ func TestConsumer_with_notexist_plugin(t *testing.T) { func TestConsumer_add_consumer_with_labels(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create the consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create the consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "labels": { @@ -199,7 +199,7 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the consumer", + Desc: "verify the consumer", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -209,10 +209,10 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create the route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create the route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -231,7 +231,7 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route with correct apikey", + Desc: "hit the route with correct apikey", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -240,7 +240,7 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the consumer", + Desc: "delete the consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -248,7 +248,7 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete the route", + Desc: "delete the route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -265,10 +265,10 @@ func TestConsumer_add_consumer_with_labels(t *testing.T) { func TestConsumer_with_createtime_updatetime(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create the consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create the consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username":"jack", "desc": "new consumer" @@ -302,10 +302,10 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "update the consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "update the consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username":"jack", "desc": "updated consumer" @@ -336,7 +336,7 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "delete the consumer", + Desc: "delete the consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -344,7 +344,7 @@ func TestConsumer_with_createtime_updatetime(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "after delete consumer verify it again", + Desc: "after delete consumer verify it again", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", diff --git a/api/test/e2e/id_compatible_test.go b/api/test/e2e/id_compatible_test.go index 3cd55660f4..7a72be5e70 100644 --- a/api/test/e2e/id_compatible_test.go +++ b/api/test/e2e/id_compatible_test.go @@ -24,10 +24,10 @@ import ( func TestID_Using_Int(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams", + Desc: "create upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams", Body: `{ "id": 1, "nodes": [{ @@ -41,10 +41,10 @@ func TestID_Using_Int(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/hello", "upstream_id": 1 @@ -54,7 +54,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just created", + Desc: "hit the route just created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -63,10 +63,10 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create service", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/services", + Desc: "create service", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/services", Body: `{ "id": 1, "upstream_id": 1 @@ -75,10 +75,10 @@ func TestID_Using_Int(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "update route to use the service just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "update route to use the service just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/hello", "service_id": 1 @@ -88,7 +88,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just updated", + Desc: "hit the route just updated", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -97,7 +97,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route", + Desc: "delete the route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/1", @@ -105,7 +105,7 @@ func TestID_Using_Int(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete the service", + Desc: "delete the service", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/services/1", @@ -114,7 +114,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "make sure the service has been deleted", + Desc: "make sure the service has been deleted", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/services/1", @@ -123,7 +123,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the upstream", + Desc: "delete the upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -131,7 +131,7 @@ func TestID_Using_Int(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the upstream has been deleted", + Desc: "make sure the upstream has been deleted", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/upstreams/1", @@ -140,7 +140,7 @@ func TestID_Using_Int(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit deleted route", + Desc: "hit deleted route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -157,10 +157,10 @@ func TestID_Using_Int(t *testing.T) { func TestID_Using_String(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams", + Desc: "create upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams", Body: `{ "id": "2", "nodes": [{ @@ -174,10 +174,10 @@ func TestID_Using_String(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/2", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/2", Body: `{ "uri": "/hello", "upstream_id": "2" @@ -187,7 +187,7 @@ func TestID_Using_String(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just created", + Desc: "hit the route just created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -196,7 +196,7 @@ func TestID_Using_String(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route", + Desc: "delete the route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/2", @@ -204,7 +204,7 @@ func TestID_Using_String(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete the upstream", + Desc: "delete the upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/2", @@ -212,7 +212,7 @@ func TestID_Using_String(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the upstream has been deleted", + Desc: "make sure the upstream has been deleted", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/upstreams/2", @@ -221,7 +221,7 @@ func TestID_Using_String(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit deleted route", + Desc: "hit deleted route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -238,10 +238,10 @@ func TestID_Using_String(t *testing.T) { func TestID_Crossing(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create upstream by admin api", - Object: APISIXExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams", + Desc: "create upstream by admin api", + Object: APISIXExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams", Body: `{ "id": 3, "nodes": [{ @@ -255,10 +255,10 @@ func TestID_Crossing(t *testing.T) { ExpectStatus: http.StatusCreated, }, { - caseDesc: "create route by admin api", - Object: APISIXExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/3", + Desc: "create route by admin api", + Object: APISIXExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/3", Body: `{ "uri": "/hello", "upstream_id": 3 @@ -268,7 +268,7 @@ func TestID_Crossing(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify that the upstream is available for manager api", + Desc: "verify that the upstream is available for manager api", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/upstreams/3", @@ -278,7 +278,7 @@ func TestID_Crossing(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify that the route is available for manager api", + Desc: "verify that the route is available for manager api", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/routes/3", @@ -288,7 +288,7 @@ func TestID_Crossing(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just created", + Desc: "hit the route just created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -297,7 +297,7 @@ func TestID_Crossing(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route", + Desc: "delete the route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/3", @@ -305,7 +305,7 @@ func TestID_Crossing(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete the upstream", + Desc: "delete the upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/3", @@ -313,7 +313,7 @@ func TestID_Crossing(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the upstream has been deleted", + Desc: "make sure the upstream has been deleted", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/upstreams/3", @@ -322,7 +322,7 @@ func TestID_Crossing(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit deleted route", + Desc: "hit deleted route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_remote_addr_test.go b/api/test/e2e/route_remote_addr_test.go index 81725ad94b..658ced6b4c 100644 --- a/api/test/e2e/route_remote_addr_test.go +++ b/api/test/e2e/route_remote_addr_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_add_with_invalid_remote_addr(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "config route with invalid remote_addr", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "config route with invalid remote_addr", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addr": "127.0.0.", @@ -45,7 +45,7 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { ExpectBody: "\"code\":10000,\"message\":\"schema validate failed: remote_addr: Must validate at least one schema (anyOf)\\nremote_addr: Does not match pattern '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$'\"", }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -54,10 +54,10 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "config route with invalid remote_addr", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "config route with invalid remote_addr", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addr": "127.0.0.aa", @@ -75,7 +75,7 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { ExpectBody: "\"code\":10000,\"message\":\"schema validate failed: remote_addr: Must validate at least one schema (anyOf)\\nremote_addr: Does not match pattern '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$'\"", }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -84,10 +84,10 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "config route with invalid remote_addrs", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "config route with invalid remote_addrs", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addrs": ["127.0.0.1","192.168.0."], @@ -105,7 +105,7 @@ func TestRoute_add_with_invalid_remote_addr(t *testing.T) { ExpectBody: "\"code\":10000,\"message\":\"schema validate failed: remote_addrs.1: Must validate at least one schema (anyOf)\\nremote_addrs.1: Does not match pattern '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$'\"", }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_service_upstream_test.go b/api/test/e2e/route_service_upstream_test.go index 4656c22fa1..b448d4cfdb 100644 --- a/api/test/e2e/route_service_upstream_test.go +++ b/api/test/e2e/route_service_upstream_test.go @@ -60,10 +60,10 @@ func batchTestServerPort(t *testing.T, times int) map[string]int { func TestRoute_Invalid_Service_And_Service(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "use service that not exist - dashboard", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "use service that not exist - dashboard", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "service_id": "not-exists" @@ -72,17 +72,17 @@ func TestRoute_Invalid_Service_And_Service(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "hit invalid route on data plane", + Desc: "hit invalid route on data plane", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", ExpectCode: http.StatusNotFound, }, { - caseDesc: "use upstream that not exist", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "use upstream that not exist", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "upstream_id": "not-exists" @@ -91,17 +91,17 @@ func TestRoute_Invalid_Service_And_Service(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "hit invalid route on data plane", + Desc: "hit invalid route on data plane", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", ExpectCode: http.StatusNotFound, }, { - caseDesc: "create service and upstream together at the same time", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create service and upstream together at the same time", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "service_id": "not-exists-service", @@ -111,7 +111,7 @@ func TestRoute_Invalid_Service_And_Service(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "hit invalid route on data plane", + Desc: "hit invalid route on data plane", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -126,7 +126,7 @@ func TestRoute_Invalid_Service_And_Service(t *testing.T) { func TestRoute_Create_Service(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route has not created", + Desc: "make sure the route has not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -134,10 +134,10 @@ func TestRoute_Create_Service(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create service", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/services/200", + Desc: "create service", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/services/200", Body: `{ "upstream": { "type": "roundrobin", @@ -164,10 +164,10 @@ func TestRoute_Create_Service(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the service just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route using the service just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/server_port", "service_id": "200" @@ -195,7 +195,7 @@ func TestRoute_Create_Service(t *testing.T) { func TestRoute_Delete_Service(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -203,7 +203,7 @@ func TestRoute_Delete_Service(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "remove service", + Desc: "remove service", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/services/200", @@ -211,7 +211,7 @@ func TestRoute_Delete_Service(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit deleted route", + Desc: "hit deleted route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -226,10 +226,10 @@ func TestRoute_Delete_Service(t *testing.T) { func TestRoute_Create_Upstream(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [ { @@ -254,7 +254,7 @@ func TestRoute_Create_Upstream(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has not created", + Desc: "make sure the route has not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -262,10 +262,10 @@ func TestRoute_Create_Upstream(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -293,7 +293,7 @@ func TestRoute_Create_Upstream(t *testing.T) { func TestRoute_Delete_Upstream(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -301,7 +301,7 @@ func TestRoute_Delete_Upstream(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "remove upstream", + Desc: "remove upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -309,7 +309,7 @@ func TestRoute_Delete_Upstream(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit deleted route", + Desc: "hit deleted route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", diff --git a/api/test/e2e/route_test.go b/api/test/e2e/route_test.go index 9445cf200e..ef7d1cac26 100644 --- a/api/test/e2e/route_test.go +++ b/api/test/e2e/route_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_Invalid_Host(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "invalid host", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "invalid host", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello_", "host": "$%$foo.com", @@ -42,10 +42,10 @@ func TestRoute_Invalid_Host(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "invalid hosts", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "invalid hosts", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "hosts": ["$%$foo.com", "*.bar.com"], @@ -60,10 +60,10 @@ func TestRoute_Invalid_Host(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "create route with host and hosts together at the same time", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with host and hosts together at the same time", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "host": "github.com", @@ -79,7 +79,7 @@ func TestRoute_Invalid_Host(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "hit route not created", + Desc: "hit route not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -88,7 +88,7 @@ func TestRoute_Invalid_Host(t *testing.T) { ExpectBody: "{\"error_msg\":\"404 Route Not Found\"}\n", }, { - caseDesc: "hit route not created", + Desc: "hit route not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -106,7 +106,7 @@ func TestRoute_Invalid_Host(t *testing.T) { func TestRoute_Create_With_Hosts(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "hit route that not exist", + Desc: "hit route that not exist", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -115,10 +115,10 @@ func TestRoute_Create_With_Hosts(t *testing.T) { ExpectBody: "{\"error_msg\":\"404 Route Not Found\"}\n", }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "hosts": ["foo.com", "*.bar.com"], @@ -133,10 +133,10 @@ func TestRoute_Create_With_Hosts(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route with int uri", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with int uri", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": 123456 }`, @@ -144,7 +144,7 @@ func TestRoute_Create_With_Hosts(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "hit the route just created - wildcard domain name", + Desc: "hit the route just created - wildcard domain name", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -154,7 +154,7 @@ func TestRoute_Create_With_Hosts(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just created", + Desc: "hit the route just created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -163,7 +163,7 @@ func TestRoute_Create_With_Hosts(t *testing.T) { ExpectBody: "hello world\n", }, { - caseDesc: "hit the route not exists", + Desc: "hit the route not exists", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_111", @@ -181,10 +181,10 @@ func TestRoute_Create_With_Hosts(t *testing.T) { func TestRoute_Update_Routes_With_Hosts(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "update route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello1", "hosts": ["bar.com"], @@ -199,7 +199,7 @@ func TestRoute_Update_Routes_With_Hosts(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just updated", + Desc: "hit the route just updated", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -209,7 +209,7 @@ func TestRoute_Update_Routes_With_Hosts(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just updated", + Desc: "hit the route just updated", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello1", @@ -227,7 +227,7 @@ func TestRoute_Update_Routes_With_Hosts(t *testing.T) { func TestRoute_Delete_Routes_With_Hosts(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -235,7 +235,7 @@ func TestRoute_Delete_Routes_With_Hosts(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete not exist route", + Desc: "delete not exist route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/not-exist", @@ -243,7 +243,7 @@ func TestRoute_Delete_Routes_With_Hosts(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello1", diff --git a/api/test/e2e/route_with_auth_plugin_test.go b/api/test/e2e/route_with_auth_plugin_test.go index fc3f46ef60..ef5e290eb4 100644 --- a/api/test/e2e/route_with_auth_plugin_test.go +++ b/api/test/e2e/route_with_auth_plugin_test.go @@ -27,7 +27,7 @@ import ( func TestRoute_With_Auth_Plugin(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -35,10 +35,10 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -58,7 +58,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectBody: `"code":0`, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -66,10 +66,10 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -106,7 +106,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { // verify token and clean test data tests = []HttpTestCase{ { - caseDesc: "verify route without jwt token", + Desc: "verify route without jwt token", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -115,7 +115,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route with correct jwt token", + Desc: "verify route with correct jwt token", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -124,7 +124,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route with incorrect jwt token", + Desc: "verify route with incorrect jwt token", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -133,7 +133,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectBody: `{"message":"invalid jwt string"}`, }, { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -141,7 +141,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with the jwt token from just deleted consumer", + Desc: "verify route with the jwt token from just deleted consumer", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -151,7 +151,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -159,7 +159,7 @@ func TestRoute_With_Auth_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_limit_plugin_test.go b/api/test/e2e/route_with_limit_plugin_test.go index 14ce2cdc25..ab3a4c0e48 100644 --- a/api/test/e2e/route_with_limit_plugin_test.go +++ b/api/test/e2e/route_with_limit_plugin_test.go @@ -25,7 +25,7 @@ import ( func TestRoute_With_Limit_Plugin(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -33,10 +33,10 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -61,7 +61,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { ExpectBody: `"code":0`, }, { - caseDesc: "verify route that should not be limited", + Desc: "verify route that should not be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -70,7 +70,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route that should not be limited 2", + Desc: "verify route that should not be limited 2", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -78,7 +78,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route that should be limited", + Desc: "verify route that should be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -86,7 +86,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { ExpectBody: "503 Service Temporarily Unavailable", }, { - caseDesc: "verify route that should not be limited since time window pass", + Desc: "verify route that should not be limited since time window pass", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -95,7 +95,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { Sleep: 3 * time.Second, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -103,7 +103,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -121,7 +121,7 @@ func TestRoute_With_Limit_Plugin(t *testing.T) { func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -129,10 +129,10 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -158,7 +158,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: `"code":0`, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -166,10 +166,10 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -182,10 +182,10 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create consumer 2", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer 2", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "pony", "plugins": { @@ -198,7 +198,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route that should not be limited", + Desc: "verify route that should not be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -208,7 +208,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route that should not be limited 2", + Desc: "verify route that should not be limited 2", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -217,7 +217,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route that should be limited", + Desc: "verify route that should be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -226,7 +226,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: "503 Service Temporarily Unavailable", }, { - caseDesc: "verify route that should not be limited (other consumer)", + Desc: "verify route that should not be limited (other consumer)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -235,7 +235,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route that should not be limited since time window pass", + Desc: "verify route that should not be limited since time window pass", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -245,7 +245,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { Sleep: 2 * time.Second, }, { - caseDesc: "delete consumer pony", + Desc: "delete consumer pony", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/pony", @@ -253,7 +253,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete consumer jack", + Desc: "delete consumer jack", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -261,7 +261,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure pony has been deleted", + Desc: "make sure pony has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -271,7 +271,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "make sure jack has been deleted", + Desc: "make sure jack has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -280,7 +280,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectBody: `{"message":"Missing related consumer"}`, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -288,7 +288,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -306,7 +306,7 @@ func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) { func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -314,10 +314,10 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -343,7 +343,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: `"code":0`, }, { - caseDesc: "verify route that should not be limited", + Desc: "verify route that should not be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -352,7 +352,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route that should not be limited 2", + Desc: "verify route that should not be limited 2", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -360,7 +360,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route that should be limited", + Desc: "verify route that should be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -368,7 +368,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: "503 Service Temporarily Unavailable", }, { - caseDesc: "verify route that should not be limited since time window pass", + Desc: "verify route that should not be limited since time window pass", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -377,10 +377,10 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { Sleep: 2 * time.Second, }, { - caseDesc: "update route to disable plugin limit-count", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route to disable plugin limit-count", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -406,7 +406,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: `"code":0`, }, { - caseDesc: "verify route that should not be limited", + Desc: "verify route that should not be limited", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -415,7 +415,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route that should not be limited (exceed config count)", + Desc: "verify route that should not be limited (exceed config count)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -423,7 +423,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "verify route that should not be limited (exceed config count again)", + Desc: "verify route that should not be limited (exceed config count again)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -431,7 +431,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -439,7 +439,7 @@ func TestRoute_With_Limit_Count_And_Disable(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_log_plugin_test.go b/api/test/e2e/route_with_log_plugin_test.go index faaa6a628b..2203d1b287 100644 --- a/api/test/e2e/route_with_log_plugin_test.go +++ b/api/test/e2e/route_with_log_plugin_test.go @@ -57,7 +57,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -65,10 +65,10 @@ func TestRoute_With_Log_Plugin(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "plugins": { @@ -97,7 +97,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access route to trigger log", + Desc: "access route to trigger log", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -124,10 +124,10 @@ func TestRoute_With_Log_Plugin(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create route with wrong https endpoint", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r2", + Desc: "create route with wrong https endpoint", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r2", Body: `{ "uri": "/hello", "plugins": { @@ -156,7 +156,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access route to trigger log", + Desc: "access route to trigger log", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -185,7 +185,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -193,7 +193,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -202,7 +202,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route 2", + Desc: "delete route 2", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r2", @@ -210,7 +210,7 @@ func TestRoute_With_Log_Plugin(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route 2 has been deleted", + Desc: "make sure the route 2 has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_management_fileds_test.go b/api/test/e2e/route_with_management_fileds_test.go index 23e7fb137c..c5bb67e378 100644 --- a/api/test/e2e/route_with_management_fileds_test.go +++ b/api/test/e2e/route_with_management_fileds_test.go @@ -29,10 +29,10 @@ import ( func TestRoute_with_name_desc(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "config route with name and desc (r1)", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "config route with name and desc (r1)", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "name": "jack", @@ -50,7 +50,7 @@ func TestRoute_with_name_desc(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route's uri (r1)", + Desc: "access the route's uri (r1)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -60,7 +60,7 @@ func TestRoute_with_name_desc(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the route's content (r1)", + Desc: "verify the route's content (r1)", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes/r1", Method: http.MethodGet, @@ -92,10 +92,10 @@ func TestRoute_with_name_desc(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "update the route (r1)", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "update the route (r1)", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "name": "new jack", @@ -115,7 +115,7 @@ func TestRoute_with_name_desc(t *testing.T) { }, { - caseDesc: "access the route's uri (r1)", + Desc: "access the route's uri (r1)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -146,7 +146,7 @@ func TestRoute_with_name_desc(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "delete the route (r1)", + Desc: "delete the route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -163,10 +163,10 @@ func TestRoute_with_name_desc(t *testing.T) { func TestRoute_with_lable(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "config route with labels (r1)", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "config route with labels (r1)", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "labels": { @@ -187,7 +187,7 @@ func TestRoute_with_lable(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route's uri (r1)", + Desc: "access the route's uri (r1)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -197,7 +197,7 @@ func TestRoute_with_lable(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the route's detail (r1)", + Desc: "verify the route's detail (r1)", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes/r1", Method: http.MethodGet, @@ -207,7 +207,7 @@ func TestRoute_with_lable(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route (r1)", + Desc: "delete the route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -215,7 +215,7 @@ func TestRoute_with_lable(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route after delete it", + Desc: "access the route after delete it", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_methods_test.go b/api/test/e2e/route_with_methods_test.go index a47b31eee2..07efdcc6bf 100644 --- a/api/test/e2e/route_with_methods_test.go +++ b/api/test/e2e/route_with_methods_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_with_methods(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "add route with invalid method", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with invalid method", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["TEST"], @@ -44,7 +44,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -53,10 +53,10 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "add route with valid method", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with valid method", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -73,7 +73,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -83,7 +83,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -91,10 +91,10 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "add route with valid methods", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with valid methods", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET", "POST", "PUT", "DELETE", "PATCH"], @@ -111,7 +111,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route by post", + Desc: "verify route by post", Object: APISIXExpect(t), Method: http.MethodPost, Path: "/hello", @@ -122,7 +122,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by put", + Desc: "verify route by put", Object: APISIXExpect(t), Method: http.MethodPut, Path: "/hello", @@ -133,7 +133,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by get", + Desc: "verify route by get", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -143,7 +143,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by delete", + Desc: "verify route by delete", Object: APISIXExpect(t), Method: http.MethodDelete, Path: "/hello", @@ -153,7 +153,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by patch", + Desc: "verify route by patch", Object: APISIXExpect(t), Method: http.MethodPatch, Path: "/hello", @@ -164,7 +164,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -172,10 +172,10 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "add route with lower case methods", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with lower case methods", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET", "post"], @@ -192,7 +192,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -201,10 +201,10 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "add route with methods GET", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with methods GET", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -221,7 +221,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route by get", + Desc: "verify route by get", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -231,7 +231,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by post", + Desc: "verify route by post", Object: APISIXExpect(t), Method: http.MethodPost, Path: "/hello", @@ -241,10 +241,10 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route methods to POST", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route methods to POST", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["POST"], @@ -261,7 +261,7 @@ func TestRoute_with_methods(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route by get", + Desc: "verify route by get", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -270,7 +270,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route by post", + Desc: "verify route by post", Object: APISIXExpect(t), Method: http.MethodPost, Path: "/hello", @@ -281,7 +281,7 @@ func TestRoute_with_methods(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", diff --git a/api/test/e2e/route_with_metric_plugin_test.go b/api/test/e2e/route_with_metric_plugin_test.go index 698d7d679e..a654436dda 100644 --- a/api/test/e2e/route_with_metric_plugin_test.go +++ b/api/test/e2e/route_with_metric_plugin_test.go @@ -24,7 +24,7 @@ import ( func TestRoute_With_Plugin_Prometheus(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -32,10 +32,10 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -54,7 +54,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "fetch the prometheus metric data", + Desc: "fetch the prometheus metric data", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/apisix/prometheus/metrics", @@ -63,7 +63,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "request from client (200)", + Desc: "request from client (200)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -71,10 +71,10 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { ExpectBody: "hello world", }, { - caseDesc: "create route that uri not exists in upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route that uri not exists in upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello-not-exists", "plugins": { @@ -93,7 +93,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "request from client (404)", + Desc: "request from client (404)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello-not-exists", @@ -101,7 +101,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the prometheus metric data (apisix_http_status 200)", + Desc: "verify the prometheus metric data (apisix_http_status 200)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/apisix/prometheus/metrics", @@ -110,7 +110,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the prometheus metric data (apisix_http_status 404)", + Desc: "verify the prometheus metric data (apisix_http_status 404)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/apisix/prometheus/metrics", @@ -119,7 +119,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -127,7 +127,7 @@ func TestRoute_With_Plugin_Prometheus(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_plugin_cors_test.go b/api/test/e2e/route_with_plugin_cors_test.go index 278fe4a6f1..a05e9637c3 100644 --- a/api/test/e2e/route_with_plugin_cors_test.go +++ b/api/test/e2e/route_with_plugin_cors_test.go @@ -24,7 +24,7 @@ import ( func TestRoute_With_Plugin_Cors(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created", + Desc: "make sure the route is not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -32,10 +32,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route with cors default setting", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with cors default setting", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -54,7 +54,7 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with cors default setting", + Desc: "verify route with cors default setting", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -67,10 +67,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route with specified setting", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with specified setting", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -96,10 +96,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with cors specified setting", - Object: APISIXExpect(t), - Method: http.MethodGet, - Path: "/hello", + Desc: "verify route with cors specified setting", + Object: APISIXExpect(t), + Method: http.MethodGet, + Path: "/hello", Headers: map[string]string{ "Origin": "http://sub2.domain.com", "resp-vary": "Via", @@ -116,10 +116,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route with cors specified no match origin", - Object: APISIXExpect(t), - Method: http.MethodGet, - Path: "/hello", + Desc: "verify route with cors specified no match origin", + Object: APISIXExpect(t), + Method: http.MethodGet, + Path: "/hello", Headers: map[string]string{ "Origin": "http://sub3.domain.com", }, @@ -135,9 +135,9 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route with options method", - Object: APISIXExpect(t), - Method: http.MethodOptions, + Desc: "verify route with options method", + Object: APISIXExpect(t), + Method: http.MethodOptions, Headers: map[string]string{ "Origin": "http://sub2.domain.com", }, @@ -153,10 +153,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectBody: "", }, { - caseDesc: "update route with cors setting force wildcard", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with cors setting force wildcard", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -180,10 +180,10 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with cors setting force wildcard", - Object: APISIXExpect(t), - Method: http.MethodGet, - Path: "/hello", + Desc: "verify route with cors setting force wildcard", + Object: APISIXExpect(t), + Method: http.MethodGet, + Path: "/hello", Headers: map[string]string{ "Origin": "https://sub.domain.com", "ExternalHeader1": "val", @@ -204,7 +204,7 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -212,7 +212,7 @@ func TestRoute_With_Plugin_Cors(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route deleted", + Desc: "make sure the route deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_plugin_orchestration_test.go b/api/test/e2e/route_with_plugin_orchestration_test.go index cd2dcd3557..e980c100c2 100644 --- a/api/test/e2e/route_with_plugin_orchestration_test.go +++ b/api/test/e2e/route_with_plugin_orchestration_test.go @@ -36,7 +36,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created", + Desc: "make sure the route is not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -44,7 +44,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route with invalid dag config", + Desc: "create route with invalid dag config", Object: ManagerApiExpect(t), Method: http.MethodPut, Path: "/apisix/admin/routes/r1", @@ -53,7 +53,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "make sure the route created failed", + Desc: "make sure the route created failed", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -62,7 +62,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route with correct dag config", + Desc: "create route with correct dag config", Object: ManagerApiExpect(t), Method: http.MethodPut, Path: "/apisix/admin/routes/r1", @@ -71,7 +71,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the route(should be blocked)", + Desc: "verify the route(should be blocked)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -81,7 +81,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the route(should not be blocked)", + Desc: "verify the route(should not be blocked)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -89,7 +89,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { ExpectBody: `hello world`, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -97,7 +97,7 @@ func TestRoute_With_Plugin_Orchestration(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_plugin_proxy_rewrite_test.go b/api/test/e2e/route_with_plugin_proxy_rewrite_test.go index e5d2e60511..a6d2898f0e 100644 --- a/api/test/e2e/route_with_plugin_proxy_rewrite_test.go +++ b/api/test/e2e/route_with_plugin_proxy_rewrite_test.go @@ -24,7 +24,7 @@ import ( func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created", + Desc: "make sure the route is not created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -32,10 +32,10 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route that will rewrite host and uri", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route that will rewrite host and uri", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -57,7 +57,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route that rewrite host and uri", + Desc: "verify route that rewrite host and uri", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -66,10 +66,10 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route that will rewrite headers", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route that will rewrite headers", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -93,7 +93,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route that rewrite headers", + Desc: "verify route that rewrite headers", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -103,10 +103,10 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route using regex_uri", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route using regex_uri", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/test/*", "plugins": { @@ -127,7 +127,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route that using regex_uri", + Desc: "verify route that using regex_uri", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/test/plugin/proxy/rewrite`, @@ -136,10 +136,10 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route that will rewrite args", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route that will rewrite args", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -160,7 +160,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route that rewrite args", + Desc: "verify route that rewrite args", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -170,7 +170,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -178,7 +178,7 @@ func TestRoute_With_Plugin_Proxy_Rewrite(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route deleted", + Desc: "make sure the route deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_priority_test.go b/api/test/e2e/route_with_priority_test.go index d94b84b8ed..baf9abeb59 100644 --- a/api/test/e2e/route_with_priority_test.go +++ b/api/test/e2e/route_with_priority_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_with_priority(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "add another route with no priority (default 0)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add another route with no priority (default 0)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/server_port", "methods": ["GET"], @@ -44,7 +44,7 @@ func TestRoute_with_priority(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route", + Desc: "access the route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -53,10 +53,10 @@ func TestRoute_with_priority(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "add another route with valid priority (1), upstream is different from the others", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r2", + Desc: "add another route with valid priority (1), upstream is different from the others", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r2", Body: `{ "uri": "/server_port", "methods": ["GET"], @@ -74,7 +74,7 @@ func TestRoute_with_priority(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route to determine whether it meets the priority (compare 1 and default)", + Desc: "access the route to determine whether it meets the priority (compare 1 and default)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -83,7 +83,7 @@ func TestRoute_with_priority(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route (r1)", + Desc: "delete route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -92,7 +92,7 @@ func TestRoute_with_priority(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route (r2)", + Desc: "delete route (r2)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r2", diff --git a/api/test/e2e/route_with_trace_plugin_test.go b/api/test/e2e/route_with_trace_plugin_test.go index cba099cb4e..cbc7e072b1 100644 --- a/api/test/e2e/route_with_trace_plugin_test.go +++ b/api/test/e2e/route_with_trace_plugin_test.go @@ -27,7 +27,7 @@ import ( func TestRoute_With_Plugin_Skywalking(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -35,10 +35,10 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -59,7 +59,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "tiger skywalking", + Desc: "tiger skywalking", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -85,10 +85,10 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "update route to change sample ratio", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route to change sample ratio", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "plugins": { @@ -109,7 +109,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route", + Desc: "access the route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -135,7 +135,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -143,7 +143,7 @@ func TestRoute_With_Plugin_Skywalking(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the route has been deleted", + Desc: "make sure the route has been deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", diff --git a/api/test/e2e/route_with_uri_uris_test.go b/api/test/e2e/route_with_uri_uris_test.go index 8b2a6a1098..60755a810e 100644 --- a/api/test/e2e/route_with_uri_uris_test.go +++ b/api/test/e2e/route_with_uri_uris_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_with_valid_uri_uris(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "add route with valid uri", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with valid uri", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "upstream": { @@ -43,7 +43,7 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route (r1)", + Desc: "hit the route (r1)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -53,7 +53,7 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route (r1)", + Desc: "delete the route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -62,10 +62,10 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "add route with valid uris", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with valid uris", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uris": ["/hello","/status"], "upstream": { @@ -81,7 +81,7 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route (/hello)", + Desc: "hit the route (/hello)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -91,7 +91,7 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route (/status)", + Desc: "hit the route (/status)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/status", @@ -101,7 +101,7 @@ func TestRoute_with_valid_uri_uris(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route (r1)", + Desc: "delete the route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", diff --git a/api/test/e2e/route_with_valid_remote_addr_test.go b/api/test/e2e/route_with_valid_remote_addr_test.go index 245d3826d0..8c5f130f20 100644 --- a/api/test/e2e/route_with_valid_remote_addr_test.go +++ b/api/test/e2e/route_with_valid_remote_addr_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_with_valid_remote_addr(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "add route with valid remote_addr", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with valid remote_addr", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addr": "172.16.238.1", @@ -44,7 +44,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -54,10 +54,10 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route with valid remote_addr (CIDR)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with valid remote_addr (CIDR)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addr": "172.16.238.1/24", @@ -74,7 +74,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -84,10 +84,10 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update route with valid remote_addrs", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with valid remote_addrs", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addrs": ["172.16.238.1","192.168.0.2/24"], @@ -104,7 +104,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -114,10 +114,10 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update remote_addr to not be hit", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update remote_addr to not be hit", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addr": "10.10.10.10", @@ -134,7 +134,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -143,10 +143,10 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update remote_addrs to not be hit", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update remote_addrs to not be hit", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "remote_addrs": ["10.10.10.10","11.11.11.1/24"], @@ -163,7 +163,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -172,7 +172,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -181,7 +181,7 @@ func TestRoute_with_valid_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify it again after deleting the route", + Desc: "verify it again after deleting the route", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_vars_test.go b/api/test/e2e/route_with_vars_test.go index e12b1a0700..faad3f2784 100644 --- a/api/test/e2e/route_with_vars_test.go +++ b/api/test/e2e/route_with_vars_test.go @@ -24,10 +24,10 @@ import ( func TestRoute_with_vars(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "add route with vars (args)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with vars (args)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "vars": [ @@ -47,7 +47,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with right args", + Desc: "hit the route with right args", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -57,7 +57,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong args", + Desc: "hit the route with wrong args", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -67,7 +67,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with no args", + Desc: "hit the route with no args", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -76,10 +76,10 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "update route with vars (header)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with vars (header)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "vars": [ @@ -99,7 +99,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with right header", + Desc: "hit the route with right header", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "header"}, @@ -109,7 +109,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong header", + Desc: "hit the route with wrong header", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "jack"}, @@ -119,7 +119,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with no header", + Desc: "hit the route with no header", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -128,10 +128,10 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "update route with vars (cookie)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "update route with vars (cookie)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "vars": [ @@ -151,7 +151,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with right Cookie", + Desc: "hit the route with right Cookie", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"Cookie": "_octo=GH1.1.572248189.1598928545; _device_id=2c1a1a52074e66a3a008e4b73c690500; logged_in=yes;"}, @@ -161,7 +161,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong Cookie", + Desc: "hit the route with wrong Cookie", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"Cookie": "jack"}, @@ -171,7 +171,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with no Cookie", + Desc: "hit the route with no Cookie", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -180,7 +180,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -190,10 +190,10 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "add route with multiple vars (args, cookie and header)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with multiple vars (args, cookie and header)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "vars": [ @@ -215,7 +215,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with right parameters", + Desc: "hit the route with right parameters", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "header", "Cookie": "_octo=GH1.1.572248189.1598928545; _device_id=2c1a1a52074e66a3a008e4b73c690500; logged_in=yes;"}, @@ -226,7 +226,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong arg", + Desc: "hit the route with wrong arg", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "header", "Cookie": "_octo=GH1.1.572248189.1598928545; _device_id=2c1a1a52074e66a3a008e4b73c690500; logged_in=yes;"}, @@ -236,7 +236,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong header", + Desc: "hit the route with wrong header", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "test", "Cookie": "_octo=GH1.1.572248189.1598928545; _device_id=2c1a1a52074e66a3a008e4b73c690500; logged_in=yes;"}, @@ -247,7 +247,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "hit the route with wrong cookie", + Desc: "hit the route with wrong cookie", Object: APISIXExpect(t), Method: http.MethodGet, Headers: map[string]string{"k": "header", "Cookie": "_octo=GH1.1.572248189.1598928545; logged_in=yes;"}, @@ -258,7 +258,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -268,10 +268,10 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "add route with vars (args is digital)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "add route with vars (args is digital)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "vars": [ @@ -291,7 +291,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "verify route", + Desc: "verify route", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -301,7 +301,7 @@ func TestRoute_with_vars(t *testing.T) { }, { - caseDesc: "delete the route with vars (args is digital)", + Desc: "delete the route with vars (args is digital)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", diff --git a/api/test/e2e/ssl_test.go b/api/test/e2e/ssl_test.go index fd7effd713..ab6f4283f0 100644 --- a/api/test/e2e/ssl_test.go +++ b/api/test/e2e/ssl_test.go @@ -66,7 +66,7 @@ func TestSSL_Basic(t *testing.T) { // main test cases tests := []HttpTestCase{ { - caseDesc: "create ssl fail - key and cert not match", + Desc: "create ssl fail - key and cert not match", Object: ManagerApiExpect(t), Method: http.MethodPost, Path: "/apisix/admin/ssl", @@ -75,7 +75,7 @@ func TestSSL_Basic(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "create ssl successfully", + Desc: "create ssl successfully", Object: ManagerApiExpect(t), Method: http.MethodPost, Path: "/apisix/admin/ssl", @@ -84,10 +84,10 @@ func TestSSL_Basic(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello_", "hosts": ["test2.com", "*.test2.com"], @@ -102,7 +102,7 @@ func TestSSL_Basic(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just created using HTTPS", + Desc: "hit the route just created using HTTPS", Object: APISIXHTTPSExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -112,7 +112,7 @@ func TestSSL_Basic(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete ssl", + Desc: "delete ssl", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/ssl/1", @@ -134,7 +134,7 @@ func TestSSL_Basic(t *testing.T) { // clean test data delRoute := HttpTestCase{ - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", diff --git a/api/test/e2e/upstream_chash_hash_on_test.go b/api/test/e2e/upstream_chash_hash_on_test.go index b93495e614..4d3a705e46 100644 --- a/api/test/e2e/upstream_chash_hash_on_test.go +++ b/api/test/e2e/upstream_chash_hash_on_test.go @@ -30,10 +30,10 @@ import ( func TestUpstream_chash_hash_on_custom_header(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with hash_on (custom_header)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with hash_on (custom_header)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -53,10 +53,10 @@ func TestUpstream_chash_hash_on_custom_header(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -102,10 +102,10 @@ func TestUpstream_chash_hash_on_custom_header(t *testing.T) { func TestUpstream_chash_hash_on_cookie(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with hash_on (cookie)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with hash_on (cookie)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -181,10 +181,10 @@ func TestUpstream_chash_hash_on_cookie(t *testing.T) { func TestUpstream_key_contains_uppercase_letters_and_hyphen(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with key contains uppercase letters and hyphen", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key contains uppercase letters and hyphen", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -240,10 +240,10 @@ func TestUpstream_key_contains_uppercase_letters_and_hyphen(t *testing.T) { func TestUpstream_chash_hash_on_consumer(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create consumer with key-auth", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/consumers", + Desc: "create consumer with key-auth", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/consumers", Body: `{ "username": "jack", "plugins": { @@ -256,10 +256,10 @@ func TestUpstream_chash_hash_on_consumer(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route with key-auth", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route with key-auth", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "plugins": { @@ -321,10 +321,10 @@ func TestUpstream_chash_hash_on_consumer(t *testing.T) { func TestUpstream_chash_hash_on_wrong_key(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with wrong key", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/2", + Desc: "create chash upstream with wrong key", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/2", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -344,7 +344,7 @@ func TestUpstream_chash_hash_on_wrong_key(t *testing.T) { ExpectBody: "schema validate failed: (root): Does not match pattern '^((uri|server_name|server_addr|request_uri|remote_port|remote_addr|query_string|host|hostname)|arg_[0-9a-zA-z_-]+)", }, { - caseDesc: "verify upstream with wrong key", + Desc: "verify upstream with wrong key", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/routes/2", @@ -363,10 +363,10 @@ func TestUpstream_chash_hash_on_wrong_key(t *testing.T) { func TestUpstream_chash_hash_on_vars(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream hash_on (vars)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream hash_on (vars)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -386,7 +386,7 @@ func TestUpstream_chash_hash_on_vars(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify upstream", + Desc: "verify upstream", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/upstreams/1", @@ -396,10 +396,10 @@ func TestUpstream_chash_hash_on_vars(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -409,7 +409,7 @@ func TestUpstream_chash_hash_on_vars(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify route", + Desc: "verify route", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/routes/1", @@ -450,7 +450,7 @@ func TestUpstream_chash_hash_on_vars(t *testing.T) { func TestUpstream_Delete_hash_on(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -458,7 +458,7 @@ func TestUpstream_Delete_hash_on(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/1", @@ -466,7 +466,7 @@ func TestUpstream_Delete_hash_on(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete upstream", + Desc: "delete upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -474,7 +474,7 @@ func TestUpstream_Delete_hash_on(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", diff --git a/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go b/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go index d01d0e8924..02e5149085 100644 --- a/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go +++ b/api/test/e2e/upstream_chash_query_string_arg_xxx_test.go @@ -30,10 +30,10 @@ import ( func TestUpstream_chash_query_string(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with key (query_string)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key (query_string)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -57,10 +57,10 @@ func TestUpstream_chash_query_string(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -106,10 +106,10 @@ func TestUpstream_chash_query_string(t *testing.T) { func TestUpstream_chash_arg_xxx(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with key (arg_xxx)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key (arg_xxx)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -169,7 +169,7 @@ func TestUpstream_chash_arg_xxx(t *testing.T) { func TestUpstream_Delete_chash(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/1", @@ -177,7 +177,7 @@ func TestUpstream_Delete_chash(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete upstream", + Desc: "delete upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -185,7 +185,7 @@ func TestUpstream_Delete_chash(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello1", diff --git a/api/test/e2e/upstream_test.go b/api/test/e2e/upstream_test.go index 093430d19c..12c5a6615c 100644 --- a/api/test/e2e/upstream_test.go +++ b/api/test/e2e/upstream_test.go @@ -28,10 +28,10 @@ import ( func TestUpstream_Create(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "use upstream that not exist", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "use upstream that not exist", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "upstream_id": "not-exists" @@ -40,10 +40,10 @@ func TestUpstream_Create(t *testing.T) { ExpectStatus: http.StatusBadRequest, }, { - caseDesc: "create upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -56,10 +56,10 @@ func TestUpstream_Create(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/hello", "upstream_id": "1" @@ -69,7 +69,7 @@ func TestUpstream_Create(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route just created", + Desc: "hit the route just created", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -87,10 +87,10 @@ func TestUpstream_Create(t *testing.T) { func TestUpstream_Update(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "update upstream with domain", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "update upstream with domain", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -103,7 +103,7 @@ func TestUpstream_Update(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route using upstream 1", + Desc: "hit the route using upstream 1", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -121,10 +121,10 @@ func TestUpstream_Update(t *testing.T) { func TestRoute_Node_Host(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "update upstream - pass host: node", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "update upstream - pass host: node", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "httpbin.org", @@ -138,10 +138,10 @@ func TestRoute_Node_Host(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "update path for route", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "update path for route", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/*", "upstream_id": "1" @@ -150,7 +150,7 @@ func TestRoute_Node_Host(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route ", + Desc: "hit the route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/get", @@ -159,10 +159,10 @@ func TestRoute_Node_Host(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "update upstream - pass host: rewrite", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "update upstream - pass host: rewrite", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -177,7 +177,7 @@ func TestRoute_Node_Host(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route ", + Desc: "hit the route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/uri", @@ -195,10 +195,10 @@ func TestRoute_Node_Host(t *testing.T) { func TestUpstream_chash_remote_addr(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "create chash upstream with key (remote_addr)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key (remote_addr)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -223,10 +223,10 @@ func TestUpstream_chash_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -265,10 +265,10 @@ func TestUpstream_chash_remote_addr(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create chash upstream with key (remote_addr, weight equal 0 or 1)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key (remote_addr, weight equal 0 or 1)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [ { @@ -294,10 +294,10 @@ func TestUpstream_chash_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -330,10 +330,10 @@ func TestUpstream_chash_remote_addr(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "create chash upstream with key (remote_addr, all weight equal 0)", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/1", + Desc: "create chash upstream with key (remote_addr, all weight equal 0)", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/1", Body: `{ "nodes": [ { @@ -354,10 +354,10 @@ func TestUpstream_chash_remote_addr(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create route using the upstream just created", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/1", + Desc: "create route using the upstream just created", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/1", Body: `{ "uri": "/server_port", "upstream_id": "1" @@ -367,7 +367,7 @@ func TestUpstream_chash_remote_addr(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "hit the route ", + Desc: "hit the route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/server_port", @@ -386,7 +386,7 @@ func TestUpstream_chash_remote_addr(t *testing.T) { func TestUpstream_Delete(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "delete not exist upstream", + Desc: "delete not exist upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/not-exist", @@ -394,7 +394,7 @@ func TestUpstream_Delete(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/1", @@ -402,7 +402,7 @@ func TestUpstream_Delete(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete upstream", + Desc: "delete upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/1", @@ -410,7 +410,7 @@ func TestUpstream_Delete(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "hit the route just deleted", + Desc: "hit the route just deleted", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello1", From 430f75fc9e099c5b21e0bb3f1e867287c332481b Mon Sep 17 00:00:00 2001 From: nic-chen Date: Sun, 20 Dec 2020 12:33:19 +0800 Subject: [PATCH 4/7] fix: naming --- api/test/e2e/json_schema_validate_test.go | 12 +- api/test/e2e/route_online_debug_test.go | 212 +++++++++--------- .../e2e/route_with_management_fileds_test.go | 32 +-- api/test/e2e/server_info_test.go | 10 +- api/test/e2e/ssl_test.go | 14 +- 5 files changed, 140 insertions(+), 140 deletions(-) diff --git a/api/test/e2e/json_schema_validate_test.go b/api/test/e2e/json_schema_validate_test.go index a025b2ec82..297436f622 100644 --- a/api/test/e2e/json_schema_validate_test.go +++ b/api/test/e2e/json_schema_validate_test.go @@ -24,10 +24,10 @@ import ( func TestSchema_not_exist_field(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "config route with non-existent fields", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "config route with non-existent fields", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "nonexistent": "test non-existent", @@ -42,10 +42,10 @@ func TestSchema_not_exist_field(t *testing.T) { }`, Headers: map[string]string{"Authorization": token}, ExpectStatus: http.StatusBadRequest, - ExpectBody: `{"code":10000,"message":"schema validate failed: (root): Additional property nonexistent is not allowed"}`, + ExpectBody: `{"code":10000,"message":"schema validate failed: (root): Additional property nonexistent is not allowed"}`, }, { - caseDesc: "make sure the route create failed", + Desc: "make sure the route create failed", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_online_debug_test.go b/api/test/e2e/route_online_debug_test.go index 4dd88f2a50..f3f6ad097d 100644 --- a/api/test/e2e/route_online_debug_test.go +++ b/api/test/e2e/route_online_debug_test.go @@ -30,7 +30,7 @@ import ( func TestRoute_Online_Debug_Route_Not_Exist(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "hit route that not exist", + Desc: "hit route that not exist", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -57,7 +57,7 @@ func TestRoute_Online_Debug_Route_Not_Exist(t *testing.T) { func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "hit route that not exist", + Desc: "hit route that not exist", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -65,10 +65,10 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { ExpectBody: "{\"error_msg\":\"404 Route Not Found\"}\n", }, { - caseDesc: "create route with query params", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with query params", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -89,10 +89,10 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "online debug route with query params", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with query params", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello?name=aaa", "request_protocol": "http", @@ -102,7 +102,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -110,7 +110,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -128,7 +128,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -137,10 +137,10 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route with header params", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with header params", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -161,10 +161,10 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "online debug route with header params", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with header params", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello", "request_protocol": "http", @@ -177,7 +177,7 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -185,7 +185,7 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -203,7 +203,7 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -212,10 +212,10 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route with method POST", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route with method POST", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["POST"], @@ -233,10 +233,10 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "online debug route with body params", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with body params", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello", "request_protocol": "http", @@ -250,7 +250,7 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -258,7 +258,7 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -276,7 +276,7 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -285,10 +285,10 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route enable basic-auth plugin", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route enable basic-auth plugin", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -309,7 +309,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -317,10 +317,10 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPost, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPost, Body: `{ "username": "jack", "plugins": { @@ -337,10 +337,10 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "online debug route with username and password", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with username and password", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello", "request_protocol": "http", @@ -374,7 +374,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { // clear test data tests = []HttpTestCase{ { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -382,7 +382,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with the jwt token from just deleted consumer", + Desc: "verify route with the jwt token from just deleted consumer", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -392,7 +392,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -400,7 +400,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -418,7 +418,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -427,10 +427,10 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create route enable jwt-auth plugin", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route enable jwt-auth plugin", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -451,7 +451,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -460,10 +460,10 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -495,10 +495,10 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { tests = []HttpTestCase{ { - caseDesc: "online debug route with jwt token", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with jwt token", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello", "request_protocol": "http", @@ -532,7 +532,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { // clear test data tests = []HttpTestCase{ { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -540,7 +540,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with the jwt token from just deleted consumer", + Desc: "verify route with the jwt token from just deleted consumer", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -550,7 +550,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -558,7 +558,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -576,7 +576,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -584,10 +584,10 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route enable key-auth plugin", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route enable key-auth plugin", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -607,7 +607,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -615,10 +615,10 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -632,10 +632,10 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "online debug route with apikey", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with apikey", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello", "request_protocol": "http", @@ -669,7 +669,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { // clear test data tests = []HttpTestCase{ { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -677,7 +677,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with the jwt token from just deleted consumer", + Desc: "verify route with the jwt token from just deleted consumer", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -687,7 +687,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -695,7 +695,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -713,7 +713,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "make sure the route is not created ", + Desc: "make sure the route is not created ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -721,10 +721,10 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectBody: `{"error_msg":"404 Route Not Found"}`, }, { - caseDesc: "create route enable key-auth plugin", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/routes/r1", + Desc: "create route enable key-auth plugin", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/routes/r1", Body: `{ "uri": "/hello", "methods": ["GET"], @@ -747,7 +747,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "make sure the consumer is not created", + Desc: "make sure the consumer is not created", Object: ManagerApiExpect(t), Method: http.MethodGet, Path: "/apisix/admin/consumers/jack", @@ -755,10 +755,10 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectStatus: http.StatusNotFound, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -772,10 +772,10 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "online debug route with apikey", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/debug-request-forwarding", + Desc: "online debug route with apikey", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/debug-request-forwarding", Body: `{ "url": "` + APISIXInternalUrl + `/hello?name=aaa", "request_protocol": "http", @@ -809,7 +809,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { // clear test data tests = []HttpTestCase{ { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/jack", @@ -817,7 +817,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify route with the jwt token from just deleted consumer", + Desc: "verify route with the jwt token from just deleted consumer", Object: APISIXExpect(t), Method: http.MethodGet, Path: `/hello`, @@ -828,7 +828,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -836,7 +836,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "verify the deleted route ", + Desc: "verify the deleted route ", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/route_with_management_fileds_test.go b/api/test/e2e/route_with_management_fileds_test.go index cbb6be11b1..5c0474d5a9 100644 --- a/api/test/e2e/route_with_management_fileds_test.go +++ b/api/test/e2e/route_with_management_fileds_test.go @@ -232,10 +232,10 @@ func TestRoute_with_label(t *testing.T) { func TestRoute_search_by_label(t *testing.T) { tests := []HttpTestCase{ { - caseDesc: "config route with labels (r1)", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "config route with labels (r1)", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "labels": { @@ -256,10 +256,10 @@ func TestRoute_search_by_label(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "config route with labels (r2)", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r2", - Method: http.MethodPut, + Desc: "config route with labels (r2)", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r2", + Method: http.MethodPut, Body: `{ "uri": "/hello2", "labels": { @@ -281,7 +281,7 @@ func TestRoute_search_by_label(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route's uri (r1)", + Desc: "access the route's uri (r1)", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", @@ -291,7 +291,7 @@ func TestRoute_search_by_label(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "verify the route's detail (r1)", + Desc: "verify the route's detail (r1)", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes/r1", Method: http.MethodGet, @@ -301,7 +301,7 @@ func TestRoute_search_by_label(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "search the route by label", + Desc: "search the route by label", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes", Query: "label=build:16", @@ -312,7 +312,7 @@ func TestRoute_search_by_label(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "search the route by label (only key)", + Desc: "search the route by label (only key)", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes", Query: "label=extra", @@ -323,7 +323,7 @@ func TestRoute_search_by_label(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "search the route by label (combination)", + Desc: "search the route by label (combination)", Object: ManagerApiExpect(t), Path: "/apisix/admin/routes", Query: "label=extra,build:16", @@ -334,7 +334,7 @@ func TestRoute_search_by_label(t *testing.T) { Sleep: sleepTime, }, { - caseDesc: "delete the route (r1)", + Desc: "delete the route (r1)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -342,7 +342,7 @@ func TestRoute_search_by_label(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete the route (r2)", + Desc: "delete the route (r2)", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r2", @@ -350,7 +350,7 @@ func TestRoute_search_by_label(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "access the route after delete it", + Desc: "access the route after delete it", Object: APISIXExpect(t), Method: http.MethodGet, Path: "/hello", diff --git a/api/test/e2e/server_info_test.go b/api/test/e2e/server_info_test.go index bbe9c50f25..ef1a67aab3 100644 --- a/api/test/e2e/server_info_test.go +++ b/api/test/e2e/server_info_test.go @@ -27,7 +27,7 @@ func TestServerInfo_Get(t *testing.T) { time.Sleep(2 * time.Second) testCases := []HttpTestCase{ { - caseDesc: "get server info", + Desc: "get server info", Object: ManagerApiExpect(t), Path: "/apisix/admin/server_info/apisix-server1", Method: http.MethodGet, @@ -36,7 +36,7 @@ func TestServerInfo_Get(t *testing.T) { ExpectBody: "\"hostname\":\"apisix_server1\"", }, { - caseDesc: "get server info", + Desc: "get server info", Object: ManagerApiExpect(t), Path: "/apisix/admin/server_info/apisix-server2", Method: http.MethodGet, @@ -54,7 +54,7 @@ func TestServerInfo_Get(t *testing.T) { func TestServerInfo_List(t *testing.T) { testCases := []HttpTestCase{ { - caseDesc: "list all server info", + Desc: "list all server info", Object: ManagerApiExpect(t), Path: "/apisix/admin/server_info", Method: http.MethodGet, @@ -63,7 +63,7 @@ func TestServerInfo_List(t *testing.T) { ExpectBody: "\"total_size\":2", }, { - caseDesc: "list server info with hostname", + Desc: "list server info with hostname", Object: ManagerApiExpect(t), Path: "/apisix/admin/server_info", Query: "hostname=apisix_", @@ -73,7 +73,7 @@ func TestServerInfo_List(t *testing.T) { ExpectBody: "\"total_size\":2", }, { - caseDesc: "list server info with hostname", + Desc: "list server info with hostname", Object: ManagerApiExpect(t), Path: "/apisix/admin/server_info", Query: "hostname=apisix_server2", diff --git a/api/test/e2e/ssl_test.go b/api/test/e2e/ssl_test.go index cdec6857d9..add638074a 100644 --- a/api/test/e2e/ssl_test.go +++ b/api/test/e2e/ssl_test.go @@ -112,10 +112,10 @@ func TestSSL_Basic(t *testing.T) { Sleep: sleepTime, }, { - Desc: "disable SSL", - Object: ManagerApiExpect(t), - Method: http.MethodPatch, - Path: "/apisix/admin/ssl/1", + Desc: "disable SSL", + Object: ManagerApiExpect(t), + Method: http.MethodPatch, + Path: "/apisix/admin/ssl/1", Body: `{ "status": 0 }`, @@ -138,7 +138,7 @@ func TestSSL_Basic(t *testing.T) { // enable SSL again tests = []HttpTestCase{ { - Desc: "enable SSL", + Desc: "enable SSL", Object: ManagerApiExpect(t), Method: http.MethodPatch, Path: "/apisix/admin/ssl/1/status", @@ -147,7 +147,7 @@ func TestSSL_Basic(t *testing.T) { ExpectStatus: http.StatusOK, }, { - Desc: "hit the route using HTTPS, make sure enable successful", + Desc: "hit the route using HTTPS, make sure enable successful", Object: APISIXHTTPSExpect(t), Method: http.MethodGet, Path: "/hello_", @@ -163,7 +163,7 @@ func TestSSL_Basic(t *testing.T) { // delete SSL delSSL := HttpTestCase{ - Desc: "delete SSL", + Desc: "delete SSL", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/ssl/1", From e93fde1b38214d6680df0ed76a467e971f73048b Mon Sep 17 00:00:00 2001 From: nic-chen Date: Sun, 20 Dec 2020 12:42:14 +0800 Subject: [PATCH 5/7] fix error --- api/test/e2e/route_online_debug_test.go | 26 +++++++++---------- .../e2e/route_with_management_fileds_test.go | 2 +- api/test/e2e/server_info_test.go | 4 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/api/test/e2e/route_online_debug_test.go b/api/test/e2e/route_online_debug_test.go index f3f6ad097d..d94c69e4e6 100644 --- a/api/test/e2e/route_online_debug_test.go +++ b/api/test/e2e/route_online_debug_test.go @@ -39,7 +39,7 @@ func TestRoute_Online_Debug_Route_Not_Exist(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } basepath := "http://127.0.0.1:9000/apisix/admin/debug-request-forwarding" request, _ := http.NewRequest("POST", basepath, strings.NewReader(`{"url": "`+APISIXInternalUrl+`/hello_","method": "GET","request_protocol": "http"}`)) @@ -121,7 +121,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -196,7 +196,7 @@ func TestRoute_Online_Debug_Route_With_Header_Params(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -269,7 +269,7 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -355,7 +355,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // online debug without basic-auth @@ -411,7 +411,7 @@ func TestRoute_Online_Debug_Route_With_Basic_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -482,7 +482,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // sign jwt token @@ -513,7 +513,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // online debug without jwt-auth @@ -569,7 +569,7 @@ func TestRoute_Online_Debug_Route_With_Jwt_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -650,7 +650,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // online debug without key-auth @@ -706,7 +706,7 @@ func TestRoute_Online_Debug_Route_With_Key_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -790,7 +790,7 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } // online debug without key-auth @@ -847,6 +847,6 @@ func TestRoute_Online_Debug_Route_With_Query_Params_Key_Auth(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/route_with_management_fileds_test.go b/api/test/e2e/route_with_management_fileds_test.go index 5c0474d5a9..5b983929e7 100644 --- a/api/test/e2e/route_with_management_fileds_test.go +++ b/api/test/e2e/route_with_management_fileds_test.go @@ -360,6 +360,6 @@ func TestRoute_search_by_label(t *testing.T) { }, } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } diff --git a/api/test/e2e/server_info_test.go b/api/test/e2e/server_info_test.go index ef1a67aab3..7eb45567f7 100644 --- a/api/test/e2e/server_info_test.go +++ b/api/test/e2e/server_info_test.go @@ -47,7 +47,7 @@ func TestServerInfo_Get(t *testing.T) { } for _, tc := range testCases { - testCaseCheck(tc) + testCaseCheck(tc, t) } } @@ -85,6 +85,6 @@ func TestServerInfo_List(t *testing.T) { } for _, tc := range testCases { - testCaseCheck(tc) + testCaseCheck(tc, t) } } From c7fa98bc2fe384b5b6439f40be28357f12dde170 Mon Sep 17 00:00:00 2001 From: nic-chen Date: Sun, 20 Dec 2020 12:53:25 +0800 Subject: [PATCH 6/7] fix error --- api/test/e2e/json_schema_validate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/test/e2e/json_schema_validate_test.go b/api/test/e2e/json_schema_validate_test.go index 297436f622..1adcc11a6e 100644 --- a/api/test/e2e/json_schema_validate_test.go +++ b/api/test/e2e/json_schema_validate_test.go @@ -55,6 +55,6 @@ func TestSchema_not_exist_field(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } } From af5dbec69466bbc02d0ed43ad530b56a99e39bec Mon Sep 17 00:00:00 2001 From: nic-chen Date: Thu, 24 Dec 2020 16:28:56 +0800 Subject: [PATCH 7/7] fix error --- api/test/e2e/label_test.go | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/api/test/e2e/label_test.go b/api/test/e2e/label_test.go index 4fe5713405..dd2e366e5d 100644 --- a/api/test/e2e/label_test.go +++ b/api/test/e2e/label_test.go @@ -25,10 +25,10 @@ func TestLabel(t *testing.T) { // Todo: test ssl after ssl bug fixed tests := []HttpTestCase{ { - caseDesc: "config route", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/routes/r1", - Method: http.MethodPut, + Desc: "config route", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/routes/r1", + Method: http.MethodPut, Body: `{ "uri": "/hello", "labels": { @@ -49,10 +49,10 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create consumer", - Object: ManagerApiExpect(t), - Path: "/apisix/admin/consumers/c1", - Method: http.MethodPut, + Desc: "create consumer", + Object: ManagerApiExpect(t), + Path: "/apisix/admin/consumers/c1", + Method: http.MethodPut, Body: `{ "username": "jack", "plugins": { @@ -71,10 +71,10 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create upstream", - Object: ManagerApiExpect(t), - Method: http.MethodPut, - Path: "/apisix/admin/upstreams/u1", + Desc: "create upstream", + Object: ManagerApiExpect(t), + Method: http.MethodPut, + Path: "/apisix/admin/upstreams/u1", Body: `{ "nodes": [{ "host": "172.16.238.20", @@ -92,10 +92,10 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "create service", - Object: ManagerApiExpect(t), - Method: http.MethodPost, - Path: "/apisix/admin/services", + Desc: "create service", + Object: ManagerApiExpect(t), + Method: http.MethodPost, + Path: "/apisix/admin/services", Body: `{ "id": "s1", "plugins": { @@ -125,7 +125,7 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "get route label", + Desc: "get route label", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -134,7 +134,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"env\":\"production\"},{\"version\":\"v2\"}", }, { - caseDesc: "get consumer label", + Desc: "get consumer label", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -143,7 +143,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"env\":\"production\"},{\"version\":\"v3\"}", }, { - caseDesc: "get upstream label", + Desc: "get upstream label", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -152,7 +152,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"17\"},{\"env\":\"production\"},{\"version\":\"v2\"}", }, { - caseDesc: "get service label", + Desc: "get service label", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -161,7 +161,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"env\":\"production\"},{\"extra\":\"test\"},{\"version\":\"v2\"}", }, { - caseDesc: "get all label", + Desc: "get all label", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -170,7 +170,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"build\":\"17\"},{\"env\":\"production\"},{\"extra\":\"test\"},{\"version\":\"v2\"},{\"version\":\"v3\"}", }, { - caseDesc: "get label with page", + Desc: "get label with page", Object: ManagerApiExpect(t), Method: http.MethodGet, Query: "page=1&page_size=1", @@ -180,7 +180,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"}", }, { - caseDesc: "get label with page", + Desc: "get label with page", Object: ManagerApiExpect(t), Method: http.MethodGet, Query: "page=3&page_size=1", @@ -190,7 +190,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"env\":\"production\"}", }, { - caseDesc: "get labels (key = build)", + Desc: "get labels (key = build)", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -200,7 +200,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"build\":\"17\"}", }, { - caseDesc: "get labels (key = build) with page", + Desc: "get labels (key = build) with page", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -210,7 +210,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"17\"}", }, { - caseDesc: "get labels (key = build && env = production)", + Desc: "get labels (key = build && env = production)", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -220,7 +220,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"build\":\"16\"},{\"build\":\"17\"},{\"env\":\"production\"}", }, { - caseDesc: "get labels (key = build && env = production) with page", + Desc: "get labels (key = build && env = production) with page", Object: ManagerApiExpect(t), Method: http.MethodGet, Headers: map[string]string{"Authorization": token}, @@ -230,7 +230,7 @@ func TestLabel(t *testing.T) { ExpectBody: "{\"env\":\"production\"}", }, { - caseDesc: "delete route", + Desc: "delete route", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/routes/r1", @@ -238,7 +238,7 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete consumer", + Desc: "delete consumer", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/consumers/c1", @@ -246,7 +246,7 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete service", + Desc: "delete service", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/services/s1", @@ -254,7 +254,7 @@ func TestLabel(t *testing.T) { ExpectStatus: http.StatusOK, }, { - caseDesc: "delete upstream", + Desc: "delete upstream", Object: ManagerApiExpect(t), Method: http.MethodDelete, Path: "/apisix/admin/upstreams/u1", @@ -264,6 +264,6 @@ func TestLabel(t *testing.T) { } for _, tc := range tests { - testCaseCheck(tc) + testCaseCheck(tc, t) } }