consul/test/integration/connect/envoy
Ashesh Vidyut 47d445d680
Envoy Integration Test Windows (#18007)
* [CONSUL-395] Update check_hostport and Usage (#40)

* [CONSUL-397] Copy envoy binary from Image (#41)

* [CONSUL-382] Support openssl in unique test dockerfile (#43)

* [CONSUL-405] Add bats to single container (#44)

* [CONSUL-414] Run Prometheus Test Cases and Validate Changes (#46)

* [CONSUL-410] Run Jaeger in Single container (#45)

* [CONSUL-412] Run test-sds-server in single container (#48)

* [CONSUL-408] Clean containers (#47)

* [CONSUL-384] Rebase and sync fork (#50)

* [CONSUL-415] Create Scenarios Troubleshooting Docs (#49)

* [CONSUL-417] Update Docs Single Container (#51)

* [CONSUL-428] Add Socat to single container (#54)

* [CONSUL-424] Replace pkill in kill_envoy function (#52)

* [CONSUL-434] Modify Docker run functions in Helper script (#53)

* [CONSUL-435] Replace docker run in set_ttl_check_state & wait_for_agent_service_register functions (#55)

* [CONSUL-438] Add netcat (nc) in the Single container Dockerfile (#56)

* [CONSUL-429] Replace Docker run with Docker exec (#57)

* [CONSUL-436] Curl timeout and run tests (#58)

* [CONSUL-443] Create dogstatsd Function (#59)

* [CONSUL-431] Update Docs Netcat (#60)

* [CONSUL-439] Parse nc Command in function (#61)

* [CONSUL-463] Review curl Exec and get_ca_root Func (#63)

* [CONSUL-453] Docker hostname in Helper functions (#64)

* [CONSUL-461] Test wipe volumes without extra cont (#66)

* [CONSUL-454] Check ports in the Server and Agent containers (#65)

* [CONSUL-441] Update windows dockerfile with version (#62)

* [CONSUL-466] Review case-grpc Failing Test (#67)

* [CONSUL-494] Review case-cfg-resolver-svc-failover (#68)

* [CONSUL-496] Replace docker_wget & docker_curl (#69)

* [CONSUL-499] Cleanup Scripts - Remove nanoserver (#70)

* [CONSUL-500] Update Troubleshooting Docs (#72)

* [CONSUL-502] Pull & Tag Envoy Windows Image (#73)

* [CONSUL-504] Replace docker run in docker_consul (#76)

* [CONSUL-505] Change admin_bind

* [CONSUL-399] Update envoy to 1.23.1 (#78)

* [CONSUL-510] Support case-wanfed-gw on Windows (#79)

* [CONSUL-506] Update troubleshooting Documentation (#80)

* [CONSUL-512] Review debug_dump_volumes Function (#81)

* [CONSUL-514] Add zipkin to Docker Image (#82)

* [CONSUL-515] Update Documentation (#83)

* [CONSUL-529] Support case-consul-exec (#86)

* [CONSUL-530] Update Documentation (#87)

* [CONSUL-530] Update default consul version 1.13.3

* [CONSUL-539] Cleanup (#91)

* [CONSUL-546] Scripts Clean-up (#92)

* [CONSUL-491] Support admin_access_log_path value for Windows (#71)

* [CONSUL-519] Implement mkfifo Alternative (#84)

* [CONSUL-542] Create OS Specific Files for Envoy Package (#88)

* [CONSUL-543] Create exec_supported.go (#89)

* [CONSUL-544] Test and Build Changes (#90)

* Implement os.DevNull

* using mmap instead of disk files

* fix import in exec-unix

* fix nmap open too many arguemtn

* go fmt on file

* changelog file

* fix go mod

* Update .changelog/17694.txt

Co-authored-by: Dhia Ayachi <dhia@hashicorp.com>

* different mmap library

* fix bootstrap json

* some fixes

* chocolatey version fix and image fix

* using different library

* fix Map funciton call

* fix mmap call

* fix tcp dump

* fix tcp dump

* windows tcp dump

* Fix docker run

* fix tests

* fix go mod

* fix version 16.0

* fix version

* fix version dev

* sleep to debug

* fix sleep

* fix permission issue

* fix permission issue

* fix permission issue

* fix command

* fix command

* fix funciton

* fix assert config entry status command not found

* fix command not found assert_cert_has_cn

* fix command not found assert_upstream_missing

* fix command not found assert_upstream_missing_once

* fix command not found get_upstream_endpoint

* fix command not found get_envoy_public_listener_once

* fix command not found

* fix test cases

* windows integration test workflow github

* made code similar to unix using npipe

* fix go.mod

* fix dialing of npipe

* dont wait

* check size of written json

* fix undefined n

* running

* fix dep

* fix syntax error

* fix workflow file

* windows runner

* fix runner

* fix from json

* fix runs on

* merge connect envoy

* fix cin path

* build

* fix file name

* fix file name

* fix dev build

* remove unwanted code

* fix upload

* fix bin name

* fix path

* checkout current branch

* fix path

* fix tests

* fix shell bash for windows sh files

* fix permission of run-test.sh

* removed docker dev

* added shell bash for tests

* fix tag

* fix win=true

* fix cd

* added dev

* fix variable undefined

* removed failing tests

* fix tcp dump image

* fix curl

* fix curl

* tcp dump path

* fix tcpdump path

* fix curl

* fix curl install

* stop removing intermediate containers

* fix tcpdump docker image

* revert -rm

* --rm=false

* makeing docker image before

* fix tcpdump

* removed case consul exec

* removed terminating gateway simple

* comment case wasm

* removed data dog

* comment out upload coverage

* uncomment case-consul-exec

* comment case consul exec

* if always

* logs

* using consul 1.17.0

* fix quotes

* revert quotes

* redirect to dev null

* Revert version

* revert consul connect

* fix version

* removed envoy connect

* not using function

* change log

* docker logs

* fix logs

* restructure bad authz

* rmeoved dev null

* output

* fix file descriptor

* fix cacert

* fix cacert

* fix ca cert

* cacert does not work in windows curl

* fix func

* removed docker logs

* added sleep

* fix tls

* commented case-consul-exec

* removed echo

* retry docker consul

* fix upload bin

* uncomment consul exec

* copying consul.exe to docker image

* copy fix

* fix paths

* fix path

* github workspace path

* latest version

* Revert "latest version"

This reverts commit 5a7d7b82d9.

* commented consul exec

* added ssl revoke best effort

* revert best effort

* removed unused files

* rename var name and change dir

* windows runner

* permission

* needs setup fix

* swtich to github runner

* fix file path

* fix path

* fix path

* fix path

* fix path

* fix path

* fix build paths

* fix tag

* nightly runs

* added matrix in github workflow, renamed files

* fix job

* fix matrix

* removed brackes

* from json

* without using job matrix

* fix quotes

* revert job matrix

* fix workflow

* fix comment

* added comment

* nightly runs

* removed datadog ci as it is already measured in linux one

* running test

* Revert "running test"

This reverts commit 7013d15a23.

* pr comment fixes

* running test now

* running subset of test

* running subset of test

* job matrix

* shell bash

* removed bash shell

* linux machine for job matrix

* fix output

* added cat to debug

* using ubuntu latest

* fix job matrix

* fix win true

* fix go test

* revert job matrix

---------

Co-authored-by: Jose Ignacio Lorenzo <74208929+joselo85@users.noreply.github.com>
Co-authored-by: Franco Bruno Lavayen <cocolavayen@gmail.com>
Co-authored-by: Ivan K Berlot <ivanberlot@gmail.com>
Co-authored-by: Ezequiel Fernández Ponce <20102608+ezfepo@users.noreply.github.com>
Co-authored-by: joselo85 <joseignaciolorenzo85@gmail.com>
Co-authored-by: Ezequiel Fernández Ponce <ezequiel.fernandez@southworks.com>
Co-authored-by: Dhia Ayachi <dhia@hashicorp.com>
2023-07-21 20:26:00 +05:30
..
case-api-gateway-http-hostnames xds: generate endpoints directly from API gateway snapshot (#17390) 2023-05-19 18:50:59 +00:00
case-api-gateway-http-simple xds: generate endpoints directly from API gateway snapshot (#17390) 2023-05-19 18:50:59 +00:00
case-api-gateway-http-splitter-targets Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-api-gateway-http-tls-overlapping-hosts xds: generate endpoints directly from API gateway snapshot (#17390) 2023-05-19 18:50:59 +00:00
case-api-gateway-tcp-conflicted Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-api-gateway-tcp-simple xds: generate endpoints directly from API gateway snapshot (#17390) 2023-05-19 18:50:59 +00:00
case-api-gateway-tcp-tls-overlapping-hosts xds: generate endpoints directly from API gateway snapshot (#17390) 2023-05-19 18:50:59 +00:00
case-badauthz Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-basic Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-centralconf Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-cluster-peering-failover Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-dc-failover-gateways-none Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-dc-failover-gateways-remote Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-defaultsubset Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-features Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-subset-onlypassing Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-subset-redirect Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-svc-failover Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-svc-redirect-http Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-resolver-svc-redirect-tcp Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-router-features Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-splitter-cluster-peering Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-splitter-features Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cfg-splitter-peering-ingress-gateways Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-consul-exec Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cross-peer-control-plane-mgw Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cross-peers Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cross-peers-http Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cross-peers-http-router Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-cross-peers-resolver-redirect-tcp Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-dogstatsd-udp Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-expose-checks Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-gateway-without-services Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-gateways-local Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-gateways-remote Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-grpc Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-http Support Envoy's MaxEjectionPercent and BaseEjectionTime config entries for passive health checks (#15979) 2023-04-26 15:59:48 -07:00
case-http-badauthz Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-ingress-gateway-grpc Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-http Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-multiple-services Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-peering-failover Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-sds Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-simple Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-ingress-gateway-tls Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-ingress-mesh-gateways-resolver Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-l7-intentions Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-lua Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-mesh-to-lambda Wasm Envoy HTTP extension (#16877) 2023-04-06 14:12:07 -07:00
case-multidc-rsa-ca Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-prometheus Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-property-override Improve Prop Override docs examples (#17799) 2023-06-20 10:00:01 -04:00
case-stats-proxy Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-statsd-udp Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-terminating-gateway-hostnames Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-terminating-gateway-simple Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-terminating-gateway-subsets Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-terminating-gateway-without-services Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
case-upstream-config Support Envoy's MaxEjectionPercent and BaseEjectionTime config entries for passive health checks (#15979) 2023-04-26 15:59:48 -07:00
case-wanfed-gw Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
case-wasm [COMPLIANCE] Add Copyright and License Headers (#16854) 2023-04-20 12:40:22 +00:00
case-zipkin Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
consul-base-cfg Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
docs Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
test-sds-server Various bits of cleanup detected when using Go Workspaces (#17462) 2023-06-05 16:08:39 -04:00
.gitignore
Dockerfile-bats
Dockerfile-consul-envoy
Dockerfile-consul-envoy-windows Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
Dockerfile-tcpdump
Dockerfile-tcpdump-windows Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
Dockerfile-test-sds-server-windows Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
README.md
WINDOWS-TEST.md Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
defaults.sh Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
docker-windows.md Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
down.sh Copyright headers for missing files/folders (#16708) 2023-03-28 18:48:58 -04:00
helpers.bash Add Prop Override Envoy extension integration test (#17569) 2023-06-06 10:04:31 -04:00
helpers.windows.bash Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
main_test.go Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
run-tests.sh ci: remove test-integrations CircleCI workflow (#16928) 2023-04-19 16:19:29 +00:00
run-tests.windows.sh Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30
windows-troubleshooting.md Envoy Integration Test Windows (#18007) 2023-07-21 20:26:00 +05:30

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.