Skip to content

Document and run health-provider tests #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Advanced/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=root
redis:
image: redis:alpine
image: redis:7.2.5-alpine
ports:
- 6379:6379
sba:
image: michayaak/spring-boot-admin:2.2.2
ports:
- 8080:8080
- 8080:8082
15 changes: 15 additions & 0 deletions tests/health/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Running help-provider tests
By default, the health-provider tests are skipped unless the monitoried systems are runnign and are configured.

In order to run all the tests health-provider tests at once, you'll need to start and configure MySQL and Redis servers.

The easiest way to do so, is using docker-compose to run the advanced-example.

1. Start MySQL and Redis - from the `example/Advanced` folder, run:
```
docker-compose --project-name example --file docker-compose.yml up --force-recreate
```
1. Run the tests - from the `tests/health` folder, run:
```
TEST_MYSQL_SERVER=localhost TEST_REDIS_SERVER=localhost poetry run pytest
```
4 changes: 2 additions & 2 deletions tests/health/test_aioredis_health_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_aioredis_health(redis_host: str) -> None:
redis_instance = AioRedis(host=redis_host)

health = AioRedisHealthProvider(redis_instance).get_health()
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("5.0.3", "standalone"))
assert health == RedisHealthStatus(Status.UP, RedisHealthDetails("7.2.5", "standalone"))


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

health = AioRedisHealthProvider(redis_instance).get_health()
assert health.status == Status.DOWN
assert "Client sent AUTH, but no password is set" in str(health.details.failure)
assert "called without any password configured for the default user" in str(health.details.failure)
4 changes: 2 additions & 2 deletions tests/health/test_redis_health_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_redis_health(redis_host: str) -> None:
from pyctuator.health.redis_health_provider import RedisHealthProvider, RedisHealthStatus, RedisHealthDetails

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


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

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