From 5b9ff7f18585f3053e183d51ce98a7e6c4e9810b Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 23 Oct 2024 10:35:15 +0800 Subject: [PATCH] test: avoid being conflict with well-known ports Signed-off-by: spacewander --- .github/workflows/test.yml | 5 ++ .../integration/controlplane/control_plane.go | 13 +++- .../tests/integration/dataplane/bootstrap.go | 14 ++++ .../tests/integration/dataplane/data_plane.go | 47 ++++++++--- .../integration/filtermanager_latest_test.go | 2 +- .../integration/testdata/grpc_backend.yml | 2 +- .../testdata/services/docker-compose.yml | 2 +- .../testdata/services/grpc/main.go | 4 +- plugins/tests/integration/oidc_test.go | 5 +- plugins/tests/integration/sentinel_test.go | 78 +++++++------------ .../plugin_integration_test_framework.md | 11 +-- .../plugin_integration_test_framework.md | 11 +-- 12 files changed, 119 insertions(+), 75 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b459c98..7631bae1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -153,6 +153,11 @@ jobs: plugins-integration-test: timeout-minutes: 10 runs-on: ubuntu-latest + env: + # to test the custom port feature + TEST_ENVOY_ADMIN_API_PORT: 9901 + TEST_ENVOY_CONTROL_PLANE_PORT: 9902 + TEST_ENVOY_DATA_PLANE_PORT: 9903 defaults: run: working-directory: ./plugins diff --git a/api/plugins/tests/integration/controlplane/control_plane.go b/api/plugins/tests/integration/controlplane/control_plane.go index 92dcf7a2..41967cb1 100644 --- a/api/plugins/tests/integration/controlplane/control_plane.go +++ b/api/plugins/tests/integration/controlplane/control_plane.go @@ -99,7 +99,18 @@ func (cp *ControlPlane) Start() { // only use it on Linux. } - lis, _ := net.Listen("tcp", host+":9999") + port := ":9999" + portEnv := os.Getenv("TEST_ENVOY_CONTROL_PLANE_PORT") + if portEnv != "" { + port = ":" + portEnv + } + + lis, err := net.Listen("tcp", host+port) + if err != nil { + logger.Error(err, "failed to listen") + return + } + if err := cp.grpcServer.Serve(lis); err != nil { logger.Error(err, "failed to start control plane") } diff --git a/api/plugins/tests/integration/dataplane/bootstrap.go b/api/plugins/tests/integration/dataplane/bootstrap.go index 105d48e2..21ffad7e 100644 --- a/api/plugins/tests/integration/dataplane/bootstrap.go +++ b/api/plugins/tests/integration/dataplane/bootstrap.go @@ -149,6 +149,20 @@ func (b *bootstrap) buildConfiguration() (map[string]interface{}, error) { staticResources := root["static_resources"].(map[string]interface{}) clusters := staticResources["clusters"].([]interface{}) + + port := "9999" + portEnv := os.Getenv("TEST_ENVOY_CONTROL_PLANE_PORT") + if portEnv != "" { + port = portEnv + } + for _, c := range clusters { + if c.(map[string]interface{})["name"] == "config_server" { + load := c.(map[string]interface{})["load_assignment"].(map[string]interface{})["endpoints"].([]interface{})[0].(map[string]interface{})["lb_endpoints"].([]interface{})[0].(map[string]interface{})["endpoint"].(map[string]interface{})["address"].(map[string]interface{})["socket_address"].(map[string]interface{}) + load["port_value"] = port + break + } + } + newClusters := []interface{}{} for _, c := range b.clusters { newClusters = append(newClusters, c) diff --git a/api/plugins/tests/integration/dataplane/data_plane.go b/api/plugins/tests/integration/dataplane/data_plane.go index 5d3a79b3..8b95359a 100644 --- a/api/plugins/tests/integration/dataplane/data_plane.go +++ b/api/plugins/tests/integration/dataplane/data_plane.go @@ -30,6 +30,7 @@ import ( "path/filepath" "regexp" "runtime" + "strconv" "strings" "testing" "time" @@ -54,6 +55,9 @@ type DataPlane struct { t *testing.T opt *Option done chan error + + dataPlanePort string + adminAPIPort string } type Option struct { @@ -189,6 +193,20 @@ func StartDataPlane(t *testing.T, opt *Option) (*DataPlane, error) { return nil, err } + adminAPIPort := "9998" + adminAPIPortEnv := os.Getenv("TEST_ENVOY_ADMIN_API_PORT") + if adminAPIPortEnv != "" { + adminAPIPort = adminAPIPortEnv + } + dp.adminAPIPort = adminAPIPort + + dataPlanePort := "10000" + dataPlanePortEnv := os.Getenv("TEST_ENVOY_DATA_PLANE_PORT") + if dataPlanePortEnv != "" { + dataPlanePort = dataPlanePortEnv + } + dp.dataPlanePort = dataPlanePort + cmdline := "docker run" + " --name " + containerName + " --network " + networkName + @@ -199,7 +217,8 @@ func StartDataPlane(t *testing.T, opt *Option) (*DataPlane, error) { " -v /tmp:/tmp" + " -e GOCOVERDIR=" + coverDir + " " + strings.Join(envs, " ") + - " -p 10000:10000 -p 9998:9998 " + hostAddr + " " + + " -p " + dataPlanePort + ":10000 -p " + adminAPIPort + ":9998 " + + hostAddr + " " + image content, _ := os.ReadFile(cfgFile.Name()) @@ -256,7 +275,7 @@ func StartDataPlane(t *testing.T, opt *Option) (*DataPlane, error) { go func() { done <- cmd.Wait() }() }() - helper.WaitServiceUp(t, ":10000", "") + helper.WaitServiceUp(t, ":"+dataPlanePort, "") select { case err := <-done: @@ -381,7 +400,7 @@ func (dp *DataPlane) Patch(path string, header http.Header, body io.Reader) (*ht } func (dp *DataPlane) SendAndCancelRequest(path string, after time.Duration) error { - conn, err := net.DialTimeout("tcp", ":10000", 1*time.Second) + conn, err := net.DialTimeout("tcp", ":"+dp.dataPlanePort, 1*time.Second) if err != nil { return err } @@ -404,13 +423,13 @@ func (dp *DataPlane) SendAndCancelRequest(path string, after time.Duration) erro } func (dp *DataPlane) do(method string, path string, header http.Header, body io.Reader) (*http.Response, error) { - req, err := http.NewRequest(method, "http://localhost:10000"+path, body) + req, err := http.NewRequest(method, "http://localhost:"+dp.dataPlanePort+path, body) if err != nil { return nil, err } req.Header = header tr := &http.Transport{DialContext: func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { - return net.DialTimeout("tcp", ":10000", 1*time.Second) + return net.DialTimeout("tcp", ":"+dp.dataPlanePort, 1*time.Second) }} client := &http.Client{Transport: tr, @@ -424,7 +443,7 @@ func (dp *DataPlane) do(method string, path string, header http.Header, body io. } func (dp *DataPlane) doWithTrailer(method string, path string, header http.Header, body io.Reader, trailer http.Header) (*http.Response, error) { - req, err := http.NewRequest(method, "http://localhost:10000"+path, body) + req, err := http.NewRequest(method, "http://localhost:"+dp.dataPlanePort+path, body) if err != nil { return nil, err } @@ -434,7 +453,7 @@ func (dp *DataPlane) doWithTrailer(method string, path string, header http.Heade req.TransferEncoding = []string{"chunked"} tr := &http.Transport{ DialContext: func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { - return net.DialTimeout("tcp", ":10000", 1*time.Second) + return net.DialTimeout("tcp", ":"+dp.dataPlanePort, 1*time.Second) }, } @@ -451,7 +470,7 @@ func (dp *DataPlane) doWithTrailer(method string, path string, header http.Heade // Use grpcurl so that the caller can specify the proto file without building the Go code. // TODO: we can rewrite this in Go. func (dp *DataPlane) Grpcurl(importPath, protoFile, fullMethodName, req string) ([]byte, error) { - cmd := exec.Command("grpcurl", "-v", "-format-error", "-import-path", importPath, "-proto", protoFile, "-plaintext", "-d", req, ":10000", fullMethodName) + cmd := exec.Command("grpcurl", "-v", "-format-error", "-import-path", importPath, "-proto", protoFile, "-plaintext", "-d", req, ":"+dp.dataPlanePort, fullMethodName) dp.t.Logf("run grpcurl command: %s", cmd.String()) return cmd.CombinedOutput() } @@ -479,7 +498,7 @@ func (dp *DataPlane) FlushCoverage() error { } func (dp *DataPlane) SetLogLevel(loggerName string, level string) error { - req, err := http.NewRequest("POST", fmt.Sprintf("http://0.0.0.0:9998/logging?%s=%s", loggerName, level), bytes.NewReader([]byte{})) + req, err := http.NewRequest("POST", fmt.Sprintf("http://0.0.0.0:%s/logging?%s=%s", dp.adminAPIPort, loggerName, level), bytes.NewReader([]byte{})) if err != nil { return err } @@ -497,3 +516,13 @@ func (dp *DataPlane) SetLogLevel(loggerName string, level string) error { return nil } + +func (dp *DataPlane) AdminAPIPort() int { + p, _ := strconv.Atoi(dp.adminAPIPort) + return p +} + +func (dp *DataPlane) Port() int { + p, _ := strconv.Atoi(dp.dataPlanePort) + return p +} diff --git a/api/tests/integration/filtermanager_latest_test.go b/api/tests/integration/filtermanager_latest_test.go index 6af1a0bc..4e56616f 100644 --- a/api/tests/integration/filtermanager_latest_test.go +++ b/api/tests/integration/filtermanager_latest_test.go @@ -242,7 +242,7 @@ func TestFilterManagerTrailersWithGrpcBackend(t *testing.T) { } defer dp.Stop() - helper.WaitServiceUp(t, ":50051", "grpc") + helper.WaitServiceUp(t, ":50001", "grpc") s := &filtermanager.FilterManagerConfig{ Plugins: []*model.FilterConfig{ diff --git a/api/tests/integration/testdata/grpc_backend.yml b/api/tests/integration/testdata/grpc_backend.yml index 4b35d155..a11e33ed 100644 --- a/api/tests/integration/testdata/grpc_backend.yml +++ b/api/tests/integration/testdata/grpc_backend.yml @@ -10,4 +10,4 @@ load_assignment: address: socket_address: address: grpc - port_value: 50051 + port_value: 50001 diff --git a/api/tests/integration/testdata/services/docker-compose.yml b/api/tests/integration/testdata/services/docker-compose.yml index 534b2201..94704bf9 100644 --- a/api/tests/integration/testdata/services/docker-compose.yml +++ b/api/tests/integration/testdata/services/docker-compose.yml @@ -3,7 +3,7 @@ services: grpc: build: ./grpc ports: - - "50051:50051" + - "50001:50001" restart: unless-stopped networks: service: diff --git a/api/tests/integration/testdata/services/grpc/main.go b/api/tests/integration/testdata/services/grpc/main.go index 86084d3f..c68f2513 100644 --- a/api/tests/integration/testdata/services/grpc/main.go +++ b/api/tests/integration/testdata/services/grpc/main.go @@ -30,7 +30,7 @@ func (s *sampleServer) Ouch(ctx context.Context, req *HelloRequest) (*HelloRespo func main() { // Create a TCP listener - lis, err := net.Listen("tcp", ":50051") + lis, err := net.Listen("tcp", ":50001") if err != nil { log.Fatalf("Failed to listen: %v", err) } @@ -42,7 +42,7 @@ func main() { RegisterSampleServer(s, &sampleServer{}) // Start the server - fmt.Println("Server started. Listening on port :50051") + fmt.Println("Server started. Listening on port :50001") if err := s.Serve(lis); err != nil { log.Fatalf("Failed to serve: %v", err) } diff --git a/plugins/tests/integration/oidc_test.go b/plugins/tests/integration/oidc_test.go index ced42f50..7d7d3ccd 100644 --- a/plugins/tests/integration/oidc_test.go +++ b/plugins/tests/integration/oidc_test.go @@ -17,6 +17,7 @@ package integration import ( "encoding/base64" "encoding/json" + "fmt" "net/http" "net/url" "os/exec" @@ -41,7 +42,7 @@ func TestOIDC(t *testing.T) { helper.WaitServiceUp(t, ":4444", "hydra") - redirectURL := "http://127.0.0.1:10000/echo" + redirectURL := fmt.Sprintf("http://127.0.0.1:%d/echo", dp.Port()) hydraCmd := "hydra create client --response-type code,id_token " + "--grant-type authorization_code,refresh_token -e http://127.0.0.1:4445 " + "--redirect-uri " + redirectURL + " --format json" @@ -89,7 +90,7 @@ func TestOIDC(t *testing.T) { encodedURL := strings.Split(u.Query().Get("state"), ".")[1] b, _ := base64.URLEncoding.DecodeString(encodedURL) originURL := string(b) - require.Equal(t, "http://localhost:10000/echo?a=1", originURL) + require.Equal(t, fmt.Sprintf("http://localhost:%d/echo?a=1", dp.Port), originURL) require.NotEmpty(t, u.Query().Get("nonce")) require.NotEmpty(t, u.Query().Get("code_challenge")) cookie := resp.Header.Get("Set-Cookie") diff --git a/plugins/tests/integration/sentinel_test.go b/plugins/tests/integration/sentinel_test.go index 585f547f..a606793d 100644 --- a/plugins/tests/integration/sentinel_test.go +++ b/plugins/tests/integration/sentinel_test.go @@ -15,11 +15,9 @@ package integration import ( - "context" _ "embed" "fmt" "io" - "net" "net/http" "net/url" "sync" @@ -38,28 +36,12 @@ var ( sentinelRoute string ) -func doGet(respStatus int, header http.Header, query url.Values) (*http.Response, error) { - u := fmt.Sprintf("http://localhost:10000/sentinel/status/%d", respStatus) +func doGet(dp *dataplane.DataPlane, respStatus int, header http.Header, query url.Values) (*http.Response, error) { + u := fmt.Sprintf("/sentinel/status/%d", respStatus) if query != nil { u += "?" + query.Encode() } - req, err := http.NewRequest(http.MethodGet, u, nil) - if err != nil { - return nil, err - } - req.Header = header - tr := &http.Transport{DialContext: func(ctx context.Context, proto, addr string) (conn net.Conn, err error) { - return net.DialTimeout("tcp", ":10000", 1*time.Second) - }} - - client := &http.Client{Transport: tr, - Timeout: 10 * time.Second, - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse - }, - } - resp, err := client.Do(req) - return resp, err + return dp.Get(u, header) } func TestSentinelFlow(t *testing.T) { @@ -107,12 +89,12 @@ func TestSentinelFlow(t *testing.T) { hdr := http.Header{} hdr.Add("X-Sentinel", "f1") - resp, err := doGet(200, hdr, nil) + resp, err := doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Sentinel-Blocked")) - resp, err = doGet(200, hdr, nil) + resp, err = doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 503, resp.StatusCode) assert.Equal(t, "true", resp.Header.Get("X-Sentinel-Blocked")) @@ -122,7 +104,7 @@ func TestSentinelFlow(t *testing.T) { time.Sleep(1100 * time.Millisecond) - resp, err = doGet(200, hdr, nil) + resp, err = doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Sentinel-Blocked")) @@ -154,10 +136,10 @@ func TestSentinelFlow(t *testing.T) { run: func(t *testing.T) { query := url.Values{} query.Set("query", "f2") - resp, _ := doGet(200, nil, query) + resp, _ := doGet(dp, 200, nil, query) assert.Equal(t, 200, resp.StatusCode) - resp, _ = doGet(200, nil, query) + resp, _ = doGet(dp, 200, nil, query) assert.Equal(t, 503, resp.StatusCode) b, _ := io.ReadAll(resp.Body) assert.Equal(t, "{\"msg\":\"custom block resp: f2\"}", string(b)) @@ -192,7 +174,7 @@ func TestSentinelFlow(t *testing.T) { m := make(map[int64]int) mLock := sync.Mutex{} for i := 0; i < 20; i++ { - resp, _ := doGet(200, hdr, nil) + resp, _ := doGet(dp, 200, hdr, nil) if resp.StatusCode == 200 { k := time.Now().UnixMilli() / 100 // interval is 100ms mLock.Lock() @@ -242,10 +224,10 @@ func TestSentinelFlow(t *testing.T) { hdr := http.Header{} hdr.Add("X-Sentinel", "f4") - resp, _ := doGet(200, hdr, nil) + resp, _ := doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) b, err := io.ReadAll(resp.Body) assert.NoError(t, err) @@ -258,7 +240,7 @@ func TestSentinelFlow(t *testing.T) { // when f3 triggers the traffic limiting, f4 also triggers the traffic limiting, // because the two resources are related - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) b, err = io.ReadAll(resp.Body) assert.NoError(t, err) @@ -323,12 +305,12 @@ func TestSentinelHotSpot(t *testing.T) { hdr := http.Header{} hdr.Add("X-Sentinel", "hs1") - resp, err := doGet(200, hdr, nil) + resp, err := doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Sentinel-Blocked")) - resp, err = doGet(200, hdr, nil) + resp, err = doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 503, resp.StatusCode) assert.Equal(t, "true", resp.Header.Get("X-Sentinel-Blocked")) @@ -337,7 +319,7 @@ func TestSentinelHotSpot(t *testing.T) { time.Sleep(1100 * time.Millisecond) - resp, err = doGet(200, hdr, nil) + resp, err = doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Sentinel-Blocked")) @@ -382,10 +364,10 @@ func TestSentinelHotSpot(t *testing.T) { hdr.Add("X-Sentinel", "hs2") hdr.Add("X-A1", "test") - resp, _ := doGet(200, hdr, nil) + resp, _ := doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) // attachment from query a2, but attachment key is `X-A1`, so there's no traffic control @@ -394,7 +376,7 @@ func TestSentinelHotSpot(t *testing.T) { query := url.Values{} query.Add("a2", "test") for i := 0; i < 5; i++ { - resp, _ = doGet(200, hdr, query) + resp, _ = doGet(dp, 200, hdr, query) assert.Equal(t, 200, resp.StatusCode) } }, @@ -428,11 +410,11 @@ func TestSentinelHotSpot(t *testing.T) { hdr := http.Header{} hdr.Add("X-Sentinel", "hs3") - resp, _ := doGet(200, hdr, nil) + resp, _ := doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) // although the threshold is 10, the threshold for `abc` is specified to be 1 through `specificItems` - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) }, }, @@ -497,7 +479,7 @@ func TestSentinelCircuitBreaker(t *testing.T) { isBreakerOpened := false // 10 requests, 5 of them will trigger the circuit breaker for i := 0; i < 10; i++ { - resp, err := doGet(500, hdr, nil) + resp, err := doGet(dp, 500, hdr, nil) assert.NoError(t, err) b, _ := io.ReadAll(resp.Body) if resp.StatusCode == 503 && @@ -512,7 +494,7 @@ func TestSentinelCircuitBreaker(t *testing.T) { time.Sleep(3100 * time.Millisecond) for i := 0; i < 3; i++ { - resp, err := doGet(200, hdr, nil) + resp, err := doGet(dp, 200, hdr, nil) assert.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Sentinel-Blocked")) @@ -611,10 +593,10 @@ func TestSentinelMixture(t *testing.T) { hdr := http.Header{} hdr.Add("X-Sentinel", "flow") - resp, _ := doGet(200, hdr, nil) + resp, _ := doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) assert.Equal(t, "flow", resp.Header.Get("X-Sentinel-Type")) b, _ := io.ReadAll(resp.Body) @@ -622,7 +604,7 @@ func TestSentinelMixture(t *testing.T) { time.Sleep(1100 * time.Millisecond) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) // flow end @@ -630,10 +612,10 @@ func TestSentinelMixture(t *testing.T) { hdr = http.Header{} hdr.Add("X-Sentinel", "hotspot") - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 503, resp.StatusCode) assert.Equal(t, "hotspot", resp.Header.Get("X-Sentinel-Type")) b, _ = io.ReadAll(resp.Body) @@ -641,7 +623,7 @@ func TestSentinelMixture(t *testing.T) { time.Sleep(1100 * time.Millisecond) - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) // hot spot end @@ -652,7 +634,7 @@ func TestSentinelMixture(t *testing.T) { isBreakerOpened := false // 10 requests, 5 of them will trigger the circuit breaker for i := 0; i < 10; i++ { - resp, _ = doGet(500, hdr, nil) + resp, _ = doGet(dp, 500, hdr, nil) b, _ = io.ReadAll(resp.Body) if resp.StatusCode == 503 && resp.Header.Get("X-Sentinel-Type") == "circuitbreaker" && @@ -666,7 +648,7 @@ func TestSentinelMixture(t *testing.T) { time.Sleep(3100 * time.Millisecond) for i := 0; i < 3; i++ { - resp, _ = doGet(200, hdr, nil) + resp, _ = doGet(dp, 200, hdr, nil) assert.Equal(t, 200, resp.StatusCode) } // circuit breaker end diff --git a/site/content/en/docs/developer-guide/plugin_integration_test_framework.md b/site/content/en/docs/developer-guide/plugin_integration_test_framework.md index 8fbce53c..f11f180b 100644 --- a/site/content/en/docs/developer-guide/plugin_integration_test_framework.md +++ b/site/content/en/docs/developer-guide/plugin_integration_test_framework.md @@ -20,9 +20,10 @@ You may have noticed that when executing `go test`, we added `-tags envoy1.29`. ## Port usage -The test framework will use: +The test framework will occupy the following ports on the host machine: -* `:2023` to represent invalid port -* `:9999` for the control plane -* `:10000` for the Envoy proxy -* `:10001` for the backend server and mock external server +* `:9998` for the Envoy's Admin API, which can be modified by the environment variable `TEST_ENVOY_ADMIN_API_PORT` +* `:9999` for the control plane, which can be modified by the environment variable `TEST_ENVOY_CONTROL_PLANE_PORT` +* `:10000` for the Envoy proxy, which can be modified by the environment variable `TEST_ENVOY_DATA_PLANE_PORT` + +For example, `TEST_ENVOY_CONTROL_PLANE_PORT=19999 go test -v ./tests/integration -run TestPluginXX` will use `:19999` as the control plane port. diff --git a/site/content/zh-hans/docs/developer-guide/plugin_integration_test_framework.md b/site/content/zh-hans/docs/developer-guide/plugin_integration_test_framework.md index f67b1b6d..e4d5c26a 100644 --- a/site/content/zh-hans/docs/developer-guide/plugin_integration_test_framework.md +++ b/site/content/zh-hans/docs/developer-guide/plugin_integration_test_framework.md @@ -20,9 +20,10 @@ title: 插件集成测试框架 ## 端口使用 -测试框架将使用: +测试框架将占用 host 上的下述端口: -* `:2023` 用于表示错误的端口 -* `:9999` 用于控制平面 -* `:10000` 用于数据面 -* `:10001` 用于后端服务器和模拟外部服务器 +* `:9998` 用于 Envoy 管理 API,可通过环境变量 `TEST_ENVOY_ADMIN_API_PORT` 修改 +* `:9999` 用于控制平面,可通过环境变量 `TEST_ENVOY_CONTROL_PLANE_PORT` 修改 +* `:10000` 用于数据面,可通过环境变量 `TEST_ENVOY_DATA_PLANE_PORT` 修改 + +例如,`TEST_ENVOY_CONTROL_PLANE_PORT=19999 go test -v ./tests/integration -run TestPluginXX` 将使用 `:19999` 端口作为控制平面端口。