Skip to content

Commit b2959c9

Browse files
committed
tests
1 parent 83913db commit b2959c9

File tree

3 files changed

+62
-20
lines changed

3 files changed

+62
-20
lines changed

Makefile

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,29 @@ test-core:
7474
pytest tests/unit/test_basic_queries.py tests/unit/test_cluster.py tests/unit/test_session.py -v -x
7575

7676
# Critical path - MUST ALL PASS
77-
test-critical: cassandra-wait
78-
@echo "Running critical tests (including FastAPI)..."
79-
pytest tests/unit -v -x -m "critical" || pytest tests/unit/test_critical_issues.py -v -x
77+
test-critical:
78+
@echo "Running critical tests..."
79+
@echo "=== Running Critical Unit Tests (No Cassandra) ==="
80+
pytest tests/unit/test_critical_issues.py -v -x
81+
@echo "=== Starting Cassandra for Integration Tests ==="
82+
$(MAKE) cassandra-wait
83+
@echo "=== Running Critical FastAPI Tests ==="
8084
pytest tests/fastapi_integration -v
8185
cd examples/fastapi_app && pytest tests/test_fastapi_app.py -v
82-
pytest tests/bdd -m "critical" -v || pytest tests/bdd -v -x
86+
@echo "=== Cleaning up Cassandra ==="
87+
$(MAKE) cassandra-stop
8388

8489
# Progressive execution - FAIL FAST
85-
test-progressive: cassandra-wait
90+
test-progressive:
8691
@echo "Running tests in fail-fast order..."
87-
@echo "=== Running Core Unit Tests ==="
92+
@echo "=== Running Core Unit Tests (No Cassandra) ==="
8893
@pytest tests/unit/test_basic_queries.py tests/unit/test_cluster.py tests/unit/test_session.py -v -x || exit 1
89-
@echo "=== Running Resilience Tests ==="
94+
@echo "=== Running Resilience Tests (No Cassandra) ==="
9095
@pytest tests/unit/test_error_recovery.py tests/unit/test_retry_policy.py -v -x || exit 1
91-
@echo "=== Running Feature Tests ==="
96+
@echo "=== Running Feature Tests (No Cassandra) ==="
9297
@pytest tests/unit/test_streaming.py tests/unit/test_prepared_statements.py -v || exit 1
98+
@echo "=== Starting Cassandra for Integration Tests ==="
99+
@$(MAKE) cassandra-wait || exit 1
93100
@echo "=== Running Integration Tests ==="
94101
@pytest tests/integration -v || exit 1
95102
@echo "=== Running FastAPI Integration Tests ==="
@@ -98,6 +105,8 @@ test-progressive: cassandra-wait
98105
@cd examples/fastapi_app && pytest tests/test_fastapi_app.py -v || exit 1
99106
@echo "=== Running BDD Tests ==="
100107
@pytest tests/bdd -v || exit 1
108+
@echo "=== Cleaning up Cassandra ==="
109+
@$(MAKE) cassandra-stop
101110

102111
# Test suite commands
103112
test-resilience:
@@ -117,12 +126,19 @@ test-performance:
117126
test-bdd: cassandra-wait
118127
@echo "Running BDD tests..."
119128
@mkdir -p reports
120-
pytest tests/bdd -v --cucumber-json=reports/bdd.json
129+
pytest tests/bdd/ -v
121130

122131
# Standard test command - runs everything except stress
123-
test: cassandra-wait
132+
test:
124133
@echo "Running standard test suite..."
125-
pytest tests/ -v -m "not stress"
134+
@echo "=== Running Unit Tests (No Cassandra Required) ==="
135+
pytest tests/unit/ -v
136+
@echo "=== Starting Cassandra for Integration Tests ==="
137+
$(MAKE) cassandra-wait
138+
@echo "=== Running Integration/FastAPI/BDD Tests ==="
139+
pytest tests/integration/ tests/fastapi_integration/ tests/bdd/ -v -m "not stress"
140+
@echo "=== Cleaning up Cassandra ==="
141+
$(MAKE) cassandra-stop
126142

127143
test-unit:
128144
@echo "Running unit tests (no Cassandra required)..."
@@ -131,12 +147,12 @@ test-unit:
131147

132148
test-integration: cassandra-wait
133149
@echo "Running integration tests..."
134-
CASSANDRA_CONTACT_POINTS=$(CASSANDRA_CONTACT_POINTS) pytest tests/integration/ -v -m integration
150+
CASSANDRA_CONTACT_POINTS=$(CASSANDRA_CONTACT_POINTS) pytest tests/integration/ -v -m "not stress"
135151
@echo "Integration tests completed."
136152

