You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/04 01:40:18 UTC

[GitHub] [apisix] tokers commented on a change in pull request #3501: fix: remove kubectl dependency in chaos test, use k8s API instead

tokers commented on a change in pull request #3501:
URL: https://github.com/apache/apisix/pull/3501#discussion_r569880121



##########
File path: t/chaos/utils.go
##########
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package chaos
+
+import (
+	"fmt"
+	"net/http"
+	"strconv"
+	"strings"
+	"time"
+
+	"github.com/gavv/httpexpect/v2"
+	. "github.com/onsi/gomega"
+)
+
+var (
+	token = "edd1c9f034335f136f87ad84b625c8f1"
+	host  = "http://127.0.0.1:9080"
+)
+
+type httpTestCase struct {
+	E            *httpexpect.Expect
+	Method       string
+	Path         string
+	Body         string
+	Headers      map[string]string
+	ExpectStatus int
+	ExpectBody   string
+}
+
+func caseCheck(tc httpTestCase) *httpexpect.Response {
+	e := tc.E
+	var req *httpexpect.Request
+	switch tc.Method {
+	case http.MethodGet:
+		req = e.GET(tc.Path)
+	case http.MethodPut:
+		req = e.PUT(tc.Path)
+	default:

Review comment:
       Panic in default, should be better from the integrity of program:
   
   ```suggestion
   	default:
   	    panic("invalid HTTP method")
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org