Skip to content

Commit

Permalink
nixos/tests/archiver-appliance: add play/pause + check store dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Aug 2, 2023
1 parent d0a6ac0 commit cb161da
Showing 1 changed file with 51 additions and 6 deletions.
57 changes: 51 additions & 6 deletions nixos/tests/archiver-appliance/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ def alarm(value: float):
for i in range(1, 6):
value: float = data[i]["val"]

expexted_val: float
expected_val: float
if previous_val == 9:
expexted_val = 0
expected_val = 0
else:
expexted_val = previous_val + 1
expected_val = previous_val + 1

assert value == expexted_val, "inconsistent archiving of aiExample"
assert value == expected_val, "inconsistent archiving of aiExample"
assert data[i]["severity"] == alarm(
value
), "incoherent severity of the aiExample alarm"
Expand Down Expand Up @@ -286,7 +286,52 @@ def waveform_has_data(_):

assert round(mean_delay) == 2, "calcExample should be archived every two second"

# TODO: check pause/play
# TODO: check /arch, check consolidation into mts, sts
with subtest("play pause"):
with subtest("pause archiving aiExample"):
# TODO: Doesn't seem to work through POST, may be a bug
get("/mgmt/bpl/pauseArchivingPV?pv=aiExample")

# For the store dirs test below
with subtest("consolidate aiExample"):
# Not POST? weird
get("/mgmt/bpl/consolidateDataForPV?pv=aiExample&storage=MTS")

data = get_data("aiExample")
expected_num_datapoints = len(data)
expected_last_point = data[expected_num_datapoints - 1]

with subtest("wait for a bit"):
time.sleep(3)

data = get_data("aiExample")
num_datapoints = len(data)
last_point = data[num_datapoints - 1]

assert num_datapoints == expected_num_datapoints, "pause shouldn't archive more"
assert last_point == expected_last_point, "pause shouldn't change last point"

with subtest("resume archiving aiExample"):
get("/mgmt/bpl/resumeArchivingPV?pv=aiExample")

with subtest("wait for a bit again"):
time.sleep(3)

data = get_data("aiExample")
num_datapoints = len(data)
last_point = data[num_datapoints - 1]

assert num_datapoints != expected_num_datapoints, "resume didn't archive more"
# Works because we also compare the timestamp
assert last_point != expected_last_point, "resume didn't change last point"


with subtest("checking store dirs"):
sts_content = server.succeed("ls -1 /arch/sts/ArchiverStore")
assert len(sts_content.strip().split("\n")) > 0

mts_content = server.succeed("ls -1 /arch/mts/ArchiverStore")
assert len(mts_content.strip().split("\n")) > 0

# TODO: check controlling PV
# TODO: check renaming PV
# TODO: check different policies

0 comments on commit cb161da

Please sign in to comment.