Skip to content

Commit 715730e

Browse files
AndrewJackson2020CommanderKeynes
authored andcommitted
Implement trust authentication
1 parent 966b8e0 commit 715730e

30 files changed

+3700
-529
lines changed

.circleci/pgcat.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tls_private_key = ".circleci/server.key"
4949
# Connecting to that database allows running commands like `SHOW POOLS`, `SHOW DATABASES`, etc..
5050
admin_username = "admin_user"
5151
admin_password = "admin_pass"
52+
admin_auth_type = "md5"
5253

5354
# pool
5455
# configs are structured as pool.<pool_name>
@@ -59,6 +60,7 @@ admin_password = "admin_pass"
5960
# session: one server connection per connected client
6061
# transaction: one server connection per client transaction
6162
pool_mode = "transaction"
63+
prepared_statements_cache_size = 500
6264

6365
# If the client doesn't specify, route traffic to
6466
# this role by default.
@@ -97,6 +99,7 @@ sharding_function = "pg_bigint_hash"
9799
[pools.sharded_db.users.0]
98100
username = "sharding_user"
99101
password = "sharding_user"
102+
auth_type = "md5"
100103
# Maximum number of server connections that can be established for this user
101104
# The maximum number of connection from a single Pgcat process to any database in the cluster
102105
# is the sum of pool_size across all users.
@@ -106,6 +109,7 @@ statement_timeout = 0
106109
[pools.sharded_db.users.1]
107110
username = "other_user"
108111
password = "other_user"
112+
auth_type = "md5"
109113
pool_size = 21
110114
statement_timeout = 30000
111115

@@ -141,10 +145,12 @@ query_parser_enabled = true
141145
query_parser_read_write_splitting = true
142146
primary_reads_enabled = true
143147
sharding_function = "pg_bigint_hash"
148+
prepared_statements_cache_size = 500
144149

145150
[pools.simple_db.users.0]
146151
username = "simple_user"
147152
password = "simple_user"
153+
auth_type = "md5"
148154
pool_size = 5
149155
statement_timeout = 30000
150156

.circleci/pgcat_trust.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
[general]
3+
4+
host = "0.0.0.0"
5+
port = 6432
6+
admin_username = "admin_user"
7+
admin_password = ""
8+
admin_auth_type = "trust"
9+
10+
[pools.sharded_db.users.0]
11+
username = "sharding_user"
12+
password = "sharding_user"
13+
auth_type = "trust"
14+
pool_size = 10
15+
min_pool_size = 1
16+
pool_mode = "transaction"
17+
18+
[pools.sharded_db.shards.0]
19+
servers = [
20+
[ "127.0.0.1", 5432, "primary" ],
21+
]
22+
database = "shard0"

.github/workflows/build-and-push.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ jobs:
2323

2424
steps:
2525
- name: Checkout Repository
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
27+
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v3
2730

2831
- name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@v2
32+
uses: docker/setup-buildx-action@v3
3033

3134
- name: Determine tags
3235
id: metadata
33-
uses: docker/metadata-action@v4
36+
uses: docker/metadata-action@v5
3437
with:
3538
images: ${{ env.registry }}/${{ env.image-name }}
3639
tags: |
@@ -42,15 +45,18 @@ jobs:
4245
type=raw,value=latest,enable={{ is_default_branch }}
4346
4447
- name: Log in to the Container registry
45-
uses: docker/login-action@v2.1.0
48+
uses: docker/login-action@v3
4649
with:
4750
registry: ${{ env.registry }}
4851
username: ${{ github.actor }}
4952
password: ${{ secrets.GITHUB_TOKEN }}
5053

5154
- name: Build and push ${{ env.image-name }}
52-
uses: docker/build-push-action@v3
55+
uses: docker/build-push-action@v6
5356
with:
57+
context: .
58+
platforms: linux/amd64,linux/arm64
59+
provenance: false
5460
push: true
5561
tags: ${{ steps.metadata.outputs.tags }}
5662
labels: ${{ steps.metadata.outputs.labels }}

CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ Thank you for contributing! Just a few tips here:
66
2. Run the test suite (e.g. `pgbench`) to make sure everything still works. The tests are in `.circleci/run_tests.sh`.
77
3. Performance is important, make sure there are no regressions in your branch vs. `main`.
88

9+
## How to run the integration tests locally and iterate on them
10+
We have integration tests written in Ruby, Python, Go and Rust.
11+
Below are the steps to run them in a developer-friendly way that allows iterating and quick turnaround.
12+
Hear me out, this should be easy, it will involve opening a shell into a container with all the necessary dependancies available for you and you can modify the test code and immediately rerun your test in the interactive shell.
13+
14+
15+
Quite simply, make sure you have docker installed and then run
16+
`./start_test_env.sh`
17+
18+
That is it!
19+
20+
Within this test environment you can modify the file in your favorite IDE and rerun the tests without having to bootstrap the entire environment again.
21+
22+
Once the environment is ready, you can run the tests by running
23+
Ruby: `cd /app/tests/ruby && bundle exec ruby <test_name>.rb --format documentation`
24+
Python: `cd /app && python3 tests/python/tests.py`
25+
Rust: `cd /app/tests/rust && cargo run`
26+
Go: `cd /app/tests/go && /usr/local/go/bin/go test`
27+
28+
You can also rebuild PgCat directly within the environment and the tests will run against the newly built binary
29+
To rebuild PgCat, just run `cargo build` within the container under `/app`
30+
31+
![Animated gif showing how to run tests](https://github.com/user-attachments/assets/2258fde3-2aed-4efb-bdc5-e4f12dcd4d33)
32+
33+
34+
935
Happy hacking!
1036

1137
## TODOs

0 commit comments

Comments
 (0)