Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang: merge multiple test go.mods into a single one #37962

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 1 addition & 101 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
18 changes: 4 additions & 14 deletions contrib/golang/filters/http/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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 = [
Expand All @@ -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 = [
Expand Down Expand Up @@ -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 = [
Expand Down
8 changes: 4 additions & 4 deletions contrib/golang/filters/http/test/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dso::HttpFilterDsoImpl>::cleanUpForTest(); }
Expand Down Expand Up @@ -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<Server::Configuration::MockFactoryContext> context;
Expand Down Expand Up @@ -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<Server::Configuration::MockFactoryContext> context;
Expand Down
10 changes: 5 additions & 5 deletions contrib/golang/filters/http/test/golang_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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");
}

Expand Down
16 changes: 8 additions & 8 deletions contrib/golang/filters/http/test/golang_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class GolangIntegrationTest : public testing::TestWithParam<Network::Address::Ip
addFakeUpstream(Http::CodecType::HTTP1);
}

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 initializeConfig(const std::string& lib_id, const std::string& lib_path,
Expand Down Expand Up @@ -132,7 +132,7 @@ name: golang
set: foo
)EOF";

auto yaml_string = absl::StrFormat(yaml_fmt, so_id, genSoPath(so_id), so_id);
auto yaml_string = absl::StrFormat(yaml_fmt, so_id, genSoPath(), so_id);
config_helper_.prependFilter(yaml_string);
if (with_injected_metadata_validator) {
config_helper_.prependFilter("{ name: validate-dynamic-metadata }");
Expand Down Expand Up @@ -289,7 +289,7 @@ name: golang
)EOF";

auto so_id = ADDDATA;
auto yaml_string = absl::StrFormat(yaml_fmt, so_id, genSoPath(so_id), so_id);
auto yaml_string = absl::StrFormat(yaml_fmt, so_id, genSoPath(), so_id);
config_helper_.prependFilter(yaml_string);
config_helper_.skipPortUsageValidation();

Expand Down Expand Up @@ -817,7 +817,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, GolangIntegrationTest,
TestUtility::ipTestParamsToString);

TEST_P(GolangIntegrationTest, Echo) {
initializeConfig(ECHO, genSoPath(ECHO), ECHO);
initializeConfig(ECHO, genSoPath(), ECHO);
initialize();
registerTestServerPorts({"http"});

Expand All @@ -843,7 +843,7 @@ TEST_P(GolangIntegrationTest, Echo) {
}

TEST_P(GolangIntegrationTest, Passthrough) {
initializeConfig(PASSTHROUGH, genSoPath(PASSTHROUGH), PASSTHROUGH);
initializeConfig(PASSTHROUGH, genSoPath(), PASSTHROUGH);
initialize();
registerTestServerPorts({"http"});

Expand Down Expand Up @@ -880,7 +880,7 @@ TEST_P(GolangIntegrationTest, Passthrough) {
}

TEST_P(GolangIntegrationTest, PluginNotFound) {
initializeConfig(ECHO, genSoPath(ECHO), PASSTHROUGH);
initializeConfig(ECHO, genSoPath(), PASSTHROUGH);
initialize();
registerTestServerPorts({"http"});

Expand All @@ -904,7 +904,7 @@ TEST_P(GolangIntegrationTest, BufferResetAfterDrain) { testBufferApi("ResetAfter
TEST_P(GolangIntegrationTest, BufferLen) { testBufferApi("Len"); }

TEST_P(GolangIntegrationTest, Property) {
initializePropertyConfig(PROPERTY, genSoPath(PROPERTY), PROPERTY);
initializePropertyConfig(PROPERTY, genSoPath(), PROPERTY);
initialize();
registerTestServerPorts({"http"});

Expand Down
32 changes: 32 additions & 0 deletions contrib/golang/filters/http/test/test_data/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

licenses(["notice"]) # Apache 2

go_binary(
name = "plugins.so",
srcs = [
"plugins.go",
],
out = "plugins.so",
cgo = True,
importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data",
linkmode = "c-shared",
visibility = ["//visibility:public"],
deps = [
"//contrib/golang/common/go/api",
"//contrib/golang/filters/http/source/go/pkg/http",
"//contrib/golang/filters/http/test/test_data/access_log",
"//contrib/golang/filters/http/test/test_data/action",
"//contrib/golang/filters/http/test/test_data/add_data",
"//contrib/golang/filters/http/test/test_data/basic",
"//contrib/golang/filters/http/test/test_data/buffer",
"//contrib/golang/filters/http/test/test_data/echo",
"//contrib/golang/filters/http/test/test_data/metric",
"//contrib/golang/filters/http/test/test_data/passthrough",
"//contrib/golang/filters/http/test/test_data/property",
"//contrib/golang/filters/http/test/test_data/routeconfig",
"//contrib/golang/filters/http/test/test_data/websocket",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/structpb",
],
)
10 changes: 4 additions & 6 deletions contrib/golang/filters/http/test/test_data/access_log/BUILD
Original file line number Diff line number Diff line change
@@ -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 = "access_log",
srcs = [
"config.go",
"filter.go",
],
out = "filter.so",
cgo = True,
importpath = "github.com/envoyproxy/envoy/contrib/golang/filters/http/test/test_data/access_log",
linkmode = "c-shared",
importpath = "example.com/test-data/access_log",
visibility = ["//visibility:public"],
deps = [
"//contrib/golang/common/go/api",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package access_log

import (
"google.golang.org/protobuf/types/known/anypb"
Expand Down Expand Up @@ -38,5 +38,3 @@ func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea
config: conf,
}
}

func main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package access_log

import (
"strconv"
Expand Down
9 changes: 0 additions & 9 deletions contrib/golang/filters/http/test/test_data/access_log/go.mod

This file was deleted.

Loading