Skip to content

Add integration tests with Envoy. #110

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

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
Test: build against Envoy
Signed-off-by: mathetake <takeshi@tetrate.io>
  • Loading branch information
mathetake committed Nov 27, 2020
commit 3abc2417d51988748309f1f58123d63c5e1254b2
72 changes: 72 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,75 @@ cc_library(
"@wasm_c_api//:wasmtime_lib",
],
)

cc_library(
name = "common_lib",
srcs = glob([
"src/*.h",
"src/*.cc",
"src/common/*.h",
"src/common/*.cc",
"src/third_party/*.h",
"src/third_party/*.cc",
]),
deps = [
":include",
"//external:abseil_flat_hash_map",
"//external:abseil_optional",
"//external:abseil_strings",
"//external:protobuf",
"//external:ssl",
"//external:zlib",
"@proxy_wasm_cpp_sdk//:api_lib",
"@proxy_wasm_cpp_sdk//:common_lib",
],
)

cc_library(
name = "null_lib",
srcs = glob([
"src/null/*.cc",
]),
deps = [
":common_lib",
],
)

cc_library(
name = "v8_lib",
srcs = glob([
"src/v8/*.cc",
]),
deps = [
":common_lib",
"//external:wee8",
],
)

cc_library(
name = "wavm_lib",
srcs = glob([
"src/wavm/*.cc",
]),
copts = [
'-DWAVM_API=""',
"-Wno-non-virtual-dtor",
"-Wno-old-style-cast",
],
deps = [
":common_lib",
"@envoy//bazel/foreign_cc:wavm",
],
)

cc_library(
name = "wasmtime_lib",
srcs = glob([
"src/wasmtime/*.h",
"src/wasmtime/*.cc",
]),
deps = [
":common_lib",
"@com_github_wasm_c_api//:wasmtime_lib",
],
)
20 changes: 20 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ proxy_wasm_cpp_host_dependencies()
load("@proxy_wasm_cpp_host//bazel:dependencies_extra.bzl", proxy_wasm_cpp_host_dependencies_extra = "dependencies_extra")

proxy_wasm_cpp_host_dependencies_extra()

load("@envoy//bazel:api_binding.bzl", "envoy_api_binding")

envoy_api_binding()

load("@envoy//bazel:api_repositories.bzl", "envoy_api_dependencies")

envoy_api_dependencies()

load("@envoy//bazel:repositories.bzl", "envoy_dependencies")

envoy_dependencies()

load("@envoy//bazel:repositories_extra.bzl", "envoy_dependencies_extra")

envoy_dependencies_extra()

