Skip to content
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
2 changes: 1 addition & 1 deletion test/envoye2e/driver/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (e *Envoy) Run(p *Params) error {
"--disable-hot-restart",
"--drain-time-s", "4", // this affects how long draining listenrs are kept alive
}
envoyPath := filepath.Join(env.GetDefaultEnvoyBin(), "envoy")
envoyPath := filepath.Join(env.GetDefaultEnvoyBinOrDie(), "envoy")
if path, exists := os.LookupEnv("ENVOY_PATH"); exists {
envoyPath = path
}
Expand Down
48 changes: 42 additions & 6 deletions test/envoye2e/env/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,53 @@ import (
"testing"
)

func GetDefaultEnvoyBin() string {
func GetDefaultEnvoyBin() (string, error) {
// Get bazel args if any
buildArgs := os.Getenv("BAZEL_BUILD_ARGS")

// Note: `bazel info bazel-bin` returns incorrect path to a binary (always fastbuild, not opt or dbg)
// Instead we rely on symbolic link src/envoy/envoy in the workspace
workspace, _ := exec.Command("bazel", "info", "workspace").Output()
return filepath.Join(strings.TrimSuffix(string(workspace), "\n"), "bazel-bin/src/envoy/")
args := []string{"info", "workspace"}
if buildArgs != "" {
args = append(args, strings.Split(buildArgs, " ")...)
}
workspace, err := exec.Command("bazel", args...).Output()
if err != nil {
return "", err
}
return filepath.Join(strings.TrimSuffix(string(workspace), "\n"), "bazel-bin/src/envoy/"), nil
}

func GetDefaultEnvoyBinOrDie() string {
p, err := GetDefaultEnvoyBin()
if err != nil {
panic(err)
}
return p
}

func GetBazelOptOut() string {
func GetBazelOptOut() (string, error) {
// Get bazel args if any
buildArgs := os.Getenv("BAZEL_BUILD_ARGS")

// `make build_wasm` puts generated wasm modules into k8-opt.
bazelOutput, _ := exec.Command("bazel", "info", "output_path").Output()
return filepath.Join(strings.TrimSuffix(string(bazelOutput), "\n"), "k8-opt/bin/")
args := []string{"info", "output_path"}
if buildArgs != "" {
args = append(args, strings.Split(buildArgs, " ")...)
}
bazelOutput, err := exec.Command("bazel", args...).Output()
if err != nil {
return "", err
}
return filepath.Join(strings.TrimSuffix(string(bazelOutput), "\n"), "k8-opt/bin/"), nil
}

func GetBazelOptOutOrDie() string {
p, err := GetBazelOptOut()
if err != nil {
panic(err)
}
return p
}

func SkipTSanASan(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/envoye2e/stats_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var AttributeGenRuntimes = []struct {
WasmRuntime: "envoy.wasm.runtime.null",
},
{
AttributeGenFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/attributegen.wasm"),
AttributeGenFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/attributegen.wasm"),
WasmRuntime: "envoy.wasm.runtime.v8",
},
}
Expand Down
10 changes: 5 additions & 5 deletions test/envoye2e/stats_plugin/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ var Runtimes = []struct {
WasmRuntime: "envoy.wasm.runtime.null",
},
{
MetadataExchangeFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/metadata_exchange.wasm"),
StatsFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/stats.wasm"),
MetadataExchangeFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/metadata_exchange.wasm"),
StatsFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/stats.wasm"),
WasmRuntime: "envoy.wasm.runtime.v8",
},
{
MetadataExchangeFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/metadata_exchange.compiled.wasm"),
StatsFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/stats.compiled.wasm"),
MetadataExchangeFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/metadata_exchange.compiled.wasm"),
StatsFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/stats.compiled.wasm"),
WasmRuntime: "envoy.wasm.runtime.v8",
},
}
Expand Down Expand Up @@ -137,7 +137,7 @@ var AttributeGenRuntimes = []struct {
WasmRuntime: "envoy.wasm.runtime.null",
},
{
AttributeGenFilterCode: "filename: " + filepath.Join(env.GetBazelOptOut(), "extensions/attributegen.wasm"),
AttributeGenFilterCode: "filename: " + filepath.Join(env.GetBazelOptOutOrDie(), "extensions/attributegen.wasm"),
WasmRuntime: "envoy.wasm.runtime.v8",
},
}
Expand Down