consul/test/integration/connect/envoy
John Murret ee82e1d01e
ci: remove test-integrations CircleCI workflow (#16928) (#17049)
* remove all CircleCI files

* remove references to CircleCI

* remove more references to CircleCI

* pin golangci-lint to v1.51.1 instead of v1.51
2023-04-19 11:28:59 -06:00
..
case-api-gateway-http-hostnames Fix hostname alignment checks for HTTPRoutes (#16315) 2023-02-17 20:47:38 +00:00
case-api-gateway-http-simple NET-2904 Fixes API Gateway Route Service Weight Division Error (#16540) 2023-03-06 10:11:27 -05:00
case-api-gateway-http-splitter-targets Backport of [API Gateway] Fix targeting service splitters in HTTPRoutes into release/1.15.x (#16353) 2023-02-22 04:34:39 +00:00
case-api-gateway-http-tls-overlapping-hosts Backport of Inline API Gateway TLS cert code into release/1.15.x (#16306) 2023-02-17 14:46:49 -05:00
case-api-gateway-tcp-conflicted Backport of [API Gateway] Validate listener name is not empty into release/1.15.x (#16341) 2023-02-21 19:34:04 +00:00
case-api-gateway-tcp-simple [API Gateway] Update simple test to leverage intentions and multiple listeners (#16228) 2023-02-10 21:13:44 +00:00
case-api-gateway-tcp-tls-overlapping-hosts Backport of Inline API Gateway TLS cert code into release/1.15.x (#16306) 2023-02-17 14:46:49 -05:00
case-badauthz flaky test: use retry long to wait for config entry upgrade (#16068) 2023-01-26 11:01:17 -05:00
case-basic
case-centralconf test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-cluster-peering-failover Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-cfg-resolver-dc-failover-gateways-none test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-dc-failover-gateways-remote test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-defaultsubset test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-features test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-subset-onlypassing test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-subset-redirect test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-svc-failover test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-svc-redirect-http test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-resolver-svc-redirect-tcp test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-router-features test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-splitter-cluster-peering Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-cfg-splitter-features test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-cfg-splitter-peering-ingress-gateways Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-consul-exec
case-cross-peer-control-plane-mgw Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-cross-peers Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-cross-peers-http Add the Lua Envoy extension (#15906) 2023-01-06 12:13:40 -05:00
case-cross-peers-http-router Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-cross-peers-resolver-redirect-tcp Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-dogstatsd-udp integ test: fix retry upstream test (#16246) 2023-02-13 15:16:56 -05:00
case-expose-checks
case-gateway-without-services
case-gateways-local
case-gateways-remote
case-grpc
case-http Add the Lua Envoy extension (#15906) 2023-01-06 12:13:40 -05:00
case-http-badauthz
case-ingress-gateway-grpc test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-ingress-gateway-http feat(ingress-gateway): support outlier detection of upstream service for ingress gateway (#15614) 2022-12-13 11:51:37 -05:00
case-ingress-gateway-multiple-services feat(ingress-gateway): support outlier detection of upstream service for ingress gateway (#15614) 2022-12-13 11:51:37 -05:00
case-ingress-gateway-peering-failover Flakiness test: case-cfg-splitter-peering-ingress-gateways (#15707) 2022-12-07 20:19:34 -05:00
case-ingress-gateway-sds test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-ingress-gateway-simple feat(ingress-gateway): support outlier detection of upstream service for ingress gateway (#15614) 2022-12-13 11:51:37 -05:00
case-ingress-gateway-tls test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-ingress-mesh-gateways-resolver test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-l7-intentions test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-lua improvement: prevent filter being added twice from any enovy extension (#16112) 2023-01-31 16:49:45 +00:00
case-mesh-to-lambda extensions: refactor serverless plugin to use extensions from config entry fields (#15817) 2022-12-19 12:19:37 -08:00
case-multidc-rsa-ca
case-prometheus
case-stats-proxy
case-statsd-udp integ test: fix retry upstream test (#16246) 2023-02-13 15:16:56 -05:00
case-terminating-gateway-hostnames test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-terminating-gateway-simple test: fix envoy integration tests to explicitly create config entries (#15269) 2022-11-07 10:02:04 -06:00
case-terminating-gateway-subsets Backport of Fix resolution of service resolvers with subsets for external upstreams into release/1.15.x (#16525) 2023-03-03 19:44:50 +00:00
case-terminating-gateway-without-services
case-upstream-config feat(ingress-gateway): support outlier detection of upstream service for ingress gateway (#15614) 2022-12-13 11:51:37 -05:00
case-wanfed-gw
case-zipkin integ test: fix retry upstream test (#16246) 2023-02-13 15:16:56 -05:00
consul-base-cfg Remove unnecessary default test config. (#15361) 2022-11-14 14:07:42 -06:00
test-sds-server removes ioutil usage everywhere which was deprecated in go1.16 (#15297) 2022-11-10 10:26:01 -06:00
.gitignore
Dockerfile-bats
Dockerfile-consul-envoy
Dockerfile-tcpdump backport of commit a0598b81a3 (#16363) 2023-02-22 16:51:54 +00:00
Dockerfile-test-sds-server
README.md
defaults.sh
down.sh
helpers.bash Backport of Fix resolution of service resolvers with subsets for external upstreams into release/1.15.x (#16525) 2023-03-03 19:44:50 +00:00
main_test.go removes ioutil usage everywhere which was deprecated in go1.16 (#15297) 2022-11-10 10:26:01 -06:00
run-tests.sh ci: remove test-integrations CircleCI workflow (#16928) (#17049) 2023-04-19 11:28:59 -06:00

README.md

Envoy Integration Tests

Overview

These tests validate that Consul is configuring Envoy correctly. They set up various scenarios using Docker containers and then run Bats (a Bash test framework) tests to validate the expected results.

Running Tests

To run the tests locally, cd into the root of the repo and run:

make test-envoy-integ

To run a specific test, run:

make test-envoy-integ GO_TEST_FLAGS="-run TestEnvoy/case-basic"

Where case-basic can be replaced by any directory name from this directory.

How Do These Tests Work

  1. The tests are all run through Go test via the main_test.go file. Each directory prefixed by case- is a subtest, for example, TestEnvoy/case-basic and TestEnvoy/case-wanfed-gw.
  2. The real framework for this test suite lives in run-tests.sh. Under the hood, main_test.go just runs run-tests.sh with various arguments.
  3. The tests use your local code by building a Docker image from your local directory just before executing. Note: this is implemented as the docker-envoy-integ Makefile target which is a prerequisite to the test-envoy-integ target, so if you are running the tests by invoking run-tests.sh or go test manually, be sure to rebuild the Docker image to ensure you are running your latest code.
  4. The tests run Docker containers connected by a shared Docker network. All tests have at least one Consul server running and then depending on the test case they will spin up additional services or gateways. Some tests run multiple Consul servers to test multi-DC setups. See the case-wanfed-gateway test for an example of this.
  5. At a high level, tests are set up by executing the setup.sh script in each directory. This script uses helper functions defined in helpers.bash. Once the test case is set up, the validations in verify.bats are run.
  6. If there exists a vars.sh file in the top-level of the case directory, the test runner will source it prior to invoking the run_tests, test_teardown and capture_logs phases of the test scenario.
  7. If there exists a capture.sh file in the top-level of the case directory, it will be executed after the test is done, but prior to the containers being removed. This is useful for capturing logs or Envoy snapshots for debugging test failures.
  8. Any files matching the *.hcl glob will be copied to the container $WORKDIR/$CLUSTER/consul directory prior to running the tests. This is useful for defining Consul configuration for each agent process to load on start up.
  9. In CI, the tests are executed against different Envoy versions and with both XDS_TARGET=client and XDS_TARGET=server. If set to client, a Consul server and client are run, and services are registered against the client. If set to server, only a Consul server is run, and services are registered against the server. By default, XDS_TARGET is set to server. See this comment for more information.

Investigating Test Failures

  • When tests fail in CI, logs and additional debugging data are available in the artifacts of the test run.
  • You can re-run the tests locally by running make test-envoy-integ GO_TEST_FLAGS="-run TestEnvoy/<case-directory>" where <case-directory> is replaced with the name of the directory, e.g. case-basic.
  • Locally, all the logs of the failed test will be available in workdir in this directory.
  • You can run with DEBUG=1 to print out all the commands being run, e.g. DEBUG=1 make test-envoy-integ GO_TEST_FLAGS="-run TestEnvoy/case-basic".
  • If you want to prevent the Docker containers from being spun down after test failure, add a sleep 9999 to the verify.bats test case that's failing.

Creating a New Test

Below is a rough outline for creating a new test. For the example, assume our test case will be called my-feature.

  1. Create a new directory named case-my-feature
  2. If the test involves multiple datacenters/clusters, create a separate subdirectory for each cluster (eg. case-my-feature/{dc1,dc2})
  3. Add any necessary configuration to *.hcl files in the respective cluster subdirectory (or the test case directory when using a single cluster).
  4. Create a setup.sh file in the case directory
  5. Create a capture.sh file in the case directory
  6. Create a verify.bats file in the case directory
  7. Populate the setup.sh, capture.sh and verify.bats files with the appropriate code for running your test, validating its state and capturing any logs or snapshots.