You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2022/06/17 06:25:15 UTC
[apisix-ingress-controller] branch master updated: fix: e2e robustness. (#1078)
This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new 3214c698 fix: e2e robustness. (#1078)
3214c698 is described below
commit 3214c698f9dd2dc7797fce837e16d15d60f64050
Author: Xin Rong <ro...@api7.ai>
AuthorDate: Fri Jun 17 14:25:09 2022 +0800
fix: e2e robustness. (#1078)
---
Makefile | 15 +-
test/e2e/scaffold/wolf-rbac.go | 47 -------
test/e2e/suite-features/consumer.go | 256 ++++++++++++++++++-----------------
test/e2e/suite-ingress/namespace.go | 19 ++-
test/e2e/testdata/wolf-rbac/cmd.sh | 75 ++++++++++
test/e2e/testdata/wolf-rbac/ip.sh | 20 ---
test/e2e/testdata/wolf-rbac/start.sh | 61 ---------
test/e2e/testdata/wolf-rbac/stop.sh | 24 ----
8 files changed, 234 insertions(+), 283 deletions(-)
diff --git a/Makefile b/Makefile
index a33c9360..266f417e 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ VERSYM="github.com/apache/apisix-ingress-controller/pkg/version._buildVersion"
GITSHASYM="github.com/apache/apisix-ingress-controller/pkg/version._buildGitRevision"
BUILDOSSYM="github.com/apache/apisix-ingress-controller/pkg/version._buildOS"
GO_LDFLAGS ?= "-X=$(VERSYM)=$(VERSION) -X=$(GITSHASYM)=$(GITSHA) -X=$(BUILDOSSYM)=$(OSNAME)/$(OSARCH)"
-E2E_CONCURRENCY ?= 1
+E2E_CONCURRENCY ?= 2
E2E_SKIP_BUILD ?= 0
### build: Build apisix-ingress-controller
@@ -66,7 +66,7 @@ unit-test:
### e2e-test: Run e2e test cases (in existing clusters directly)
.PHONY: e2e-test
-e2e-test: ginkgo-check push-images
+e2e-test: ginkgo-check push-images e2e-wolf-rbac
kubectl apply -k $(PWD)/samples/deploy/crd
kubectl apply -f $(PWD)/samples/deploy/gateway-api
cd test/e2e \
@@ -218,3 +218,14 @@ update-all: update-codegen update-license update-mdlint update-gofmt
.PHONY: e2e-names-check
e2e-names-check:
chmod +x ./utils/check-e2e-names.sh && ./utils/check-e2e-names.sh
+
+.PHONY: e2e-wolf-rbac
+e2e-wolf-rbac:
+ifeq ("$(E2E_FOCUS)", "")
+ chmod +x ./test/e2e/testdata/wolf-rbac/cmd.sh && ./test/e2e/testdata/wolf-rbac/cmd.sh start
+endif
+ifneq ("$(E2E_FOCUS)", "")
+ echo $(E2E_FOCUS) | grep -E 'suite-features|consumer|wolf' || exit 0 \
+ && chmod +x ./test/e2e/testdata/wolf-rbac/cmd.sh \
+ && ./test/e2e/testdata/wolf-rbac/cmd.sh start
+endif
diff --git a/test/e2e/scaffold/wolf-rbac.go b/test/e2e/scaffold/wolf-rbac.go
deleted file mode 100644
index 6a16a5c1..00000000
--- a/test/e2e/scaffold/wolf-rbac.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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 scaffold
-
-import (
- "fmt"
- "os/exec"
-)
-
-func (s *Scaffold) StartWolfRBACServer() error {
- cmd := exec.Command("sh", "testdata/wolf-rbac/start.sh")
- return cmd.Run()
-}
-
-func (s *Scaffold) GetWolfRBACServerURL() (string, error) {
- cmd := exec.Command("sh", "testdata/wolf-rbac/ip.sh")
- ip, err := cmd.Output()
- if err != nil {
- return "", err
- }
- if len(ip) == 0 {
- return "", fmt.Errorf("wolf-server start failed")
- }
- httpsvc := fmt.Sprintf("http://%s:12180", string(ip))
- return httpsvc, nil
-}
-
-func (s *Scaffold) StopWolfRBACServer() error {
- cmd := exec.Command("sh", "testdata/wolf-rbac/stop.sh")
- err := cmd.Run()
- return err
-}
diff --git a/test/e2e/suite-features/consumer.go b/test/e2e/suite-features/consumer.go
index 275595b9..28575578 100644
--- a/test/e2e/suite-features/consumer.go
+++ b/test/e2e/suite-features/consumer.go
@@ -19,6 +19,7 @@ import (
"encoding/json"
"fmt"
"net/http"
+ "os/exec"
"time"
ginkgo "github.com/onsi/ginkgo/v2"
@@ -343,14 +344,22 @@ spec:
Raw()
assert.Contains(ginkgo.GinkgoT(), msg, "404 Route Not Found")
})
-
- ginkgo.It("ApisixRoute with wolfRBAC consumer", func() {
- _ = s.StartWolfRBACServer()
- wolfSvr, err := s.GetWolfRBACServerURL()
- assert.Nil(ginkgo.GinkgoT(), err, "checking wolf-server")
- defer s.StopWolfRBACServer()
-
- ac := fmt.Sprintf(`
+ ginkgo.Context("wolfRBAC-server", func() {
+ getWolfRBACServerURL := func() (string, error) {
+ cmd := exec.Command("sh", "testdata/wolf-rbac/cmd.sh", "ip")
+ ip, err := cmd.Output()
+ if err != nil {
+ return "", err
+ }
+ if len(ip) == 0 {
+ return "", fmt.Errorf("wolf-server start failed")
+ }
+ return fmt.Sprintf("http://%s:12180", string(ip)), nil
+ }
+ ginkgo.It("ApisixRoute with wolfRBAC consumer", func() {
+ wolfSvr, err := getWolfRBACServerURL()
+ assert.Nil(ginkgo.GinkgoT(), err, "checking wolf-server")
+ ac := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixConsumer
metadata:
@@ -363,23 +372,23 @@ spec:
appid: "test-app"
header_prefix: "X-"
`, wolfSvr)
- assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixConsumer(ac), "creating wolfRBAC ApisixConsumer")
-
- // Wait until the ApisixConsumer create event was delivered.
- time.Sleep(6 * time.Second)
-
- grs, err := s.ListApisixConsumers()
- assert.Nil(ginkgo.GinkgoT(), err, "listing consumer")
- assert.Len(ginkgo.GinkgoT(), grs, 1)
- assert.Len(ginkgo.GinkgoT(), grs[0].Plugins, 1)
- wolfRBAC, _ := grs[0].Plugins["wolf-rbac"].(map[string]interface{})
- assert.Equal(ginkgo.GinkgoT(), wolfRBAC, map[string]interface{}{
- "server": wolfSvr,
- "appid": "test-app",
- "header_prefix": "X-",
- })
- adminSvc, adminPort := s.ApisixAdminServiceAndPort()
- ar1 := fmt.Sprintf(`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixConsumer(ac), "creating wolfRBAC ApisixConsumer")
+
+ // Wait until the ApisixConsumer create event was delivered.
+ time.Sleep(6 * time.Second)
+
+ grs, err := s.ListApisixConsumers()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing consumer")
+ assert.Len(ginkgo.GinkgoT(), grs, 1)
+ assert.Len(ginkgo.GinkgoT(), grs[0].Plugins, 1)
+ wolfRBAC, _ := grs[0].Plugins["wolf-rbac"].(map[string]interface{})
+ assert.Equal(ginkgo.GinkgoT(), wolfRBAC, map[string]interface{}{
+ "server": wolfSvr,
+ "appid": "test-app",
+ "header_prefix": "X-",
+ })
+ adminSvc, adminPort := s.ApisixAdminServiceAndPort()
+ ar1 := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
@@ -397,12 +406,12 @@ spec:
- name: public-api
enable: true
`, adminSvc, adminPort)
- assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar1), "creating ApisixRoute")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1), "Checking number of routes")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "Checking number of upstreams")
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar1), "creating ApisixRoute")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1), "Checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "Checking number of upstreams")
- backendSvc, backendPorts := s.DefaultHTTPBackend()
- ar2 := fmt.Sprintf(`
+ backendSvc, backendPorts := s.DefaultHTTPBackend()
+ ar2 := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
@@ -422,10 +431,10 @@ spec:
enable: true
type: wolfRBAC
`, backendSvc, backendPorts[0])
- assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar2), "creating ApisixRoute")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(2), "Checking number of routes")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(2), "Checking number of upstreams")
- payload := []byte(`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar2), "creating ApisixRoute")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(2), "Checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(2), "Checking number of upstreams")
+ payload := []byte(`
{
"appid": "test-app",
"username": "test",
@@ -433,42 +442,39 @@ spec:
"authType": 1
}
`)
- body := s.NewAPISIXClient().POST("/apisix/plugin/wolf-rbac/login").
- WithHeader("Content-Type", "application/json").
- WithBytes(payload).
- Expect().
- Status(http.StatusOK).
- Body().
- Contains("rbac_token").
- Raw()
-
- data := struct {
- Token string `json:"rbac_token"`
- }{}
- _ = json.Unmarshal([]byte(body), &data)
-
- _ = s.NewAPISIXClient().GET("").
- WithHeader("Host", "httpbin.org").
- WithHeader("Authorization", data.Token).
- Expect().
- Status(http.StatusOK)
-
- msg401 := s.NewAPISIXClient().GET("").
- WithHeader("Host", "httpbin.org").
- Expect().
- Status(http.StatusUnauthorized).
- Body().
- Raw()
- assert.Contains(ginkgo.GinkgoT(), msg401, "Missing rbac token in request")
- })
-
- ginkgo.It("ApisixRoute with wolfRBAC consumer using secret", func() {
- _ = s.StartWolfRBACServer()
- wolfSvr, err := s.GetWolfRBACServerURL()
- assert.Nil(ginkgo.GinkgoT(), err, "checking wolf-server")
- defer s.StopWolfRBACServer()
+ body := s.NewAPISIXClient().POST("/apisix/plugin/wolf-rbac/login").
+ WithHeader("Content-Type", "application/json").
+ WithBytes(payload).
+ Expect().
+ Status(http.StatusOK).
+ Body().
+ Contains("rbac_token").
+ Raw()
+
+ data := struct {
+ Token string `json:"rbac_token"`
+ }{}
+ _ = json.Unmarshal([]byte(body), &data)
+
+ _ = s.NewAPISIXClient().GET("").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("Authorization", data.Token).
+ Expect().
+ Status(http.StatusOK)
+
+ msg401 := s.NewAPISIXClient().GET("").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusUnauthorized).
+ Body().
+ Raw()
+ assert.Contains(ginkgo.GinkgoT(), msg401, "Missing rbac token in request")
+ })
- secret := fmt.Sprintf(`
+ ginkgo.It("ApisixRoute with wolfRBAC consumer using secret", func() {
+ wolfSvr, err := getWolfRBACServerURL()
+ assert.Nil(ginkgo.GinkgoT(), err, "checking wolf-server")
+ secret := fmt.Sprintf(`
apiVersion: v1
kind: Secret
metadata:
@@ -478,9 +484,9 @@ data:
appid: dGVzdC1hcHA=
header_prefix: WC0=
`, base64.StdEncoding.EncodeToString([]byte(wolfSvr)))
- assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(secret), "creating wolfRBAC secret for ApisixConsumer")
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(secret), "creating wolfRBAC secret for ApisixConsumer")
- ac := `
+ ac := `
apiVersion: apisix.apache.org/v2beta3
kind: ApisixConsumer
metadata:
@@ -491,23 +497,23 @@ spec:
secretRef:
name: rbac
`
- assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixConsumer(ac), "creating wolfRBAC ApisixConsumer")
-
- // Wait until the ApisixConsumer create event was delivered.
- time.Sleep(6 * time.Second)
-
- grs, err := s.ListApisixConsumers()
- assert.Nil(ginkgo.GinkgoT(), err, "listing consumer")
- assert.Len(ginkgo.GinkgoT(), grs, 1)
- assert.Len(ginkgo.GinkgoT(), grs[0].Plugins, 1)
- wolfRBAC, _ := grs[0].Plugins["wolf-rbac"].(map[string]interface{})
- assert.Equal(ginkgo.GinkgoT(), wolfRBAC, map[string]interface{}{
- "server": wolfSvr,
- "appid": "test-app",
- "header_prefix": "X-",
- })
- adminSvc, adminPort := s.ApisixAdminServiceAndPort()
- ar1 := fmt.Sprintf(`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixConsumer(ac), "creating wolfRBAC ApisixConsumer")
+
+ // Wait until the ApisixConsumer create event was delivered.
+ time.Sleep(6 * time.Second)
+
+ grs, err := s.ListApisixConsumers()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing consumer")
+ assert.Len(ginkgo.GinkgoT(), grs, 1)
+ assert.Len(ginkgo.GinkgoT(), grs[0].Plugins, 1)
+ wolfRBAC, _ := grs[0].Plugins["wolf-rbac"].(map[string]interface{})
+ assert.Equal(ginkgo.GinkgoT(), wolfRBAC, map[string]interface{}{
+ "server": wolfSvr,
+ "appid": "test-app",
+ "header_prefix": "X-",
+ })
+ adminSvc, adminPort := s.ApisixAdminServiceAndPort()
+ ar1 := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
@@ -525,12 +531,12 @@ spec:
- name: public-api
enable: true
`, adminSvc, adminPort)
- assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar1), "creating ApisixRoute")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1), "Checking number of routes")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "Checking number of upstreams")
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar1), "creating ApisixRoute")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1), "Checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "Checking number of upstreams")
- backendSvc, backendPorts := s.DefaultHTTPBackend()
- ar2 := fmt.Sprintf(`
+ backendSvc, backendPorts := s.DefaultHTTPBackend()
+ ar2 := fmt.Sprintf(`
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
@@ -550,10 +556,10 @@ spec:
enable: true
type: wolfRBAC
`, backendSvc, backendPorts[0])
- assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar2), "creating ApisixRoute")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(2), "Checking number of routes")
- assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(2), "Checking number of upstreams")
- payload := []byte(`
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ar2), "creating ApisixRoute")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(2), "Checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(2), "Checking number of upstreams")
+ payload := []byte(`
{
"appid": "test-app",
"username": "test",
@@ -561,35 +567,35 @@ spec:
"authType": 1
}
`)
- body := s.NewAPISIXClient().POST("/apisix/plugin/wolf-rbac/login").
- WithHeader("Content-Type", "application/json").
- WithBytes(payload).
- Expect().
- Status(http.StatusOK).
- Body().
- Contains("rbac_token").
- Raw()
-
- data := struct {
- Token string `json:"rbac_token"`
- }{}
- _ = json.Unmarshal([]byte(body), &data)
-
- _ = s.NewAPISIXClient().GET("").
- WithHeader("Host", "httpbin.org").
- WithHeader("Authorization", data.Token).
- Expect().
- Status(http.StatusOK)
-
- msg401 := s.NewAPISIXClient().GET("").
- WithHeader("Host", "httpbin.org").
- Expect().
- Status(http.StatusUnauthorized).
- Body().
- Raw()
- assert.Contains(ginkgo.GinkgoT(), msg401, "Missing rbac token in request")
+ body := s.NewAPISIXClient().POST("/apisix/plugin/wolf-rbac/login").
+ WithHeader("Content-Type", "application/json").
+ WithBytes(payload).
+ Expect().
+ Status(http.StatusOK).
+ Body().
+ Contains("rbac_token").
+ Raw()
+
+ data := struct {
+ Token string `json:"rbac_token"`
+ }{}
+ _ = json.Unmarshal([]byte(body), &data)
+
+ _ = s.NewAPISIXClient().GET("").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("Authorization", data.Token).
+ Expect().
+ Status(http.StatusOK)
+
+ msg401 := s.NewAPISIXClient().GET("").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusUnauthorized).
+ Body().
+ Raw()
+ assert.Contains(ginkgo.GinkgoT(), msg401, "Missing rbac token in request")
+ })
})
-
ginkgo.It("ApisixRoute with hmacAuth consumer", func() {
ac := `
apiVersion: apisix.apache.org/v2beta3
diff --git a/test/e2e/suite-ingress/namespace.go b/test/e2e/suite-ingress/namespace.go
index 6dd1103d..712784af 100644
--- a/test/e2e/suite-ingress/namespace.go
+++ b/test/e2e/suite-ingress/namespace.go
@@ -36,7 +36,7 @@ type headers struct {
} `json:"headers"`
}
-var _ = ginkgo.Describe("suite-ingress: namespacing filtering", func() {
+var _ = ginkgo.Describe("suite-ingress: namespacing filtering enable", func() {
opts := &scaffold.Options{
Name: "default",
Kubeconfig: scaffold.GetKubeconfig(),
@@ -100,7 +100,18 @@ spec:
_ = s.NewAPISIXClient().GET("/headers").WithHeader("Host", "httpbin.com").Expect().Status(http.StatusNotFound)
})
})
+})
+var _ = ginkgo.Describe("suite-ingress: namespacing filtering disable", func() {
+ opts := &scaffold.Options{
+ Name: "default",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ APISIXRouteVersion: "apisix.apache.org/v2beta3",
+ }
+ s := scaffold.NewScaffold(opts)
ginkgo.Context("without namespace_selector", func() {
// make namespace_selector empty
s.DisableNamespaceSelector()
@@ -150,13 +161,13 @@ spec:
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
- name: httpbin-route
+ name: httpbin-route-second-httpbin-service-namespace
spec:
http:
- name: rule1
match:
hosts:
- - httpbin.com
+ - second-httpbin-service-namespace.httpbin.com
paths:
- /headers
backends:
@@ -182,7 +193,7 @@ spec:
err = json.Unmarshal([]byte(body), &placeholder)
assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling IP")
assert.NotEqual(ginkgo.GinkgoT(), ip{}, placeholder)
- body = s.NewAPISIXClient().GET("/headers").WithHeader("Host", "httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+ body = s.NewAPISIXClient().GET("/headers").WithHeader("Host", "second-httpbin-service-namespace.httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
var headerResponse headers
err = json.Unmarshal([]byte(body), &headerResponse)
assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling header")
diff --git a/test/e2e/testdata/wolf-rbac/cmd.sh b/test/e2e/testdata/wolf-rbac/cmd.sh
new file mode 100755
index 00000000..54cd1c85
--- /dev/null
+++ b/test/e2e/testdata/wolf-rbac/cmd.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+cd test/e2e/testdata/wolf-rbac/
+
+OPTION=$1
+
+if [ $OPTION = "ip" ]; then
+ echo -n `docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' wolf-server`
+elif [ $OPTION = "start" ]; then
+ docker-compose -f 'docker-compose.yaml' -p 'wolf-rbac' down
+ rm -rf db-psql.sql
+
+ wget https://raw.githubusercontent.com/iGeeky/wolf/f6ddeb75a37bff90406f0f0a2b7ae5d16f6f3bd4/server/script/db-psql.sql
+
+ # start database
+ docker-compose up -d database
+
+ # start wolf-server
+ docker-compose up -d server restful-demo agent-or agent-demo
+
+ sleep 6
+
+ WOLF_TOKEN=`curl http://127.0.0.1:12180/wolf/user/login -H "Content-Type: application/json" -d '{ "username": "root", "password": "wolf-123456"}' -s | grep token| tr -d ':",' | awk '{print $2}'`
+
+ curl http://127.0.0.1:12180/wolf/application \
+ -H "Content-Type: application/json" \
+ -H "x-rbac-token: $WOLF_TOKEN" \
+ -d '{
+ "id": "test-app",
+ "name": "application for test"
+ }'
+
+ curl http://127.0.0.1:12180/wolf/resource \
+ -H "Content-Type: application/json" \
+ -H "x-rbac-token: $WOLF_TOKEN" \
+ -d '{
+ "appID": "test-app",
+ "matchType": "prefix",
+ "name": "/",
+ "action": "GET",
+ "permID": "ALLOW_ALL"
+ }'
+
+ curl http://127.0.0.1:12180/wolf/user \
+ -H "Content-Type: application/json" \
+ -H "x-rbac-token: $WOLF_TOKEN" \
+ -d '{
+ "username": "test",
+ "nickname": "test",
+ "password": "test-123456",
+ "appIDs": ["test-app"]
+ }'
+elif [ $OPTION = "stop" ]; then
+ docker-compose -f 'docker-compose.yaml' -p 'wolf-rbac' down
+ rm -rf db-psql.sql
+else
+ echo "argument is one of [ip, start, stop]"
+fi
diff --git a/test/e2e/testdata/wolf-rbac/ip.sh b/test/e2e/testdata/wolf-rbac/ip.sh
deleted file mode 100644
index 47f5ba15..00000000
--- a/test/e2e/testdata/wolf-rbac/ip.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-#
-# 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.
-#
-
-echo -n `docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' wolf-server`
diff --git a/test/e2e/testdata/wolf-rbac/start.sh b/test/e2e/testdata/wolf-rbac/start.sh
deleted file mode 100644
index d8de22ef..00000000
--- a/test/e2e/testdata/wolf-rbac/start.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-#
-# 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.
-#
-
-cd testdata/wolf-rbac/
-
-wget https://raw.githubusercontent.com/iGeeky/wolf/f6ddeb75a37bff90406f0f0a2b7ae5d16f6f3bd4/server/script/db-psql.sql
-
-# start database
-docker-compose up -d database
-
-# start wolf-server
-docker-compose up -d server restful-demo agent-or agent-demo
-
-sleep 6
-
-WOLF_TOKEN=`curl http://127.0.0.1:12180/wolf/user/login -H "Content-Type: application/json" -d '{ "username": "root", "password": "wolf-123456"}' -s | grep token| tr -d ':",' | awk '{print $2}'`
-
-curl http://127.0.0.1:12180/wolf/application \
--H "Content-Type: application/json" \
--H "x-rbac-token: $WOLF_TOKEN" \
--d '{
- "id": "test-app",
- "name": "application for test"
-}'
-
-curl http://127.0.0.1:12180/wolf/resource \
--H "Content-Type: application/json" \
--H "x-rbac-token: $WOLF_TOKEN" \
--d '{
- "appID": "test-app",
- "matchType": "prefix",
- "name": "/",
- "action": "GET",
- "permID": "ALLOW_ALL"
-}'
-
-curl http://127.0.0.1:12180/wolf/user \
--H "Content-Type: application/json" \
--H "x-rbac-token: $WOLF_TOKEN" \
--d '{
- "username": "test",
- "nickname": "test",
- "password": "test-123456",
- "appIDs": ["test-app"]
-}'
diff --git a/test/e2e/testdata/wolf-rbac/stop.sh b/test/e2e/testdata/wolf-rbac/stop.sh
deleted file mode 100644
index db4b916b..00000000
--- a/test/e2e/testdata/wolf-rbac/stop.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-#
-# 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.
-#
-
-cd testdata/wolf-rbac/
-
-docker-compose -f 'docker-compose.yaml' -p 'wolf-rbac' down
-
-rm db-psql.sql