-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests to verify Redis DB configuration (#12877)
* Add test to verify that the redis DB is not being saved to disk Add a test script to check that the redis config for the save setting is correct. This can be extended to check for other config options. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
- Loading branch information
1 parent
95d5707
commit 9684620
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
Test the database config | ||
""" | ||
import logging | ||
import pytest | ||
import json | ||
|
||
from tests.common.helpers.assertions import pytest_assert | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
pytestmark = [ | ||
pytest.mark.topology('any') | ||
] | ||
|
||
|
||
def test_redis_save_disabled(duthosts, rand_one_dut_hostname): | ||
""" | ||
@summary: Test that the database isn't being saved to disk | ||
""" | ||
duthost = duthosts[rand_one_dut_hostname] | ||
|
||
save_config_json = duthost.command(argv=["redis-cli", "--json", "CONFIG", "GET", "save"])["stdout"] | ||
save_config = json.loads(save_config_json) | ||
pytest_assert(save_config["save"] == "", "Redis should not be persisting contents to disk, save config is {}" | ||
.format(save_config["save"])) | ||
|
||
|
||
def test_redis_database_count(duthosts, rand_one_dut_hostname): | ||
""" | ||
@summary: Test that redis is configured to support 100 databases | ||
""" | ||
duthost = duthosts[rand_one_dut_hostname] | ||
|
||
database_config_json = duthost.command(argv=["redis-cli", "--json", "CONFIG", "GET", "databases"])["stdout"] | ||
database_config = json.loads(database_config_json) | ||
pytest_assert(database_config["databases"] == "100", "Redis is configured to support {} instead of 100 databases" | ||
.format(database_config["databases"])) | ||
|
||
|
||
def test_redis_unix_socket(duthosts, rand_one_dut_hostname): | ||
""" | ||
@summary: Test that redis has the unix socket option enabled | ||
""" | ||
duthost = duthosts[rand_one_dut_hostname] | ||
|
||
unixsocket_config_json = duthost.command(argv=["redis-cli", "--json", "CONFIG", "GET", "unixsocket"])["stdout"] | ||
unixsocket_config = json.loads(unixsocket_config_json) | ||
pytest_assert(unixsocket_config["unixsocket"] == "/var/run/redis/redis.sock", | ||
"Redis unixsocket is not configured correctly") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters