-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[proxy/docs]imprv: Add local testing section to proxy README
Add commands to run proxy locally with mocked control plane.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,3 +122,43 @@ and connect to it | |
```sh | ||
PGSSLROOTCERT=./server.crt psql 'postgres://my-cluster-42.localtest.me:1234?sslmode=verify-full' | ||
``` | ||
|
||
## Test proxy locally | ||
|
||
Firstly, we need to build proxy with 'testing' feature and run, e.g.: | ||
|
||
``` | ||
RUST_LOG=proxy cargo run --release -p proxy --bin proxy --features testing -- --auth-backend postgres --auth-endpoint 'postgresql://proxy:[email protected]:5432/postgres' --is-private-access-proxy true | ||
``` | ||
|
||
We will also need to have a postgres instance. Assuming that we have setted up docker we can set it up as follows: | ||
```sh | ||
mkdir -p "$HOME/.pgdata/proxy-postgres" | ||
|
||
docker network create proxy-net | ||
|
||
exec docker \ | ||
run \ | ||
--platform linux/aarch64 \ | ||
--detach \ | ||
--name proxy-postgres \ | ||
--env POSTGRES_PASSWORD=proxy-postgres \ | ||
--env PGDATA=/var/lib/postgresql/data/pgdata \ | ||
--volume "$HOME/.pgdata/proxy-postgres":/var/lib/postgresql/data \ | ||
--publish 5432:5432 \ | ||
--network proxy-net \ | ||
postgres:17-bookworm | ||
``` | ||
|
||
Next step is setting up auth table and schema as well as creating role: | ||
```sh | ||
docker exec -it proxy-postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS neon_control_plane" | ||
docker exec -it proxy-postgres psql -U postgres -c "CREATE TABLE neon_control_plane.endpoints "(endpoint_id VARCHAR(255) PRIMARY KEY, allowed_ips VARCHAR(255))" | ||
docker exec -it proxy-postgres psql -U postgres -c "CREATE ROLE proxy WITH SUPERUSER LOGIN PASSWORD 'password';" | ||
``` | ||
Now from client you can start a new session: | ||
```sh | ||
psql "postgresql://proxy:[email protected]:4432/postgres?options=endpoint%3D" | ||
``` |