Skip to content

Commit

Permalink
Merge pull request #388 from input-output-hk/dorin/mary_update
Browse files Browse the repository at this point in the history
sync tests - added support for marry era (not for mainnet yet)
  • Loading branch information
dorin100 committed Feb 19, 2021
2 parents 608ec2b + ea81208 commit aa08b18
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 20 deletions.
Binary file modified sync_tests/sync_results.db
Binary file not shown.
72 changes: 55 additions & 17 deletions sync_tests/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def get_size(start_path='.'):
def wait_for_node_to_sync(env, tag_no):
sync_details_dict = OrderedDict()
count = 0
last_byron_slot_no, last_shelley_slot_no, latest_slot_no = get_calculated_slot_no(env)
last_byron_slot_no, last_shelley_slot_no, last_allegra_slot_no, latest_slot_no = get_calculated_slot_no(env)

actual_slot_no = get_current_tip(tag_no)[2]
start_sync = time.perf_counter()
Expand Down Expand Up @@ -475,7 +475,27 @@ def wait_for_node_to_sync(env, tag_no):
end_shelley_sync = time.perf_counter()
shelley_sync_time_seconds = int(end_shelley_sync - end_byron_sync)

if last_shelley_slot_no != latest_slot_no:
while actual_slot_no <= last_allegra_slot_no:
value_dict = {
"actual_slot_not": actual_slot_no,
"actual_sync_percent": percentage(actual_slot_no, latest_slot_no),
"actual_date_time": get_current_date_time(),
}
sync_details_dict[count] = value_dict

print(
f" - actual_slot_no (Allegra era): "
f"{actual_slot_no} - {percentage(actual_slot_no, latest_slot_no)} % --> "
f"{get_current_date_time()}"
)
time.sleep(15)
count += 1
actual_slot_no = get_current_tip(tag_no)[2]

end_allegra_sync = time.perf_counter()
allegra_sync_time_seconds = int(end_allegra_sync - end_shelley_sync)

