From afdcf9644caa0f0a83d7986dd1b71b513e9de8fa Mon Sep 17 00:00:00 2001 From: doujiang24 Date: Sat, 11 Jan 2025 01:03:58 +0800 Subject: [PATCH] golang: merge multiple test go.mods into a single one (#37962) To make dependabot happy, as discussed in [slack](https://envoyproxy.slack.com/archives/C04QNSXC7U0/p1736352171382819) Signed-off-by: doujiang24 --- .github/dependabot.yml | 102 +----------------- contrib/golang/filters/http/test/BUILD | 18 +--- .../golang/filters/http/test/config_test.cc | 8 +- .../filters/http/test/golang_filter_test.cc | 10 +- .../http/test/golang_integration_test.cc | 16 +-- .../golang/filters/http/test/test_data/BUILD | 32 ++++++ .../http/test/test_data/access_log/BUILD | 10 +- .../http/test/test_data/access_log/config.go | 4 +- .../http/test/test_data/access_log/filter.go | 2 +- .../http/test/test_data/access_log/go.mod | 9 -- .../filters/http/test/test_data/action/BUILD | 10 +- .../http/test/test_data/action/config.go | 4 +- .../http/test/test_data/action/filter.go | 2 +- .../filters/http/test/test_data/action/go.mod | 9 -- .../http/test/test_data/add_data/BUILD | 10 +- .../http/test/test_data/add_data/config.go | 4 +- .../http/test/test_data/add_data/filter.go | 2 +- .../http/test/test_data/add_data/go.mod | 9 -- .../filters/http/test/test_data/basic/BUILD | 10 +- .../http/test/test_data/basic/config.go | 5 +- .../http/test/test_data/basic/filter.go | 2 +- .../filters/http/test/test_data/basic/go.mod | 9 -- .../filters/http/test/test_data/buffer/BUILD | 10 +- .../http/test/test_data/buffer/config.go | 4 +- .../http/test/test_data/buffer/filter.go | 2 +- .../filters/http/test/test_data/buffer/go.mod | 10 -- .../filters/http/test/test_data/dummy/go.mod | 2 +- .../filters/http/test/test_data/echo/BUILD | 10 +- .../http/test/test_data/echo/config.go | 4 +- .../http/test/test_data/echo/filter.go | 2 +- .../filters/http/test/test_data/echo/go.mod | 21 ---- .../golang/filters/http/test/test_data/go.mod | 19 ++++ .../filters/http/test/test_data/metric/BUILD | 10 +- .../http/test/test_data/metric/config.go | 5 +- .../http/test/test_data/metric/filter.go | 2 +- .../filters/http/test/test_data/metric/go.mod | 9 -- .../http/test/test_data/passthrough/BUILD | 10 +- .../http/test/test_data/passthrough/filter.go | 5 +- .../http/test/test_data/passthrough/go.mod | 9 -- .../filters/http/test/test_data/plugins.go | 17 +++ .../http/test/test_data/property/BUILD | 10 +- .../http/test/test_data/property/config.go | 4 +- .../http/test/test_data/property/filter.go | 2 +- .../http/test/test_data/property/go.mod | 10 -- .../http/test/test_data/routeconfig/BUILD | 10 +- .../http/test/test_data/routeconfig/config.go | 5 +- .../http/test/test_data/routeconfig/filter.go | 2 +- .../http/test/test_data/routeconfig/go.mod | 21 ---- .../http/test/test_data/websocket/BUILD | 10 +- .../http/test/test_data/websocket/config.go | 5 +- .../http/test/test_data/websocket/filter.go | 2 +- .../http/test/test_data/websocket/go.mod | 9 -- .../http/test/websocket_integration_test.cc | 6 +- 53 files changed, 159 insertions(+), 375 deletions(-) create mode 100644 contrib/golang/filters/http/test/test_data/BUILD delete mode 100644 contrib/golang/filters/http/test/test_data/access_log/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/action/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/add_data/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/basic/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/buffer/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/echo/go.mod create mode 100644 contrib/golang/filters/http/test/test_data/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/metric/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/passthrough/go.mod create mode 100644 contrib/golang/filters/http/test/test_data/plugins.go delete mode 100644 contrib/golang/filters/http/test/test_data/property/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/routeconfig/go.mod delete mode 100644 contrib/golang/filters/http/test/test_data/websocket/go.mod diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7580a6e07c1e..ba66a0bd0968 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -41,47 +41,7 @@ updates: time: "06:00" - package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/access_log" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/action" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/add_data" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/basic" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/buffer" + directory: "/contrib/golang/filters/http/test/test_data" groups: contrib-golang: patterns: @@ -100,66 +60,6 @@ updates: interval: daily time: "06:00" -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/echo" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/metric" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/passthrough" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/property" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/routeconfig" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - -- package-ecosystem: "gomod" - directory: "/contrib/golang/filters/http/test/test_data/websocket" - groups: - contrib-golang: - patterns: - - "*" - schedule: - interval: daily - time: "06:00" - - package-ecosystem: "gomod" directory: "/contrib/golang/filters/network/test/test_data" groups: diff --git a/contrib/golang/filters/http/test/BUILD b/contrib/golang/filters/http/test/BUILD index fc2f544933fc..cec24068d5ab 100644 --- a/contrib/golang/filters/http/test/BUILD +++ b/contrib/golang/filters/http/test/BUILD @@ -14,7 +14,7 @@ envoy_cc_test( name = "config_test", srcs = ["config_test.cc"], data = [ - "//contrib/golang/filters/http/test/test_data/passthrough:filter.so", + "//contrib/golang/filters/http/test/test_data:plugins.so", ], rbe_pool = "6gig", deps = [ @@ -28,8 +28,7 @@ envoy_cc_test( name = "golang_filter_test", srcs = ["golang_filter_test.cc"], data = [ - "//contrib/golang/filters/http/test/test_data/passthrough:filter.so", - "//contrib/golang/filters/http/test/test_data/routeconfig:filter.so", + "//contrib/golang/filters/http/test/test_data:plugins.so", ], rbe_pool = "6gig", deps = [ @@ -52,16 +51,7 @@ envoy_cc_test( name = "golang_integration_test", srcs = ["golang_integration_test.cc"], data = [ - "//contrib/golang/filters/http/test/test_data/access_log:filter.so", - "//contrib/golang/filters/http/test/test_data/action:filter.so", - "//contrib/golang/filters/http/test/test_data/add_data:filter.so", - "//contrib/golang/filters/http/test/test_data/basic:filter.so", - "//contrib/golang/filters/http/test/test_data/buffer:filter.so", - "//contrib/golang/filters/http/test/test_data/echo:filter.so", - "//contrib/golang/filters/http/test/test_data/metric:filter.so", - "//contrib/golang/filters/http/test/test_data/passthrough:filter.so", - "//contrib/golang/filters/http/test/test_data/property:filter.so", - "//contrib/golang/filters/http/test/test_data/routeconfig:filter.so", + "//contrib/golang/filters/http/test/test_data:plugins.so", ], rbe_pool = "6gig", deps = [ @@ -109,7 +99,7 @@ envoy_cc_test( size = "large", srcs = ["websocket_integration_test.cc"], data = [ - "//contrib/golang/filters/http/test/test_data/websocket:filter.so", + "//contrib/golang/filters/http/test/test_data:plugins.so", ], rbe_pool = "6gig", tags = [ diff --git a/contrib/golang/filters/http/test/config_test.cc b/contrib/golang/filters/http/test/config_test.cc index 4dd471302711..96aeed77b35a 100644 --- a/contrib/golang/filters/http/test/config_test.cc +++ b/contrib/golang/filters/http/test/config_test.cc @@ -21,9 +21,9 @@ namespace HttpFilters { namespace Golang { namespace { -std::string genSoPath(std::string name) { +std::string genSoPath() { return TestEnvironment::substitute( - "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/" + name + "/filter.so"); + "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/plugins.so"); } void cleanup() { Dso::DsoManager::cleanUpForTest(); } @@ -55,7 +55,7 @@ TEST(GolangFilterConfigTest, GolangFilterWithValidConfig) { )EOF"; const std::string PASSTHROUGH{"passthrough"}; - auto yaml_string = absl::StrFormat(yaml_fmt, PASSTHROUGH, genSoPath(PASSTHROUGH)); + auto yaml_string = absl::StrFormat(yaml_fmt, PASSTHROUGH, genSoPath()); envoy::extensions::filters::http::golang::v3alpha::Config proto_config; TestUtility::loadFromYaml(yaml_string, proto_config); NiceMock context; @@ -84,7 +84,7 @@ TEST(GolangFilterConfigTest, GolangFilterWithNilPluginConfig) { )EOF"; const std::string PASSTHROUGH{"passthrough"}; - auto yaml_string = absl::StrFormat(yaml_fmt, PASSTHROUGH, genSoPath(PASSTHROUGH)); + auto yaml_string = absl::StrFormat(yaml_fmt, PASSTHROUGH, genSoPath()); envoy::extensions::filters::http::golang::v3alpha::Config proto_config; TestUtility::loadFromYaml(yaml_string, proto_config); NiceMock context; diff --git a/contrib/golang/filters/http/test/golang_filter_test.cc b/contrib/golang/filters/http/test/golang_filter_test.cc index 365f69899f91..53b0725f6ae8 100644 --- a/contrib/golang/filters/http/test/golang_filter_test.cc +++ b/contrib/golang/filters/http/test/golang_filter_test.cc @@ -104,9 +104,9 @@ class GolangHttpFilterTest : public testing::Test { setupFilter(plugin_name); } - std::string genSoPath(std::string name) { + std::string genSoPath() { return TestEnvironment::substitute( - "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/" + name + "/filter.so"); + "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/plugins.so"); } void setupDso(std::string id, std::string path, std::string plugin_name) { @@ -166,7 +166,7 @@ class GolangHttpFilterTest : public testing::Test { // request that is headers only. TEST_F(GolangHttpFilterTest, ScriptHeadersOnlyRequestHeadersOnly) { InSequence s; - setup(PASSTHROUGH, genSoPath(PASSTHROUGH), PASSTHROUGH); + setup(PASSTHROUGH, genSoPath(), PASSTHROUGH); Http::TestRequestHeaderMapImpl request_headers{{":path", "/"}}; EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->decodeHeaders(request_headers, true)); @@ -176,7 +176,7 @@ TEST_F(GolangHttpFilterTest, ScriptHeadersOnlyRequestHeadersOnly) { // setHeader at wrong stage TEST_F(GolangHttpFilterTest, SetHeaderAtWrongStage) { InSequence s; - setup(PASSTHROUGH, genSoPath(PASSTHROUGH), PASSTHROUGH); + setup(PASSTHROUGH, genSoPath(), PASSTHROUGH); auto req = new HttpRequestInternal(*filter_); EXPECT_EQ(CAPINotInGo, filter_->setHeader(req->decodingState(), "foo", "bar", HeaderSet)); @@ -187,7 +187,7 @@ TEST_F(GolangHttpFilterTest, SetHeaderAtWrongStage) { // invalid config for routeconfig filter TEST_F(GolangHttpFilterTest, InvalidConfigForRouteConfigFilter) { InSequence s; - EXPECT_THROW_WITH_REGEX(setup(ROUTECONFIG, genSoPath(ROUTECONFIG), ROUTECONFIG), EnvoyException, + EXPECT_THROW_WITH_REGEX(setup(ROUTECONFIG, genSoPath(), ROUTECONFIG), EnvoyException, "golang filter failed to parse plugin config"); } diff --git a/contrib/golang/filters/http/test/golang_integration_test.cc b/contrib/golang/filters/http/test/golang_integration_test.cc index 6ad5361d5c07..fe8b9df14846 100644 --- a/contrib/golang/filters/http/test/golang_integration_test.cc +++ b/contrib/golang/filters/http/test/golang_integration_test.cc @@ -90,9 +90,9 @@ class GolangIntegrationTest : public testing::TestWithParam ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/action/BUILD b/contrib/golang/filters/http/test/test_data/action/BUILD index daaf13cce009..9f514ee18b7c 100644 --- a/contrib/golang/filters/http/test/test_data/action/BUILD +++ b/contrib/golang/filters/http/test/test_data/action/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "action", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/action", - linkmode = "c-shared", + importpath = "example.com/test-data/action", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/action/config.go b/contrib/golang/filters/http/test/test_data/action/config.go index 87b48690ac7f..580494301292 100644 --- a/contrib/golang/filters/http/test/test_data/action/config.go +++ b/contrib/golang/filters/http/test/test_data/action/config.go @@ -1,4 +1,4 @@ -package main +package action import ( "github.com/envoyproxy/envoy/contrib/golang/common/go/api" @@ -16,5 +16,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea callbacks: callbacks, } } - -func main() {} diff --git a/contrib/golang/filters/http/test/test_data/action/filter.go b/contrib/golang/filters/http/test/test_data/action/filter.go index 5829945d16f5..a28e3fab0470 100644 --- a/contrib/golang/filters/http/test/test_data/action/filter.go +++ b/contrib/golang/filters/http/test/test_data/action/filter.go @@ -1,4 +1,4 @@ -package main +package action import ( "net/url" diff --git a/contrib/golang/filters/http/test/test_data/action/go.mod b/contrib/golang/filters/http/test/test_data/action/go.mod deleted file mode 100644 index 2e75a107b1c5..000000000000 --- a/contrib/golang/filters/http/test/test_data/action/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/action - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.33.0 // indirect - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/add_data/BUILD b/contrib/golang/filters/http/test/test_data/add_data/BUILD index 50c74bed87e4..b91299616a42 100644 --- a/contrib/golang/filters/http/test/test_data/add_data/BUILD +++ b/contrib/golang/filters/http/test/test_data/add_data/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "add_data", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/add_data", - linkmode = "c-shared", + importpath = "example.com/test-data/add_data", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/add_data/config.go b/contrib/golang/filters/http/test/test_data/add_data/config.go index d3c2fb1dfcfd..d257e56989f2 100644 --- a/contrib/golang/filters/http/test/test_data/add_data/config.go +++ b/contrib/golang/filters/http/test/test_data/add_data/config.go @@ -1,4 +1,4 @@ -package main +package add_data import ( "google.golang.org/protobuf/types/known/anypb" @@ -37,5 +37,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea config: conf, } } - -func main() {} diff --git a/contrib/golang/filters/http/test/test_data/add_data/filter.go b/contrib/golang/filters/http/test/test_data/add_data/filter.go index d78861378449..fdf7ae8f83fc 100644 --- a/contrib/golang/filters/http/test/test_data/add_data/filter.go +++ b/contrib/golang/filters/http/test/test_data/add_data/filter.go @@ -1,4 +1,4 @@ -package main +package add_data import ( "net/url" diff --git a/contrib/golang/filters/http/test/test_data/add_data/go.mod b/contrib/golang/filters/http/test/test_data/add_data/go.mod deleted file mode 100644 index e2f836c37ac9..000000000000 --- a/contrib/golang/filters/http/test/test_data/add_data/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/add_data - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.36.1 - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/basic/BUILD b/contrib/golang/filters/http/test/test_data/basic/BUILD index 99fdc0fa5d17..88ba80afa8d0 100644 --- a/contrib/golang/filters/http/test/test_data/basic/BUILD +++ b/contrib/golang/filters/http/test/test_data/basic/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "basic", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/basic", - linkmode = "c-shared", + importpath = "example.com/test-data/basic", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/basic/config.go b/contrib/golang/filters/http/test/test_data/basic/config.go index cb099a60d70c..60b4f62d2e23 100644 --- a/contrib/golang/filters/http/test/test_data/basic/config.go +++ b/contrib/golang/filters/http/test/test_data/basic/config.go @@ -1,4 +1,4 @@ -package main +package basic import ( "github.com/envoyproxy/envoy/contrib/golang/common/go/api" @@ -19,6 +19,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea callbacks: callbacks, } } - -func main() { -} diff --git a/contrib/golang/filters/http/test/test_data/basic/filter.go b/contrib/golang/filters/http/test/test_data/basic/filter.go index 71338c5cec11..66a5d7332128 100644 --- a/contrib/golang/filters/http/test/test_data/basic/filter.go +++ b/contrib/golang/filters/http/test/test_data/basic/filter.go @@ -1,4 +1,4 @@ -package main +package basic import ( "fmt" diff --git a/contrib/golang/filters/http/test/test_data/basic/go.mod b/contrib/golang/filters/http/test/test_data/basic/go.mod deleted file mode 100644 index ef1378b50ca2..000000000000 --- a/contrib/golang/filters/http/test/test_data/basic/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/basic - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.33.0 // indirect - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/buffer/BUILD b/contrib/golang/filters/http/test/test_data/buffer/BUILD index c072c6e72f57..8c1540b70c5a 100644 --- a/contrib/golang/filters/http/test/test_data/buffer/BUILD +++ b/contrib/golang/filters/http/test/test_data/buffer/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "buffer", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/buffer", - linkmode = "c-shared", + importpath = "example.com/test-data/buffer", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/buffer/config.go b/contrib/golang/filters/http/test/test_data/buffer/config.go index e2a5b75a207c..a047a98a45f6 100644 --- a/contrib/golang/filters/http/test/test_data/buffer/config.go +++ b/contrib/golang/filters/http/test/test_data/buffer/config.go @@ -1,4 +1,4 @@ -package main +package buffer import ( "google.golang.org/protobuf/types/known/anypb" @@ -38,5 +38,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea config: conf, } } - -func main() {} diff --git a/contrib/golang/filters/http/test/test_data/buffer/filter.go b/contrib/golang/filters/http/test/test_data/buffer/filter.go index 9b0d9f6a8d41..62b0233d0b7f 100644 --- a/contrib/golang/filters/http/test/test_data/buffer/filter.go +++ b/contrib/golang/filters/http/test/test_data/buffer/filter.go @@ -1,4 +1,4 @@ -package main +package buffer import ( "fmt" diff --git a/contrib/golang/filters/http/test/test_data/buffer/go.mod b/contrib/golang/filters/http/test/test_data/buffer/go.mod deleted file mode 100644 index 769375c0b4af..000000000000 --- a/contrib/golang/filters/http/test/test_data/buffer/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module example.com/buffer - -go 1.22 - -require ( - github.com/envoyproxy/envoy v1.24.0 - google.golang.org/protobuf v1.36.1 -) - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/dummy/go.mod b/contrib/golang/filters/http/test/test_data/dummy/go.mod index 1355c37b7682..25094545aa06 100644 --- a/contrib/golang/filters/http/test/test_data/dummy/go.mod +++ b/contrib/golang/filters/http/test/test_data/dummy/go.mod @@ -4,6 +4,6 @@ go 1.22 require github.com/envoyproxy/envoy v1.24.0 -require google.golang.org/protobuf v1.33.0 // indirect +require google.golang.org/protobuf v1.36.1 // indirect replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/echo/BUILD b/contrib/golang/filters/http/test/test_data/echo/BUILD index 1764f4ea0d17..37ab2f0a8fa7 100644 --- a/contrib/golang/filters/http/test/test_data/echo/BUILD +++ b/contrib/golang/filters/http/test/test_data/echo/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "echo", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/echo", - linkmode = "c-shared", + importpath = "example.com/test-data/echo", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/echo/config.go b/contrib/golang/filters/http/test/test_data/echo/config.go index 3e501a0d0e14..90c719b53832 100644 --- a/contrib/golang/filters/http/test/test_data/echo/config.go +++ b/contrib/golang/filters/http/test/test_data/echo/config.go @@ -1,4 +1,4 @@ -package main +package echo import ( xds "github.com/cncf/xds/go/xds/type/v3" @@ -53,5 +53,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea config: conf, } } - -func main() {} diff --git a/contrib/golang/filters/http/test/test_data/echo/filter.go b/contrib/golang/filters/http/test/test_data/echo/filter.go index 0ae00890fba3..36cf4ed9738e 100644 --- a/contrib/golang/filters/http/test/test_data/echo/filter.go +++ b/contrib/golang/filters/http/test/test_data/echo/filter.go @@ -1,4 +1,4 @@ -package main +package echo import ( "fmt" diff --git a/contrib/golang/filters/http/test/test_data/echo/go.mod b/contrib/golang/filters/http/test/test_data/echo/go.mod deleted file mode 100644 index 5fa85e62e27e..000000000000 --- a/contrib/golang/filters/http/test/test_data/echo/go.mod +++ /dev/null @@ -1,21 +0,0 @@ -module example.com/echo - -go 1.22 - -require ( - github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa - github.com/envoyproxy/envoy v1.24.0 -) - -require ( - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect -) - -require ( - github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - google.golang.org/protobuf v1.36.1 -) - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/go.mod b/contrib/golang/filters/http/test/test_data/go.mod new file mode 100644 index 000000000000..7fc0f07ced60 --- /dev/null +++ b/contrib/golang/filters/http/test/test_data/go.mod @@ -0,0 +1,19 @@ +module example.com/test-data + +go 1.22 + +require github.com/envoyproxy/envoy v1.24.0 + +require ( + github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3 + google.golang.org/protobuf v1.36.1 +) + +require ( + cel.dev/expr v0.15.0 // indirect + github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect +) + +replace github.com/envoyproxy/envoy => ../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/metric/BUILD b/contrib/golang/filters/http/test/test_data/metric/BUILD index 5f55ffe25b46..c334bf9e0577 100644 --- a/contrib/golang/filters/http/test/test_data/metric/BUILD +++ b/contrib/golang/filters/http/test/test_data/metric/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "metric", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/metric", - linkmode = "c-shared", + importpath = "example.com/test-data/metric", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/metric/config.go b/contrib/golang/filters/http/test/test_data/metric/config.go index fcb2343a3357..ced3f54478ab 100644 --- a/contrib/golang/filters/http/test/test_data/metric/config.go +++ b/contrib/golang/filters/http/test/test_data/metric/config.go @@ -1,4 +1,4 @@ -package main +package metric import ( "google.golang.org/protobuf/types/known/anypb" @@ -47,6 +47,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea config: conf, } } - -func main() { -} diff --git a/contrib/golang/filters/http/test/test_data/metric/filter.go b/contrib/golang/filters/http/test/test_data/metric/filter.go index ca390e053b0c..50cdd273321a 100644 --- a/contrib/golang/filters/http/test/test_data/metric/filter.go +++ b/contrib/golang/filters/http/test/test_data/metric/filter.go @@ -1,4 +1,4 @@ -package main +package metric import ( "net/url" diff --git a/contrib/golang/filters/http/test/test_data/metric/go.mod b/contrib/golang/filters/http/test/test_data/metric/go.mod deleted file mode 100644 index b1f6549cc6d1..000000000000 --- a/contrib/golang/filters/http/test/test_data/metric/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/basic - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.36.1 - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/passthrough/BUILD b/contrib/golang/filters/http/test/test_data/passthrough/BUILD index a9dd87316c58..0126623ea574 100644 --- a/contrib/golang/filters/http/test/test_data/passthrough/BUILD +++ b/contrib/golang/filters/http/test/test_data/passthrough/BUILD @@ -1,16 +1,14 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "passthrough", srcs = [ "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/passthrough", - linkmode = "c-shared", + importpath = "example.com/test-data/passthrough", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/passthrough/filter.go b/contrib/golang/filters/http/test/test_data/passthrough/filter.go index 3c90dbcd1059..4669d047f08b 100644 --- a/contrib/golang/filters/http/test/test_data/passthrough/filter.go +++ b/contrib/golang/filters/http/test/test_data/passthrough/filter.go @@ -1,4 +1,4 @@ -package main +package passthrough import ( "github.com/envoyproxy/envoy/contrib/golang/filters/http/source/go/pkg/http" @@ -7,6 +7,3 @@ import ( func init() { http.RegisterHttpFilterFactoryAndConfigParser("passthrough", http.PassThroughFactory, http.NullParser) } - -func main() { -} diff --git a/contrib/golang/filters/http/test/test_data/passthrough/go.mod b/contrib/golang/filters/http/test/test_data/passthrough/go.mod deleted file mode 100644 index 7900685fdc15..000000000000 --- a/contrib/golang/filters/http/test/test_data/passthrough/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/passthrough - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.33.0 // indirect - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/plugins.go b/contrib/golang/filters/http/test/test_data/plugins.go new file mode 100644 index 000000000000..ae24999d71fc --- /dev/null +++ b/contrib/golang/filters/http/test/test_data/plugins.go @@ -0,0 +1,17 @@ +package main + +import ( + _ "example.com/test-data/access_log" + _ "example.com/test-data/action" + _ "example.com/test-data/add_data" + _ "example.com/test-data/basic" + _ "example.com/test-data/buffer" + _ "example.com/test-data/echo" + _ "example.com/test-data/metric" + _ "example.com/test-data/passthrough" + _ "example.com/test-data/property" + _ "example.com/test-data/routeconfig" + _ "example.com/test-data/websocket" +) + +func main() {} diff --git a/contrib/golang/filters/http/test/test_data/property/BUILD b/contrib/golang/filters/http/test/test_data/property/BUILD index cbbb582905da..29ae5208c2ff 100644 --- a/contrib/golang/filters/http/test/test_data/property/BUILD +++ b/contrib/golang/filters/http/test/test_data/property/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "property", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/property", - linkmode = "c-shared", + importpath = "example.com/test-data/property", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/property/config.go b/contrib/golang/filters/http/test/test_data/property/config.go index 60f10c98602c..80d9119f228b 100644 --- a/contrib/golang/filters/http/test/test_data/property/config.go +++ b/contrib/golang/filters/http/test/test_data/property/config.go @@ -1,4 +1,4 @@ -package main +package property import ( "google.golang.org/protobuf/types/known/anypb" @@ -38,5 +38,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea config: conf, } } - -func main() {} diff --git a/contrib/golang/filters/http/test/test_data/property/filter.go b/contrib/golang/filters/http/test/test_data/property/filter.go index e61df65f2392..efbd314122a6 100644 --- a/contrib/golang/filters/http/test/test_data/property/filter.go +++ b/contrib/golang/filters/http/test/test_data/property/filter.go @@ -1,4 +1,4 @@ -package main +package property import ( "strconv" diff --git a/contrib/golang/filters/http/test/test_data/property/go.mod b/contrib/golang/filters/http/test/test_data/property/go.mod deleted file mode 100644 index c7d5c89ee5e4..000000000000 --- a/contrib/golang/filters/http/test/test_data/property/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module example.com/property - -go 1.22 - -require ( - github.com/envoyproxy/envoy v1.24.0 - google.golang.org/protobuf v1.36.1 -) - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/routeconfig/BUILD b/contrib/golang/filters/http/test/test_data/routeconfig/BUILD index a477ad3ddab3..f3e6a6918881 100644 --- a/contrib/golang/filters/http/test/test_data/routeconfig/BUILD +++ b/contrib/golang/filters/http/test/test_data/routeconfig/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "routeconfig", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/routeconfig", - linkmode = "c-shared", + importpath = "example.com/test-data/routeconfig", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/routeconfig/config.go b/contrib/golang/filters/http/test/test_data/routeconfig/config.go index 6b77040fd2a8..bd84db78f8a2 100644 --- a/contrib/golang/filters/http/test/test_data/routeconfig/config.go +++ b/contrib/golang/filters/http/test/test_data/routeconfig/config.go @@ -1,4 +1,4 @@ -package main +package routeconfig import ( "errors" @@ -69,6 +69,3 @@ func (p *parser) Merge(parent interface{}, child interface{}) interface{} { } return &newConfig } - -func main() { -} diff --git a/contrib/golang/filters/http/test/test_data/routeconfig/filter.go b/contrib/golang/filters/http/test/test_data/routeconfig/filter.go index d365d683ce12..85e693ee9b9b 100644 --- a/contrib/golang/filters/http/test/test_data/routeconfig/filter.go +++ b/contrib/golang/filters/http/test/test_data/routeconfig/filter.go @@ -1,4 +1,4 @@ -package main +package routeconfig import ( "github.com/envoyproxy/envoy/contrib/golang/common/go/api" diff --git a/contrib/golang/filters/http/test/test_data/routeconfig/go.mod b/contrib/golang/filters/http/test/test_data/routeconfig/go.mod deleted file mode 100644 index 16a089f61261..000000000000 --- a/contrib/golang/filters/http/test/test_data/routeconfig/go.mod +++ /dev/null @@ -1,21 +0,0 @@ -module example.com/routeconfig - -go 1.22 - -require ( - github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa - github.com/envoyproxy/envoy v1.24.0 -) - -require ( - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect -) - -require ( - github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - google.golang.org/protobuf v1.36.1 -) - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/test_data/websocket/BUILD b/contrib/golang/filters/http/test/test_data/websocket/BUILD index bf9dbe54e186..4abd0f3c5abe 100644 --- a/contrib/golang/filters/http/test/test_data/websocket/BUILD +++ b/contrib/golang/filters/http/test/test_data/websocket/BUILD @@ -1,17 +1,15 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library") licenses(["notice"]) # Apache 2 -go_binary( - name = "filter.so", +go_library( + name = "websocket", srcs = [ "config.go", "filter.go", ], - out = "filter.so", cgo = True, - importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/websocket", - linkmode = "c-shared", + importpath = "example.com/test-data/websocket", visibility = ["//visibility:public"], deps = [ "//contrib/golang/common/go/api", diff --git a/contrib/golang/filters/http/test/test_data/websocket/config.go b/contrib/golang/filters/http/test/test_data/websocket/config.go index 0886c96295f8..2d377e1421f1 100644 --- a/contrib/golang/filters/http/test/test_data/websocket/config.go +++ b/contrib/golang/filters/http/test/test_data/websocket/config.go @@ -1,4 +1,4 @@ -package main +package websocket import ( "github.com/envoyproxy/envoy/contrib/golang/common/go/api" @@ -16,6 +16,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea callbacks: callbacks, } } - -func main() { -} diff --git a/contrib/golang/filters/http/test/test_data/websocket/filter.go b/contrib/golang/filters/http/test/test_data/websocket/filter.go index 5e01829ed01d..468a946df39c 100644 --- a/contrib/golang/filters/http/test/test_data/websocket/filter.go +++ b/contrib/golang/filters/http/test/test_data/websocket/filter.go @@ -1,4 +1,4 @@ -package main +package websocket import ( "fmt" diff --git a/contrib/golang/filters/http/test/test_data/websocket/go.mod b/contrib/golang/filters/http/test/test_data/websocket/go.mod deleted file mode 100644 index d05aa1beec5c..000000000000 --- a/contrib/golang/filters/http/test/test_data/websocket/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module example.com/websocket - -go 1.22 - -require github.com/envoyproxy/envoy v1.24.0 - -require google.golang.org/protobuf v1.33.0 // indirect - -replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/contrib/golang/filters/http/test/websocket_integration_test.cc b/contrib/golang/filters/http/test/websocket_integration_test.cc index 271eaf03073e..dcab4eb79884 100644 --- a/contrib/golang/filters/http/test/websocket_integration_test.cc +++ b/contrib/golang/filters/http/test/websocket_integration_test.cc @@ -34,9 +34,9 @@ ConfigHelper::HttpModifierFunction setRouteUsingWebsocket() { void WebsocketIntegrationTest::initialize() { HttpProtocolIntegrationTest::initialize(); } -std::string genSoPath(std::string name) { +std::string genSoPath() { return TestEnvironment::substitute( - "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/" + name + "/filter.so"); + "{{ test_rundir }}/contrib/golang/filters/http/test/test_data/plugins.so"); } std::string filterConfig(const std::string& name) { @@ -54,7 +54,7 @@ name: golang match_path: "/echo" )EOF"; - return absl::StrFormat(yaml_fmt, name, genSoPath(name), name); + return absl::StrFormat(yaml_fmt, name, genSoPath(), name); } TEST_P(GolangWebsocketIntegrationTest, WebsocketGolangFilterChain) {