load("@envoy//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()
26 changes: 21 additions & 5 deletions bazel/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def dependencies():
def dependencies(name = ""):
_envoy_deps()
_http_archives()

def _http_archives():
Expand Down Expand Up @@ -57,10 +58,9 @@ def _http_archives():

http_archive(
name = "com_google_absl",
sha256 = "19391fb4882601a65cb648d638c11aa301ce5f525ef02da1a9eafd22f72d7c59",
strip_prefix = "abseil-cpp-37dd2562ec830d547a1524bb306be313ac3f2556",
# 2020-01-29
urls = ["https://github.com/abseil/abseil-cpp/archive/37dd2562ec830d547a1524bb306be313ac3f2556.tar.gz"],
sha256 = "e3812f256dd7347a33bf9d93a950cf356c61c0596842ff07d8154cd415145d83",
strip_prefix = "abseil-cpp-5d8fc9192245f0ea67094af57399d7931d6bd53f",
urls = ["https://github.com/abseil/abseil-cpp/archive/5d8fc9192245f0ea67094af57399d7931d6bd53f.tar.gz"],
)

http_archive(
Expand All @@ -84,4 +84,20 @@ def _http_archives():
sha256 = "59621f4011a95df270748dcc0ec1cc51946473f0e140d4848a2f20c8719e43aa",
strip_prefix = "protobuf-655310ca192a6e3a050e0ca0b7084a2968072260",
url = "https://github.com/protocolbuffers/protobuf/archive/655310ca192a6e3a050e0ca0b7084a2968072260.tar.gz",
patches = ["@envoy//bazel:protobuf.patch"],
patch_args = ["-p1"],
)

def _envoy_deps():
native.new_local_repository(
name = "envoy_build_config",
path = "bazel/external/envoy",
build_file_content = "",
)

http_archive(
name = "envoy",
sha256 = "910ef0c163a0b9ff34506a6c787de7239d8f57c558ef8db92b3c71d15fc3a281",
strip_prefix = "envoy-0f7952d1850be92620f2add304c8d95fce028f93",
url = "https://github.com/envoyproxy/envoy/archive/0f7952d1850be92620f2add304c8d95fce028f93.tar.gz",
)
154 changes: 154 additions & 0 deletions bazel/external/envoy/extensions_build_config.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# See bazel/README.md for details on how this system works.
EXTENSIONS = {
#
# Access loggers
#
"envoy.access_loggers.file": "//source/extensions/access_loggers/file:config",
"envoy.access_loggers.wasm": "//source/extensions/access_loggers/wasm:config",

#
# WASM
#
"envoy.bootstrap.wasm": "//source/extensions/bootstrap/wasm:config",

#
# HTTP filters
#
"envoy.filters.http.router": "//source/extensions/filters/http/router:config",
"envoy.filters.http.wasm": "//source/extensions/filters/http/wasm:config",

#
# Listener filters
#
"envoy.filters.listener.http_inspector": "//source/extensions/filters/listener/http_inspector:config",
# NOTE: The original_dst filter is implicitly loaded if original_dst functionality is
# configured on the listener. Do not remove it in that case or configs will fail to load.
"envoy.filters.listener.original_dst": "//source/extensions/filters/listener/original_dst:config",
"envoy.filters.listener.original_src": "//source/extensions/filters/listener/original_src:config",
# NOTE: The proxy_protocol filter is implicitly loaded if proxy_protocol functionality is
# configured on the listener. Do not remove it in that case or configs will fail to load.
"envoy.filters.listener.proxy_protocol": "//source/extensions/filters/listener/proxy_protocol:config",
"envoy.filters.listener.tls_inspector": "//source/extensions/filters/listener/tls_inspector:config",

#
# Network filters
#
"envoy.filters.network.client_ssl_auth": "//source/extensions/filters/network/client_ssl_auth:config",
"envoy.filters.network.direct_response": "//source/extensions/filters/network/direct_response:config",
"envoy.filters.network.dubbo_proxy": "//source/extensions/filters/network/dubbo_proxy:config",
"envoy.filters.network.echo": "//source/extensions/filters/network/echo:config",
"envoy.filters.network.ext_authz": "//source/extensions/filters/network/ext_authz:config",
"envoy.filters.network.http_connection_manager": "//source/extensions/filters/network/http_connection_manager:config",
# WiP
"envoy.filters.network.kafka_broker": "//source/extensions/filters/network/kafka:kafka_broker_config_lib",
"envoy.filters.network.local_ratelimit": "//source/extensions/filters/network/local_ratelimit:config",
"envoy.filters.network.mongo_proxy": "//source/extensions/filters/network/mongo_proxy:config",
"envoy.filters.network.mysql_proxy": "//source/extensions/filters/network/mysql_proxy:config",
"envoy.filters.network.postgres_proxy": "//source/extensions/filters/network/postgres_proxy:config",
"envoy.filters.network.ratelimit": "//source/extensions/filters/network/ratelimit:config",
"envoy.filters.network.rbac": "//source/extensions/filters/network/rbac:config",
"envoy.filters.network.redis_proxy": "//source/extensions/filters/network/redis_proxy:config",
"envoy.filters.network.rocketmq_proxy": "//source/extensions/filters/network/rocketmq_proxy:config",
"envoy.filters.network.tcp_proxy": "//source/extensions/filters/network/tcp_proxy:config",
"envoy.filters.network.thrift_proxy": "//source/extensions/filters/network/thrift_proxy:config",
"envoy.filters.network.sni_cluster": "//source/extensions/filters/network/sni_cluster:config",
"envoy.filters.network.sni_dynamic_forward_proxy": "//source/extensions/filters/network/sni_dynamic_forward_proxy:config",
"envoy.filters.network.wasm": "//source/extensions/filters/network/wasm:config",
"envoy.filters.network.zookeeper_proxy": "//source/extensions/filters/network/zookeeper_proxy:config",

#
# UDP filters
#
"envoy.filters.udp_listener.dns_filter": "//source/extensions/filters/udp/dns_filter:config",
"envoy.filters.udp_listener.udp_proxy": "//source/extensions/filters/udp/udp_proxy:config",

#
# Resource monitors
#
"envoy.resource_monitors.fixed_heap": "//source/extensions/resource_monitors/fixed_heap:config",
"envoy.resource_monitors.injected_resource": "//source/extensions/resource_monitors/injected_resource:config",

#
# Stat sinks
#
"envoy.stat_sinks.dog_statsd": "//source/extensions/stat_sinks/dog_statsd:config",
"envoy.stat_sinks.hystrix": "//source/extensions/stat_sinks/hystrix:config",
"envoy.stat_sinks.metrics_service": "//source/extensions/stat_sinks/metrics_service:config",
"envoy.stat_sinks.statsd": "//source/extensions/stat_sinks/statsd:config",
"envoy.stat_sinks.wasm": "//source/extensions/stat_sinks/wasm:config",

#
# Thrift filters
#
"envoy.filters.thrift.router": "//source/extensions/filters/network/thrift_proxy/router:config",
"envoy.filters.thrift.ratelimit": "//source/extensions/filters/network/thrift_proxy/filters/ratelimit:config",

#
# Tracers
#
"envoy.tracers.dynamic_ot": "//source/extensions/tracers/dynamic_ot:config",
"envoy.tracers.lightstep": "//source/extensions/tracers/lightstep:config",
"envoy.tracers.datadog": "//source/extensions/tracers/datadog:config",
"envoy.tracers.zipkin": "//source/extensions/tracers/zipkin:config",
"envoy.tracers.opencensus": "//source/extensions/tracers/opencensus:config",
# WiP
"envoy.tracers.xray": "//source/extensions/tracers/xray:config",
"envoy.tracers.skywalking": "//source/extensions/tracers/skywalking:config",

#
# Transport sockets
#
"envoy.transport_sockets.alts": "//source/extensions/transport_sockets/alts:config",
"envoy.transport_sockets.upstream_proxy_protocol": "//source/extensions/transport_sockets/proxy_protocol:upstream_config",
"envoy.transport_sockets.raw_buffer": "//source/extensions/transport_sockets/raw_buffer:config",
"envoy.transport_sockets.tap": "//source/extensions/transport_sockets/tap:config",
"envoy.transport_sockets.quic": "//source/extensions/quic_listeners/quiche:quic_factory_lib",

#
# Retry host predicates
#
"envoy.retry_host_predicates.previous_hosts": "//source/extensions/retry/host/previous_hosts:config",
"envoy.retry_host_predicates.omit_canary_hosts": "//source/extensions/retry/host/omit_canary_hosts:config",
"envoy.retry_host_predicates.omit_host_metadata": "//source/extensions/retry/host/omit_host_metadata:config",

#
# Retry priorities
#
"envoy.retry_priorities.previous_priorities": "//source/extensions/retry/priority/previous_priorities:config",

#
# CacheFilter plugins
#
"envoy.filters.http.cache.simple_http_cache": "//source/extensions/filters/http/cache/simple_http_cache:simple_http_cache_lib",

#
# Internal redirect predicates
#
"envoy.internal_redirect_predicates.allow_listed_routes": "//source/extensions/internal_redirect/allow_listed_routes:config",
"envoy.internal_redirect_predicates.previous_routes": "//source/extensions/internal_redirect/previous_routes:config",
"envoy.internal_redirect_predicates.safe_cross_scheme": "//source/extensions/internal_redirect/safe_cross_scheme:config",

#
# Http Upstreams (excepting envoy.upstreams.http.generic which is hard-coded into the build so not registered here)
#
"envoy.upstreams.http.http": "//source/extensions/upstreams/http/http:config",
"envoy.upstreams.http.tcp": "//source/extensions/upstreams/http/tcp:config",

#
# Watchdog actions
#
"envoy.watchdog.profile_action": "//source/extensions/watchdog/profile_action:config",

#
# WebAssembly runtimes
#
"envoy.wasm.runtime.null": "//source/extensions/wasm_runtime/null:config",
"envoy.wasm.runtime.v8": "//source/extensions/wasm_runtime/v8:config",
"envoy.wasm.runtime.wavm": "//source/extensions/wasm_runtime/wavm:config",
"envoy.wasm.runtime.wasmtime": "//source/extensions/wasm_runtime/wasmtime:config",
}

# These can be changed to ["//visibility:public"], for downstream builds which
# need to directly reference Envoy extensions.
EXTENSION_CONFIG_VISIBILITY = ["//:extension_config"]
EXTENSION_PACKAGE_VISIBILITY = ["//:extension_library"]
42 changes: 42 additions & 0 deletions bazel/get_workspace_status
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# This file was imported from https://github.com/bazelbuild/bazel at d6fec93.

# This script will be run bazel when building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with non-zero code, it's considered as a failure
# and the output will be discarded.

# For Envoy in particular, we want to force binaries to relink when the Git
# SHA changes (https://github.com/envoyproxy/envoy/issues/2551). This can be
# done by prefixing keys with "STABLE_". To avoid breaking compatibility with
# other status scripts, this one still echos the non-stable ("volatile") names.

# If this SOURCE_VERSION file exists then it must have been placed here by a
# distribution doing a non-git, source build.
# Distributions would be expected to echo the commit/tag as BUILD_SCM_REVISION
if [ -f SOURCE_VERSION ]
then
echo "BUILD_SCM_REVISION $(cat SOURCE_VERSION)"
echo "STABLE_BUILD_SCM_REVISION $(cat SOURCE_VERSION)"
echo "BUILD_SCM_STATUS Distribution"
exit 0
fi

# The code below presents an implementation that works for git repository
git_rev=$(git rev-parse HEAD) || exit 1
echo "BUILD_SCM_REVISION ${git_rev}"
echo "STABLE_BUILD_SCM_REVISION ${git_rev}"

# Check whether there are any uncommitted changes
tree_status="Clean"
git diff-index --quiet HEAD -- || {
tree_status="Modified"
}
echo "BUILD_SCM_STATUS ${tree_status}"
echo "STABLE_BUILD_SCM_STATUS ${tree_status}"
12 changes: 12 additions & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load(
"@envoy//bazel:envoy_build_system.bzl",
"envoy_cc_binary",
)

envoy_cc_binary(
name = "envoy",
repository = "@envoy",
deps = [
"@envoy//source/exe:envoy_main_entry_lib",
],
)