if last_allegra_slot_no != latest_slot_no:
while actual_slot_no < latest_slot_no:
value_dict = {
"actual_slot_not": actual_slot_no,
Expand All @@ -485,18 +505,18 @@ def wait_for_node_to_sync(env, tag_no):
sync_details_dict[count] = value_dict

print(
f" - actual_slot_no (Allegra era): "
f" - actual_slot_no (Mary era): "
f"{actual_slot_no} - {percentage(actual_slot_no, latest_slot_no)} % --> "
f"{get_current_date_time()}"
)
time.sleep(15)
count += 1
actual_slot_no = get_current_tip(tag_no)[2]

end_allegra_sync = time.perf_counter()
allegra_sync_time_seconds = int(end_allegra_sync - end_shelley_sync)
end_mary_sync = time.perf_counter()
mary_sync_time_seconds = int(end_mary_sync - end_allegra_sync)
else:
allegra_sync_time_seconds = 0
mary_sync_time_seconds = 0

# include also the last value into the db/dict (100%)
value_dict = {
Expand All @@ -512,7 +532,7 @@ def wait_for_node_to_sync(env, tag_no):
os.chdir(Path(CARDANO_NODE_TESTS_PATH))
print(f"Sync done!; newest_chunk: {newest_chunk}")
return newest_chunk, byron_sync_time_seconds, shelley_sync_time_seconds, \
allegra_sync_time_seconds, sync_details_dict
allegra_sync_time_seconds, mary_sync_time_seconds, sync_details_dict


def date_diff_in_seconds(dt2, dt1):
Expand All @@ -522,16 +542,18 @@ def date_diff_in_seconds(dt2, dt1):

def get_calculated_slot_no(env):
current_time = datetime.utcnow()
allegra_start_time = current_time
shelley_start_time, byron_start_time, allegra_start_time, mary_start_time, alonzo_start_time = current_time

if env == "testnet":
byron_start_time = datetime.strptime("2019-07-24 20:20:16", "%Y-%m-%d %H:%M:%S")
shelley_start_time = datetime.strptime("2020-07-28 20:20:16", "%Y-%m-%d %H:%M:%S")
allegra_start_time = datetime.strptime("2020-12-15 20:20:16", "%Y-%m-%d %H:%M:%S")
mary_start_time = datetime.strptime("2021-02-03 20:20:16", "%Y-%m-%d %H:%M:%S")
elif env == "staging":
byron_start_time = datetime.strptime("2017-09-26 18:23:33", "%Y-%m-%d %H:%M:%S")
shelley_start_time = datetime.strptime("2020-08-01 18:23:33", "%Y-%m-%d %H:%M:%S")
allegra_start_time = datetime.strptime("2020-12-19 18:23:33", "%Y-%m-%d %H:%M:%S")
mary_start_time = datetime.strptime("2021-01-28 18:23:33", "%Y-%m-%d %H:%M:%S")
elif env == "mainnet":
byron_start_time = datetime.strptime("2017-09-23 21:44:51", "%Y-%m-%d %H:%M:%S")
shelley_start_time = datetime.strptime("2020-07-29 21:44:51", "%Y-%m-%d %H:%M:%S")
Expand All @@ -540,15 +562,19 @@ def get_calculated_slot_no(env):
byron_start_time = datetime.strptime("2020-08-17 13:00:00", "%Y-%m-%d %H:%M:%S")
shelley_start_time = datetime.strptime("2020-08-17 17:00:00", "%Y-%m-%d %H:%M:%S")
allegra_start_time = datetime.strptime("2020-12-07 19:00:00", "%Y-%m-%d %H:%M:%S")
mary_start_time = datetime.strptime("2021-01-30 01:00:00", "%Y-%m-%d %H:%M:%S")

last_byron_slot_no = int(date_diff_in_seconds(shelley_start_time, byron_start_time) / 20)
last_shelley_slot_no = int(date_diff_in_seconds(allegra_start_time, shelley_start_time) +
last_byron_slot_no)
if allegra_start_time != current_time:
last_allegra_slot_no = int(date_diff_in_seconds(current_time, allegra_start_time) +
last_shelley_slot_no)
last_allegra_slot_no = int(date_diff_in_seconds(mary_start_time, shelley_start_time) +
last_byron_slot_no)

if mary_start_time != current_time:
last_mary_slot_no = int(date_diff_in_seconds(current_time, mary_start_time) +
last_allegra_slot_no)
else:
last_allegra_slot_no = 0
last_mary_slot_no = 0

latest_slot_no = int(date_diff_in_seconds(shelley_start_time, byron_start_time) / 20 +
date_diff_in_seconds(current_time, shelley_start_time))
Expand All @@ -557,14 +583,16 @@ def get_calculated_slot_no(env):
print(f"byron_start_time : {byron_start_time}")
print(f"shelley_start_time : {shelley_start_time}")
print(f"allegra_start_time : {allegra_start_time}")
print(f"mary_start_time : {mary_start_time}")
print(f"current_utc_time : {current_time}")
print(f"last_byron_slot_no : {last_byron_slot_no}")
print(f"last_shelley_slot_no : {last_shelley_slot_no}")
print(f"last_allegra_slot_no : {last_allegra_slot_no}")
print(f"last_mary_slot_no : {last_mary_slot_no}")
print(f"latest_slot_no : {latest_slot_no}")
print("----------------------------------------------------------------")

return last_byron_slot_no, last_shelley_slot_no, latest_slot_no
return last_byron_slot_no, last_shelley_slot_no, last_allegra_slot_no, latest_slot_no


def main():
Expand Down Expand Up @@ -624,6 +652,7 @@ def main():
byron_sync_time_seconds1,
shelley_sync_time_seconds1,
allegra_sync_time_seconds1,
mary_sync_time_seconds1,
sync_details_dict1
) = wait_for_node_to_sync(env, tag_no1)

Expand All @@ -643,16 +672,20 @@ def main():
print(
f"allegra_sync_time_seconds1: {time.strftime('%H:%M:%S', time.gmtime(allegra_sync_time_seconds1))}"
)
print(f"mary_sync_time_seconds1: {mary_sync_time_seconds1}")
print(
f"mary_sync_time_seconds1: {time.strftime('%H:%M:%S', time.gmtime(mary_sync_time_seconds1))}"
)

latest_block_no1 = get_current_tip(tag_no1)[0]
latest_slot_no1 = get_current_tip(tag_no1)[2]
sync_speed_bps1 = int(
latest_block_no1 / (
byron_sync_time_seconds1 + shelley_sync_time_seconds1 + allegra_sync_time_seconds1)
byron_sync_time_seconds1 + shelley_sync_time_seconds1 + allegra_sync_time_seconds1 + mary_sync_time_seconds1)
)
sync_speed_sps1 = int(
latest_slot_no1 / (
byron_sync_time_seconds1 + shelley_sync_time_seconds1 + allegra_sync_time_seconds1)
byron_sync_time_seconds1 + shelley_sync_time_seconds1 + allegra_sync_time_seconds1 + mary_sync_time_seconds1)
)
print(f"sync_speed_bps1 : {sync_speed_bps1}")
print(f"sync_speed_sps1 : {sync_speed_sps1}")
Expand Down Expand Up @@ -703,6 +736,7 @@ def main():
byron_sync_time_seconds2,
shelley_sync_time_seconds2,
allegra_sync_time_seconds2,
mary_sync_time_seconds2,
sync_details_dict2
) = wait_for_node_to_sync(env, tag_no2)

