Skip to content

Commit

Permalink
[proxy/docs]imprv: Add local testing section to proxy README
Browse files Browse the repository at this point in the history
Add commands to run proxy locally with mocked control plane.
  • Loading branch information
awarus committed Dec 23, 2024
1 parent 9c53b41 commit ff5792a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

0 comments on commit ff5792a

Please sign in to comment.