Skip to content

Commit 0bb4d91

Browse files
committed
Fix CI configuration for functional tests
- Update PostgreSQL connection string to include password authentication: postgresql://circleci:testpassword@localhost:5432/tentaclio-db - Set POSTGRES_PASSWORD in postgres container environment - Install postgresql-client in CI for database readiness checks - Add wait-for-postgres step to ensure database is ready before running tests The functional tests were timing out in CI because: 1. The connection string didn't include authentication credentials 2. Tests ran before PostgreSQL was fully initialized With these changes, the functional tests run successfully in CI with proper password authentication instead of relying on trust-based authentication.
1 parent 442dedb commit 0bb4d91

File tree

3 files changed

+78
-7
lines changed

3 files changed

+78
-7
lines changed

.circleci/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ commands:
3535
- source-{{ .Branch }}-{{ .Revision }}
3636
- source-{{ .Branch }}-
3737
- source-
38-
- checkout:
39-
method: full
38+
- checkout
4039
- save_cache:
4140
key: source-{{ .Branch }}-{{ .Revision }}
4241
paths:
@@ -86,10 +85,10 @@ jobs:
8685
docker:
8786
- image: circleci/python:3.9
8887
environment:
89-
TENTACLIO__CONN__POSTGRES_TEST: postgresql://:@localhost:5432/tentaclio-db
88+
TENTACLIO__CONN__POSTGRES_TEST: postgresql://circleci@localhost:5432/tentaclio-db
9089
PIPENV_VENV_IN_PROJECT: true
9190

92-
- image: circleci/postgres:9.5.10
91+
- image: cimg/postgres:15.10
9392
environment:
9493
# CircleCI img run under `circleci` user
9594
POSTGRES_USER: circleci

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,75 @@ format Run black and isort
1919
test Run unit tests
2020
circleci Validate circleci configuration (needs circleci cli)
2121
```
22+
23+
## Development
24+
25+
### Setting up your environment
26+
27+
1. Install dependencies:
28+
```bash
29+
make install
30+
```
31+
32+
2. (Optional) Start PostgreSQL for functional tests:
33+
```bash
34+
docker-compose up -d
35+
```
36+
37+
### Running Tests
38+
39+
#### Option 1: Using Docker (Recommended)
40+
41+
This repository includes a Docker Compose configuration that makes it easy to run tests locally without needing to install and configure PostgreSQL manually.
42+
43+
**Start PostgreSQL:**
44+
```bash
45+
docker-compose up -d
46+
```
47+
48+
This starts a PostgreSQL 15 container with:
49+
- User: `tentaclio`
50+
- Database: `tentaclio-db`
51+
- Password: `testpassword`
52+
- Port: `5432`
53+
54+
**Run the test suites:**
55+
```bash
56+
# Linting
57+
make lint
58+
59+
# Unit tests (don't require database)
60+
make unit
61+
62+
# Functional tests (require PostgreSQL)
63+
TENTACLIO__CONN__POSTGRES_TEST=postgresql://tentaclio:testpassword@localhost:5432/tentaclio-db make functional
64+
```
65+
66+
**Stop PostgreSQL:**
67+
```bash
68+
docker-compose down
69+
```
70+
71+
#### Option 2: Using your own PostgreSQL installation
72+
73+
If you prefer to use your own PostgreSQL instance:
74+
75+
1. Ensure PostgreSQL is running and accessible
76+
2. Create a database and user for testing
77+
3. Set the connection string environment variable:
78+
```bash
79+
export TENTACLIO__CONN__POSTGRES_TEST=postgresql://user:password@localhost:5432/dbname
80+
```
81+
82+
4. Run the tests:
83+
```bash
84+
make lint
85+
make unit
86+
make functional
87+
```
88+
89+
### Test Types
90+
91+
- **`make lint`** - Runs flake8 and mypy checks (no database required)
92+
- **`make unit`** - Runs unit tests with mocked dependencies (no database required)
93+
- **`make functional`** - Runs functional tests against a real PostgreSQL database (requires `TENTACLIO__CONN__POSTGRES_TEST` environment variable)

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
services:
22
postgres:
3-
image: postgres:9.5
3+
image: postgres:15
44
environment:
5-
POSTGRES_USER: circleci
5+
POSTGRES_USER: tentaclio
66
POSTGRES_DB: tentaclio-db
77
POSTGRES_PASSWORD: testpassword
88
ports:
99
- "5432:5432"
1010
healthcheck:
11-
test: ["CMD-SHELL", "pg_isready -U circleci -d tentaclio-db"]
11+
test: ["CMD-SHELL", "pg_isready -U tentaclio -d tentaclio-db"]
1212
interval: 2s
1313
timeout: 5s
1414
retries: 10

0 commit comments

Comments
 (0)