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
Closed
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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build --copt=-fPIC
build --cxxopt=-std=c++17
build --conlyopt=-fexceptions
build --fission=dbg,opt
build --features=per_object_debug_info
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.6.0
20 changes: 19 additions & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,22 @@ jobs:

- name: Test
run: |
"${GITHUB_WORKSPACE}/bin/bazel" test //...
"${GITHUB_WORKSPACE}/bin/bazel" test //test/...

integration-test-envoy:
runs-on: ubuntu-latest
container:
image: gcr.io/envoy-ci/envoy-build:19a268cfe3d12625380e7c61d2467c8779b58b56
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/.cache/bazel
# TODO: find better keys
# ${ENVOY_HASH}-YYYY-MM-DD
key: 0f7952d1850be92620f2add304c8d95fce028f93-2020-11-27

- name: Test
run: |
"bazel" test //integration_test/envoy/... --define wasm=wasmtime --verbose_failures
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this supposed to test? It doesn't interact with changes in this repository, it simply runs Envoy tests.

Copy link
Contributor Author

@mathetake mathetake Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now it's just simply building envoy with the HEAD of this repo. I was thinking about writing e2e test as in istio/proxy https://github.com/istio/proxy/tree/master/test/envoye2e, or run envoy's integration test directly. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, overriding proxy_wasm_cpp_host works, and you could use the existing Wasm unit tests in Envoy, but that results in a circular dependency, where you cannot commit any changes to this repo that also require changes in Envoy upstream, because it would break this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that's true. So We should have our own test plugins and e2e tests in this repository rather than depending on integration tests in Envoy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, in any case, we cannot avoid changing the Envoy location in this repo to folk Envoy repositories if we want to make any breaking change just like as we do in "opening a PR in Envoy to run unit tests" 😞

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not so much about our own test plugins and e2e tests, as it's about a lot of real non-cleanup changes requiring changes in both repositories, which would always fail this test.

We could potentially mark it as an optional CI target, but then we might get in a habit of always ignoring it, so I'm not sure how much value it would really provide vs being always false negative.

Copy link
Contributor Author

@mathetake mathetake Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lizan I would like to have your thoughts on this PR. As you know that cpp-host is tightly coupled with Envoy right now, we have to open PR in Envoy corresponding to almost every PRs in this repository to ensure that all the unittest passes, which is a little bit time consuming and complicated process. What's more, sometimes istio/proxy's e2e test(https://github.com/istio/proxy/tree/master/test/envoye2e) fails(?) even after the Envoy's unit test passes.

That's why I initially thought that building Envoy and running e2e tests in this repository would be great for us as host implementation developers. But as Piotr said, the cycle dependency seems problematic and I really agree with that point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially mark it as an optional CI target, but then we might get in a habit of always ignoring it, so I'm not sure how much value it would really provide vs being always false negative.

I don't have a real good answer for this. I would agree this is the way to go. The real question is how many changes also requires Envoy change. So we can try optional CI target and if that doesn't work just delete it later?

48 changes: 47 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//:bazel/variables.bzl", "COPTS", "LINKOPTS")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@proxy_wasm_cpp_host//bazel:variables.bzl", "COPTS")

licenses(["notice"]) # Apache 2

Expand Down Expand Up @@ -36,3 +37,48 @@ 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 = "wasmtime_lib",
srcs = glob([
"src/wasmtime/*.h",
"src/wasmtime/*.cc",
]),
deps = [
":common_lib",
"@com_github_wasm_c_api//:wasmtime_lib",
],
)
88 changes: 14 additions & 74 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,89 +1,29 @@
workspace(name = "proxy_wasm_cpp_host")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@proxy_wasm_cpp_host//bazel:dependencies.bzl", proxy_wasm_cpp_host_dependencies = "dependencies")

git_repository(
name = "proxy_wasm_cpp_sdk",
commit = "1b5f69ce1535b0c21f88c4af4ebf0ec51d255abe",
remote = "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk",
)
proxy_wasm_cpp_host_dependencies()

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"],
)
load("@proxy_wasm_cpp_host//bazel:dependencies_extra.bzl", proxy_wasm_cpp_host_dependencies_extra = "dependencies_extra")

# required by com_google_protobuf
http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)
proxy_wasm_cpp_host_dependencies_extra()

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

bazel_skylib_workspace()
envoy_api_binding()

# rust rules
http_archive(
name = "io_bazel_rules_rust",
sha256 = "7401878bf966325bbec5224eeb4ff7e8762681070b401acaa168da68d383563a",
strip_prefix = "rules_rust-9741a32e50a8c50c504c0931111bb6048d6d6888",
url = "https://github.com/bazelbuild/rules_rust/archive/9741a32e50a8c50c504c0931111bb6048d6d6888.tar.gz",
)
load("@envoy//bazel:api_repositories.bzl", "envoy_api_dependencies")

load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
envoy_api_dependencies()

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

load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")
envoy_dependencies()

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

load("//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_raze__fetch_remote_crates")
envoy_dependencies_extra()

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

git_repository(
name = "com_google_protobuf",
commit = "655310ca192a6e3a050e0ca0b7084a2968072260",
remote = "https://github.com/protocolbuffers/protobuf",
shallow_since = "1565024848 -0700",
)

http_archive(
name = "boringssl",
sha256 = "bb55b0ed2f0cb548b5dce6a6b8307ce37f7f748eb9f1be6bfe2d266ff2b4d52b",
strip_prefix = "boringssl-2192bbc878822cf6ab5977d4257a1339453d9d39",
urls = ["https://github.com/google/boringssl/archive/2192bbc878822cf6ab5977d4257a1339453d9d39.tar.gz"],
)

http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
)

