Skip to content

Commit 33359d8

Browse files
tobixenclaude
andcommitted
test: lift stalwart ratelimits
Claude has been trying to disable rate-limiting in Stalwart. I still got up some RateLimit errors while doing testing on the scheduling, but while asking Claude to continue debugging it, the problems disappeared and never came back. Hm. prompt: The stalwart docker image stops working every now and then when running test code due to ratelimiting errors. Any possibilities for deactivating this in the docker image? (followup-promps complaining that it isn't working) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1f45dee commit 33359d8

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

tests/docker-test-servers/stalwart/setup_stalwart.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ for i in $(seq 1 $max_caldav_attempts); do
124124
sleep 2
125125
done
126126

127+
echo ""
128+
echo "Disabling rate limiting for test environment..."
129+
# Stalwart applies HTTP and authentication rate limits by default, which causes
130+
# 429 responses during rapid test runs. Append generous limits to config inside
131+
# the container, then reload.
132+
docker exec "$CONTAINER_NAME" sh -c 'cat >> /opt/stalwart/etc/config.toml << '"'"'EOF'"'"'
133+
134+
[http]
135+
rate-limit-anonymous = { count = 999999999, period = "1m" }
136+
rate-limit-authenticated = { count = 999999999, period = "1m" }
137+
EOF'
138+
RELOAD_RESULT=$(curl -s -u "${ADMIN_USER}:${ADMIN_PASSWORD}" "${API_BASE}/reload")
139+
if echo "$RELOAD_RESULT" | grep -q '"errors":{}'; then
140+
echo "Rate limiting disabled (config reloaded)"
141+
else
142+
echo "Warning: config reload result: $RELOAD_RESULT"
143+
fi
144+
127145
echo ""
128146
echo "Stalwart setup complete!"
129147
echo ""

tests/test_async_integration.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ def _skip_unless_support(self, feature: str) -> None:
503503
@pytest_asyncio.fixture
504504
async def scheduling_setup(self) -> Any:
505505
"""Create async clients/principals/calendars for each scheduling user."""
506-
import uuid
507-
508506
from caldav.aio import get_async_davclient
509507

510508
from .fixture_helpers import aget_or_create_test_calendar, cleanup_calendar_objects
@@ -523,11 +521,14 @@ async def scheduling_setup(self) -> Any:
523521
await client.close()
524522
continue
525523
principal = await client.principal()
524+
## Use a fixed cal_id (not a random UUID) so the same calendar is
525+
## reused across test runs and does not accumulate on the server.
526+
## This mirrors the sync scheduling tests which use fixed calendar names.
526527
cal, _ = await aget_or_create_test_calendar(
527528
client,
528529
principal,
529530
calendar_name=f"async scheduling test {i}",
530-
cal_id=f"asyncschedtest{uuid.uuid4().hex[:8]}",
531+
cal_id=f"asyncschedtest{i}",
531532
)
532533
if cal is None:
533534
await client.close()

0 commit comments

Comments
 (0)