Expand All @@ -722,16 +756,19 @@ def main():
print(f"allegra_sync_time_seconds2: {allegra_sync_time_seconds2}")
print(f"allegra_sync_time_seconds2: "
f"{time.strftime('%H:%M:%S', time.gmtime(allegra_sync_time_seconds2))}")
print(f"mary_sync_time_seconds2: {mary_sync_time_seconds2}")
print(f"mary_sync_time_seconds2: "
f"{time.strftime('%H:%M:%S', time.gmtime(mary_sync_time_seconds2))}")

latest_block_no2 = get_current_tip(tag_no2)[0]
latest_slot_no2 = get_current_tip(tag_no2)[2]
sync_speed_bps2 = int(
(latest_block_no2 - latest_block_no1)
/ (byron_sync_time_seconds2 + shelley_sync_time_seconds2 + allegra_sync_time_seconds2)
/ (byron_sync_time_seconds2 + shelley_sync_time_seconds2 + allegra_sync_time_seconds2 + mary_sync_time_seconds2)
)
sync_speed_sps2 = int(
(latest_slot_no2 - latest_slot_no1)
/ (byron_sync_time_seconds2 + shelley_sync_time_seconds2 + allegra_sync_time_seconds2)
/ (byron_sync_time_seconds2 + shelley_sync_time_seconds2 + allegra_sync_time_seconds2 + mary_sync_time_seconds2)
)
print(f"sync_speed_bps2 : {sync_speed_bps2}")
print(f"sync_speed_sps2 : {sync_speed_sps2}")
Expand Down Expand Up @@ -761,6 +798,7 @@ def main():
byron_sync_time_seconds1,
shelley_sync_time_seconds1,
allegra_sync_time_seconds1,
mary_sync_time_seconds1,
sync_time_after_restart_seconds,
total_chunks1,
total_chunks2,
Expand Down
6 changes: 3 additions & 3 deletions sync_tests/write_values_to_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def add_test_values_into_db(env, test_values):
sql = f' INSERT INTO {env} ' \
f'(env, tag_no1, tag_no2, cardano_cli_version1, cardano_cli_version2, ' \
f'cardano_cli_git_rev1, cardano_cli_git_rev2, start_sync_time1, end_sync_time1, start_sync_time2, ' \
f'end_sync_time2, byron_sync_time_secs1, shelley_sync_time_secs1, allegra_sync_time_seconds1, ' \
f'end_sync_time2, byron_sync_time_secs1, shelley_sync_time_secs1, allegra_sync_time_seconds1, mary_sync_time_seconds1, ' \
f'sync_time_after_restart_seconds, total_chunks1, total_chunks2, latest_block_no1, latest_block_no2, ' \
f'latest_slot_no1, latest_slot_no2, start_node_seconds1, start_node_seconds2, platform_system, ' \
f'platform_release, platform_version, chain_size, sync_details1) ' \
f'VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'
f'VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'

print(f"sql: {sql}")

Expand Down Expand Up @@ -99,7 +99,7 @@ def main():
file_values = file.read()
print(f"file_values: {file_values}")

test_values = file_values.replace("(", "").replace(")", "").replace("'", "").split(", ", 27)
test_values = file_values.replace("(", "").replace(")", "").replace("'", "").split(", ", 28)

print(f"env: {env}")
print(f"test_values: {test_values}")
Expand Down

0 comments on commit aa08b18

Please sign in to comment.