http_archive(
name = "wasmtime",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmtime.BUILD",
sha256 = "7874feb1026bbef06796bd5ab80e73f15b8e83752bde8dc93994f5bc039a4952",
strip_prefix = "wasmtime-0.21.0",
url = "https://github.com/bytecodealliance/wasmtime/archive/v0.21.0.tar.gz",
)

http_archive(
name = "wasm_c_api",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
sha256 = "aea8cd095e9937f1e14f2c93e026317b197eb2345e7a817fe3932062eb7b792c",
strip_prefix = "wasm-c-api-d9a80099d496b5cdba6f3fe8fc77586e0e505ddc",
url = "https://github.com/WebAssembly/wasm-c-api/archive/d9a80099d496b5cdba6f3fe8fc77586e0e505ddc.tar.gz",
)
envoy_dependency_imports()
Empty file added bazel/BUILD
Empty file.
110 changes: 110 additions & 0 deletions bazel/dependencies.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

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

def _http_archives():
http_archive(
name = "rules_cc",
sha256 = "9d48151ea71b3e225adfb6867e6d2c7d0dce46cbdc8710d9a9a628574dfd40a0",
strip_prefix = "rules_cc-818289e5613731ae410efb54218a4077fb9dbb03",
urls = ["https://github.com/bazelbuild/rules_cc/archive/818289e5613731ae410efb54218a4077fb9dbb03.tar.gz"],
)

http_archive(
name = "proxy_wasm_cpp_sdk",
sha256 = "b97e3e716b1f38dc601487aa0bde72490bbc82b8f3ad73f1f3e69733984955df",
strip_prefix = "proxy-wasm-cpp-sdk-956f0d500c380cc1656a2d861b7ee12c2515a664",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/956f0d500c380cc1656a2d861b7ee12c2515a664.tar.gz"],
)

http_archive(
name = "boringssl",
sha256 = "bb55b0ed2f0cb548b5dce6a6b8307ce37f7f748eb9f1be6bfe2d266ff2b4d52b",
strip_prefix = "boringssl-2192bbc878822cf6ab5977d4257a1339453d9d39",
urls = ["https://github.com/google/boringssl/archive/2192bbc878822cf6ab5977d4257a1339453d9d39.tar.gz"],
)

http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
)

http_archive(
name = "wasmtime",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmtime.BUILD",
sha256 = "7874feb1026bbef06796bd5ab80e73f15b8e83752bde8dc93994f5bc039a4952",
strip_prefix = "wasmtime-0.21.0",
url = "https://github.com/bytecodealliance/wasmtime/archive/v0.21.0.tar.gz",
)

http_archive(
name = "wasm_c_api",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
sha256 = "aea8cd095e9937f1e14f2c93e026317b197eb2345e7a817fe3932062eb7b792c",
strip_prefix = "wasm-c-api-d9a80099d496b5cdba6f3fe8fc77586e0e505ddc",
url = "https://github.com/WebAssembly/wasm-c-api/archive/d9a80099d496b5cdba6f3fe8fc77586e0e505ddc.tar.gz",
)

http_archive(
name = "com_google_absl",
sha256 = "e3812f256dd7347a33bf9d93a950cf356c61c0596842ff07d8154cd415145d83",
strip_prefix = "abseil-cpp-5d8fc9192245f0ea67094af57399d7931d6bd53f",
urls = ["https://github.com/abseil/abseil-cpp/archive/5d8fc9192245f0ea67094af57399d7931d6bd53f.tar.gz"],
)

http_archive(
name = "io_bazel_rules_rust",
sha256 = "7401878bf966325bbec5224eeb4ff7e8762681070b401acaa168da68d383563a",
strip_prefix = "rules_rust-9741a32e50a8c50c504c0931111bb6048d6d6888",
url = "https://github.com/bazelbuild/rules_rust/archive/9741a32e50a8c50c504c0931111bb6048d6d6888.tar.gz",
)

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)

http_archive(
name = "com_google_protobuf",
sha256 = "465fd9367992a9b9c4fba34a549773735da200903678b81b25f367982e8df376",
strip_prefix = "protobuf-3.13.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.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",
)
24 changes: 24 additions & 0 deletions bazel/dependencies_extra.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_raze__fetch_remote_crates")

def dependencies_extra():
bazel_skylib_workspace()
rust_repositories()
rust_workspace()
proxy_wasm_cpp_host_raze__fetch_remote_crates()
31 changes: 31 additions & 0 deletions bazel/external/envoy/extensions_build_config.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

EXTENSIONS = {
"envoy.access_loggers.wasm": "//source/extensions/access_loggers/wasm:config",
"envoy.bootstrap.wasm": "//source/extensions/bootstrap/wasm:config",
"envoy.filters.http.router": "//source/extensions/filters/http/router:config",
"envoy.filters.http.wasm": "//source/extensions/filters/http/wasm:config",
"envoy.filters.network.http_connection_manager": "//source/extensions/filters/network/http_connection_manager:config",
"envoy.filters.network.tcp_proxy": "//source/extensions/filters/network/tcp_proxy:config",
"envoy.filters.network.wasm": "//source/extensions/filters/network/wasm:config",
"envoy.stat_sinks.wasm": "//source/extensions/stat_sinks/wasm:config",
"envoy.wasm.runtime.null": "//source/extensions/wasm_runtime/null: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"]
File renamed without changes.
23 changes: 23 additions & 0 deletions integration_test/envoy/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
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",
],
)

cc_test(
name = "tmp_test",
srcs = ["tmp.cc"],
deps = [
":envoy",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
14 changes: 14 additions & 0 deletions integration_test/envoy/tmp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2016-2019 Envoy Project Authors
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Loading