137153
test-integration-keep: cassandra-wait
138154
@echo "Running integration tests (keeping containers after tests)..."
139-
KEEP_CONTAINERS=1 CASSANDRA_CONTACT_POINTS=$(CASSANDRA_CONTACT_POINTS) pytest tests/integration/ -v -m integration
155+
KEEP_CONTAINERS=1 CASSANDRA_CONTACT_POINTS=$(CASSANDRA_CONTACT_POINTS) pytest tests/integration/ -v -m "not stress"
140156
@echo "Integration tests completed. Containers are still running."
141157

142158
test-fastapi: cassandra-wait
@@ -152,9 +168,39 @@ test-stress: cassandra-wait
152168
@echo "Stress tests completed."
153169

154170
# Full test suite - EVERYTHING MUST PASS
155-
test-all: lint cassandra-wait
171+
test-all: lint
156172
@echo "Running complete test suite..."
157-
@./scripts/run_tests.sh all
173+
@echo "=== Running Unit Tests (No Cassandra Required) ==="
174+
pytest tests/unit/ -v --cov=async_cassandra --cov-report=html --cov-report=xml
175+
176+
@echo "=== Running Integration Tests ==="
177+
$(MAKE) cassandra-stop || true
178+
$(MAKE) cassandra-wait
179+
pytest tests/integration/ -v -m "not stress"
180+
181+
@echo "=== Running FastAPI Integration Tests ==="
182+
$(MAKE) cassandra-stop
183+
$(MAKE) cassandra-wait
184+
pytest tests/fastapi_integration/ -v
185+
186+
@echo "=== Running BDD Tests ==="
187+
$(MAKE) cassandra-stop
188+
$(MAKE) cassandra-wait
189+
pytest tests/bdd/ -v
190+
191+
@echo "=== Running Example App Tests ==="
192+
$(MAKE) cassandra-stop
193+
$(MAKE) cassandra-wait
194+
cd examples/fastapi_app && pytest tests/ -v
195+
196+
@echo "=== Running Stress Tests ==="
197+
$(MAKE) cassandra-stop
198+
$(MAKE) cassandra-wait
199+
pytest tests/integration/ -v -m stress
200+
201+
@echo "=== Cleaning up Cassandra ==="
202+
$(MAKE) cassandra-stop
203+
@echo "✅ All tests completed!"
158204

159205
# Code quality - MUST PASS
160206
lint:
@@ -240,7 +286,7 @@ cassandra-wait:
240286
exit 1; \
241287
else \
242288
echo "Checking if Cassandra on $(CASSANDRA_CONTACT_POINTS):$(CASSANDRA_PORT) can accept queries..."; \
243-
if [ "$(CASSANDRA_CONTACT_POINTS)" = "localhost" ] && $(CONTAINER_RUNTIME) ps --format "{{.Names}}" | grep -q "^$(CASSANDRA_CONTAINER_NAME)$$"; then \
289+
if [ "$(CASSANDRA_CONTACT_POINTS)" = "127.0.0.1" ] && $(CONTAINER_RUNTIME) ps --format "{{.Names}}" | grep -q "^$(CASSANDRA_CONTAINER_NAME)$$"; then \
244290
if ! $(CONTAINER_RUNTIME) exec $(CASSANDRA_CONTAINER_NAME) cqlsh -e "SELECT release_version FROM system.local" 2>&1 | grep -q "[0-9]"; then \
245291
echo "Cassandra is running but not accepting queries yet, waiting..."; \
246292
for i in $$(seq 1 30); do \

tests/fastapi_integration/test_fastapi_example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import asyncio
6-
import os
76
import sys
87
import uuid
98
from pathlib import Path
@@ -245,7 +244,6 @@ async def test_sync_performance(self, client: AsyncClient, cassandra_service):
245244
assert data["requests_per_second"] > 0
246245

247246
@pytest.mark.asyncio
248-
@pytest.mark.skipif(os.getenv("CI") == "true", reason="Performance comparison unreliable in CI")
249247
async def test_performance_comparison(self, client: AsyncClient, cassandra_service):
250248
"""Test that async is faster than sync for concurrent operations."""
251249
# Run async test

tests/fastapi_integration/test_reconnection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
import asyncio
9-
import os
109
import subprocess
1110
import time
1211

@@ -219,7 +218,6 @@ async def test_cassandra_reconnection_behavior(self, app_client, cassandra_conta
219218
print(" - No manual intervention required")
220219

221220
@pytest.mark.asyncio
222-
@pytest.mark.skipif(os.getenv("CI") == "true", reason="Reconnection timing unreliable in CI")
223221
async def test_multiple_reconnection_cycles(self, app_client, cassandra_container):
224222
"""Test multiple disconnect/reconnect cycles to ensure stability."""
225223
print("\n=== Testing Multiple Reconnection Cycles ===")

0 commit comments

Comments
 (0)