You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(feat) Local dev env: Tilt orchestrated data store initialization and connection coordinates propagation (#4101)
## Description
This PR uses Tilt+Docker Compose to start ancillary services required
for local e2e testing.
<img width="1833" height="1023" alt="image"
src="https://github.com/user-attachments/assets/310bd5ad-fcc2-4eac-bbbc-0cfba60c4d80"
/>
The idea is simple: Make tests read their input parameters from the same
source of truth that generated the dev environment.
The local `.env` file contains the ports, users and other parameters
used to fill in the docker compose template defining the services.
e.g:
```
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_ADMIN_USERNAME=admin
MONGO_ADMIN_PASSWORD=admin
MONGO_USERNAME=csuser
MONGO_PASSWORD=cspass
CLICKHOUSE_HOST=localhost
CLICKHOUSE_HTTP_PORT=8123
CLICKHOUSE_NATIVE_PORT=9000
PG_HOST=localhost
PG_PORT=5436
PG_USER=postgres
PG_PASSWORD=postgres
PG_DATABASE=postgres
```
## Notes for reviewers
- This PR version extracts versions from GH Workflow test flow. I think
we can re-use this infrastructure definition in the flow itself. If we
do that, we can just use a different way of defining the test matrix
images that works both locally and in CI without the need of brittle
extraction scripts. Alternatively we can just hard-code versions in the
local env too.
- The dev env adds an additional PSQL service to use as data source but
the existing e2e tests use the catalog PSQL instance. We can disable the
extra resource.
- Some PG tests fail because the catalog has not been provisioned
completely. (e.g: `env -f ../.env go test -v -run
TestGenericCH_PG/Test_Simple_Flow ./e2e/`) I am following up with a PR
in the tests to use the additional PSQL instance which is intended to be
a data source instead of the catalog.
## ~WIP~
- [x] Update README.md with instructions.
- [x] Add MySQL/MariaDB f6ef96d
- [x] Make provisioning scripts idempotent:
2d8a2cc
## Related work
Follows:
[#3901](#3901)
Replaces:
[#4095](#4095)
(same changes, moving source repository)
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: pfcoperez <273379+pfcoperez@users.noreply.github.com>
Co-authored-by: masterashu <ashutosh.chauhan@clickhouse.com>
Copy file name to clipboardExpand all lines: README.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,73 @@ You can use Postgres’ ecosystem to manage your ETL —
91
91
92
92
We have expanded our connector ecosystem to support multiple source connectors beyond Postgres, including MySQL and MongoDB. You can check the status of connectors [here](https://docs.peerdb.io/sql/commands/supported-connectors)
93
93
94
+
## Local End to End testing
95
+
96
+
You can run locally the same end-to-end tests that our CI uses to validate changes, enabling fast iteration cycles during development.
97
+
98
+
For example:
99
+
100
+
```bash
101
+
cd flow
102
+
go clean -cache
103
+
env -f ../.env go test -v -run TestGenericCH_MySQL ./e2e/
104
+
```
105
+
106
+
Or local debugging sessions.
107
+
108
+
These tests require both PeerDB services, source and destination stores to be running. We provide a local environment with all the necessary services and dependencies to run these tests.
109
+
110
+
This is done through [Tilt](https://tilt.dev/) orchestrated Docker compose.
111
+
112
+
To get the environment up you first need to specify the shared environment variables for both the test and the test environment in your local `.env` file. You can use the provided `.env.example` as a template: `cp .env.example .env `.
113
+
114
+
:memo: In the template, services URLs are set to `host.docker.internal`, which is the name for the default Docker gateway in Docker Desktop set-ups such as macOS and Windows. Using the default gateway address allows both test processes and services running inside Docker to access services on the host machine. In native Docker (Linux) this name is not resolved by default, you might replace it with the default gateway IP (e.g., `172.18.0.1`) or add a custom entry to your `/etc/hosts` file to resolve `host.docker.internal` to the appropriate IP address. e.g:
115
+
116
+
```bash
117
+
echo"172.18.0.1 host.docker.internal"| sudo tee -a /etc/hosts
118
+
```
119
+
120
+
Then you can just run:
121
+
122
+
```bash
123
+
./tilt.sh
124
+
```
125
+
126
+
And follow the status of the services and access logs through the Tilt UI at http://localhost:10352/. [Dozzle](https://dozzle.dev/) is also included at http://localhost:8118/, providing real-time container resource utilization metrics (CPU, memory) and log streaming for all running Docker containers.
Since `.env` is the environment configuration source of truth, it can be used directly to inject the required variables to the test execution processes. e.g:
131
+
132
+
```bash
133
+
go clean -cache; env -f ../.env go test -v -run TestGenericCH_MySQL ./e2e/ # Some MySQL generic tests
134
+
```
135
+
136
+
### Running tests from Tilt
137
+
138
+
The Tilt setup includes pre-configured test launcher resources under the `e2e` label. These resources do not start automatically; instead, you can trigger them on demand from the Tilt UI at http://localhost:10352/.
-**e2e_postgres** -- Postgres to ClickHouse generic tests (`TestGenericCH_PG`)
145
+
-**e2e_mysql** -- MySQL to ClickHouse generic tests (`TestGenericCH_MySQL`)
146
+
-**e2e_mongodb** -- MongoDB to ClickHouse test suite (`TestMongoClickhouseSuite`)
147
+
148
+
Each launcher automatically depends on the required services and provisioning steps, so Tilt will ensure all prerequisites are running before executing the tests. To trigger a test, click the resource in the Tilt UI and press the trigger (play) button.
149
+
150
+
### Environment services versions
151
+
152
+
Data stores versions are extracted from `.github/workflows/flow.yml`, select the last row of the test matrix except for MySQL version which defaults to `9.5`.
153
+
This automatic extraction relies on the `yq` CLI; install the Go-based [`mikefarah/yq`](https://github.com/mikefarah/yq) version 4 or later so that local environment generation works correctly.
154
+
You can specify different versions in the local `.env` file to override them as follows:
0 commit comments