From 754c4ce3a906d0b86df6800439cad86ce5ec0462 Mon Sep 17 00:00:00 2001 From: Zufar Dhiyaulhaq Date: Mon, 17 Apr 2023 13:13:07 +0700 Subject: [PATCH] feat: add ReloadExample to easily reload the example when testing WASM (#173) Signed-off-by: zufardhiyaulhaq --- README.md | 2 +- magefiles/magefile.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fc69bd6f90b00..bdb3f2bc6f43b 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ FTW_INCLUDE=920410 go run mage.go ftw ## Example: Spinning up the coraza-wasm-filter for manual tests -Once the filter is built, via the commands `mage runExample` and `mage teardownExample` you can spin up and tear down the test environment. Envoy with the coraza-wasm filter will be reachable at `localhost:8080`. The filter is configured with the CRS loaded working in Anomaly Scoring mode. For details and locally tweaking the configuration refer to [@demo-conf](./wasmplugin/rules/coraza-demo.conf) and [@crs-setup-demo-conf](./wasmplugin/rules/crs-setup-demo.conf). +Once the filter is built, via the commands `mage runExample`, `mage reloadExample`, and `mage teardownExample` you can spin up, test, and tear down the test environment. Envoy with the coraza-wasm filter will be reachable at `localhost:8080`. The filter is configured with the CRS loaded working in Anomaly Scoring mode. For details and locally tweaking the configuration refer to [@demo-conf](./wasmplugin/rules/coraza-demo.conf) and [@crs-setup-demo-conf](./wasmplugin/rules/crs-setup-demo.conf). In order to monitor envoy logs while performing requests you can run: - Envoy logs: `docker-compose -f ./example/docker-compose.yml logs -f envoy-logs`. diff --git a/magefiles/magefile.go b/magefiles/magefile.go index 195a8c78d57c9..2b8c37c6cbc79 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -233,6 +233,11 @@ func TeardownExample() error { return sh.RunV("docker-compose", "--file", "example/docker-compose.yml", "down") } +// ReloadExample reload the test environment (container) in case of envoy or wasm update. Requires docker-compose +func ReloadExample() error { + return sh.RunV("docker-compose", "--file", "example/docker-compose.yml", "restart") +} + var Default = Build func patchWasm(inPath, outPath string, initialPages int) error {