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

build: Add envoy_extension_py_test for excluding extensions with py_tests #15319

Merged
merged 5 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 0 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ load(
_envoy_cc_test = "envoy_cc_test",
_envoy_cc_test_binary = "envoy_cc_test_binary",
_envoy_cc_test_library = "envoy_cc_test_library",
_envoy_py_test = "envoy_py_test",
_envoy_py_test_binary = "envoy_py_test_binary",
_envoy_sh_test = "envoy_sh_test",
)
Expand Down Expand Up @@ -215,5 +216,6 @@ envoy_cc_test_binary = _envoy_cc_test_binary
envoy_cc_test_library = _envoy_cc_test_library
envoy_cc_benchmark_binary = _envoy_cc_benchmark_binary
envoy_benchmark_test = _envoy_benchmark_test
envoy_py_test = _envoy_py_test
envoy_py_test_binary = _envoy_py_test_binary
envoy_sh_test = _envoy_sh_test
14 changes: 13 additions & 1 deletion bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy test targets. This includes both test library and test binary targets.
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "fuzzing_decoration")
load(":envoy_binary.bzl", "envoy_cc_binary")
Expand Down Expand Up @@ -269,6 +269,18 @@ def envoy_py_test_binary(
**kargs
)

# Envoy py_tests should be specified with this function.
def envoy_py_test(
name,
external_deps = [],
deps = [],
**kargs):
py_test(
name = name,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps],
**kargs
)

# Envoy C++ mock targets should be specified with this function.
def envoy_cc_mock(name, **kargs):
envoy_cc_test_library(name = name, **kargs)
Expand Down
9 changes: 8 additions & 1 deletion test/extensions/extensions_build_system.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//bazel:envoy_build_system.bzl", "envoy_benchmark_test", "envoy_cc_benchmark_binary", "envoy_cc_mock", "envoy_cc_test", "envoy_cc_test_binary", "envoy_cc_test_library")
load("//bazel:envoy_build_system.bzl", "envoy_benchmark_test", "envoy_cc_benchmark_binary", "envoy_cc_mock", "envoy_cc_test", "envoy_cc_test_binary", "envoy_cc_test_library", "envoy_py_test")
load("@envoy_build_config//:extensions_build_config.bzl", "EXTENSIONS")

def _apply_to_extension_allow_for_test(func, name, extension_name, **kwargs):
Expand Down Expand Up @@ -45,3 +45,10 @@ def envoy_extension_benchmark_test(
extension_name,
**kwargs):
_apply_to_extension_allow_for_test(envoy_benchmark_test, name, extension_name, **kwargs)

# Similar to envoy_cc_test, all extension py_tests should use this version of envoy_py_test
def envoy_extension_py_test(
name,
extension_name,
**kwargs):
_apply_to_extension_allow_for_test(envoy_py_test, name, extension_name, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ load(
"//bazel:envoy_build_system.bzl",
"envoy_package",
)
load("@rules_python//python:defs.bzl", "py_test")
load(
"//test/extensions:extensions_build_system.bzl",
"envoy_extension_py_test",
)
load("@kafka_pip3//:requirements.bzl", "requirement")

licenses(["notice"]) # Apache 2

envoy_package()

py_test(
envoy_extension_py_test(
name = "kafka_broker_integration_test",
srcs = [
"kafka_broker_integration_test.py",
Expand All @@ -20,6 +23,7 @@ py_test(
"//bazel:remote_jdk11",
"@kafka_server_binary//:all",
] + glob(["*.j2"]),
extension_name = "envoy.filters.network.kafka_broker",
flaky = True,
python_version = "PY3",
srcs_version = "PY3",
Expand Down