Skip to content
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

nixos/tests/phoebus-alarm: use IPv4 when querying Kafka #218

Merged
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
14 changes: 9 additions & 5 deletions nixos/tests/phoebus/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ def wait_for_boot():
alarm_config = f"config:{alarm_path}"
alarm_state = f"state:{alarm_path}"

server_ip = "192.168.1.3"


def send_kafka(key: str, value: dict[str, Any]):
value_s = json.dumps(value)
client.succeed(
f"echo '{key}={value_s}' | kcat -P -b server:9092 -t Accelerator -K="
f"echo '{key}={value_s}' | kcat -P -b {server_ip}:9092 -t Accelerator -K="
)


def get_alarm() -> dict[str, Any]:
result_s = client.wait_until_succeeds(
f"kcat -b server:9092 -C -t Accelerator -e -qJ | grep -F '{alarm_state}' | tail -1"
f"kcat -b {server_ip}:9092 -C -t Accelerator -e -qJ | grep -F '{alarm_state}' | tail -1"
)
result = json.loads(result_s)

Expand All @@ -61,7 +63,7 @@ def get_logger(uri: str):
client.wait_until_succeeds("caput ALARM_TEST 2")

with subtest("Topics are created"):
client.wait_until_succeeds("kcat -b server:9092 -L | grep Accelerator")
client.wait_until_succeeds(f"kcat -b {server_ip}:9092 -L | grep Accelerator")

with subtest("Can monitor a PV"):
send_kafka(
Expand Down Expand Up @@ -127,7 +129,7 @@ def logger_has_config(_):

with subtest("We can see that the previous alarm was acknowledged"):
result_s = client.wait_until_succeeds(
f"kcat -b server:9092 -C -t Accelerator -e -qJ | grep -F '{alarm_state}' | tail -1"
f"kcat -b {server_ip}:9092 -C -t Accelerator -e -qJ | grep -F '{alarm_state}' | tail -1"
)
result = json.loads(result_s)

Expand Down Expand Up @@ -192,6 +194,8 @@ def logger_has_latest_state(_):
assert alarm_states[2]["value"] == "4.0"

with subtest("Can export alarm configuration"):
server.succeed("phoebus-alarm-server -settings /etc/phoebus/alarm-server.properties -export export.xml")
server.succeed(
"phoebus-alarm-server -settings /etc/phoebus/alarm-server.properties -export export.xml"
)
server.succeed("grep ALARM_TEST export.xml")
server.copy_from_vm("export.xml")
Loading