Skip to content

Commit 80c00e8

Browse files
Document and run health-provider tests
Document how to run health-provider tests, and fix docker-compose and tests which failed due to newer Redis.
1 parent 056c552 commit 80c00e8

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

examples/Advanced/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ services:
77
environment:
88
- MYSQL_ROOT_PASSWORD=root
99
redis:
10-
image: redis:alpine
10+
image: redis:7.2.5-alpine
1111
ports:
1212
- 6379:6379
1313
sba:
1414
image: michayaak/spring-boot-admin:2.2.2
1515
ports:
16-
- 8080:8080
16+
- 8080:8082

tests/health/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Running help-provider tests
2+
By default, the health-provider tests are skipped unless the monitoried systems are runnign and are configured.
3+
4+
In order to run all the tests health-provider tests at once, you'll need to start and configure MySQL and Redis servers.
5+
6+
The easiest way to do so, is using docker-compose to run the advanced-example.
7+
8+
1. Start MySQL and Redis - from the `example/Advanced` folder, run:
9+
```
10+
docker-compose --project-name example --file docker-compose.yml up --force-recreate
11+
```
12+
1. Run the tests - from the `tests/health` folder, run:
13+
```
14+
TEST_MYSQL_SERVER=localhost TEST_REDIS_SERVER=localhost poetry run pytest
15+
```

tests/health/test_aioredis_health_provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_aioredis_health(redis_host: str) -> None:
3131
redis_instance = AioRedis(host=redis_host)
3232

3333
health = AioRedisHealthProvider(redis_instance).get_health()
34-
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("5.0.3", "standalone"))
34+
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("7.2.5", "standalone"))
3535

3636

3737
@pytest.mark.usefixtures("require_redis", "require_redis_server")
@@ -44,4 +44,4 @@ def test_aioredis_bad_password(redis_host: str) -> None:
4444

4545
health = AioRedisHealthProvider(redis_instance).get_health()
4646
assert health.status == Status.DOWN
47-
assert "Client sent AUTH, but no password is set" in str(health.details.failure)
47+
assert "called without any password configured for the default user" in str(health.details.failure)

tests/health/test_redis_health_provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_redis_health(redis_host: str) -> None:
3030
from pyctuator.health.redis_health_provider import RedisHealthProvider, RedisHealthStatus, RedisHealthDetails
3131

3232
health = RedisHealthProvider(redis.Redis(host=redis_host)).get_health()
33-
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("5.0.3", "standalone"))
33+
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("7.2.5", "standalone"))
3434

3535

3636
@pytest.mark.usefixtures("require_redis", "require_redis_server")
@@ -41,4 +41,4 @@ def test_redis_bad_password(redis_host: str) -> None:
4141

4242
health = RedisHealthProvider(redis.Redis(host=redis_host, password="blabla")).get_health()
4343
assert health.status == Status.DOWN
44-
assert "Client sent AUTH, but no password is set" in str(health.details.failure)
44+
assert "called without any password configured for the default user" in str(health.details.failure)

0 commit comments

Comments
 (0)