From 5bbbccee1806ac595198c7c442e3634cf6ba83d5 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 17 Oct 2023 09:31:16 -0700 Subject: [PATCH] Add zk test to check myid is set in service Previously we were checking that myid was written to disk in the expected location. However, it is possible that zk would stop looking in that location for the myid value. To ensure we actually set the value in the running service check the logs for the [myid:4] string. Change-Id: Iee3b126abac13e19dab9ddf4c64ed133d0a98956 --- testinfra/test_zookeeper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testinfra/test_zookeeper.py b/testinfra/test_zookeeper.py index 4b638d2fdc..b2fea0edc2 100644 --- a/testinfra/test_zookeeper.py +++ b/testinfra/test_zookeeper.py @@ -24,6 +24,12 @@ def test_id_file(host): myid = host.file('/var/zookeeper/data/myid') assert myid.content == b'4\n' +def test_zk_myid_is_set(host): + # Test that our wacky hostname regex results in the correct + # myid value in the running service. + cmd = host.run("docker logs zookeeper-compose_zk_1") + assert "[myid:4]" in cmd.stdout + def test_zk_listening(host): zk = host.socket("tcp://0.0.0.0:2181") assert zk.is_listening