Skip to content

Instantly share code, notes, and snippets.

@sazid
Created August 14, 2023 20:24
Show Gist options
  • Save sazid/f382c9194b9c8f756f7910202f3024f7 to your computer and use it in GitHub Desktop.
Save sazid/f382c9194b9c8f756f7910202f3024f7 to your computer and use it in GitHub Desktop.
zeuz_pricing.py
def inp(msg: str, default_value=None) -> float:
while True:
try:
if default_value is not None:
typ = type(default_value)
user_input = input(f"{msg}: ")
if user_input:
return typ(user_input)
else:
return default_value
else:
return input(msg)
except:
print("[ERROR] invalid input, must be of type ", type(default_value))
def main():
# Server metrics
runids_per_day = inp("How many deployments/runids are created every day? [default: 10]", 10)
tcs_per_runid = inp("Average number of test cases per runid? [default: 200]", 200)
screenshot_size = inp("Average screenshot size in MB? [default: 1.5]", 1.5)
screenshot_count_per_tc = inp(
"Average number of screenshots per test case? "
"(Number of actions that interact with the UI) "
"[default: 20]",
20,
)
db_and_misc_size = inp("Database and attachment storage in GB? [default: 10]", 10)
# Node metrics
number_of_nodes = inp("Number of zeuz nodes? [default: 1]", 1)
node_vm_storage = inp("Node VM storage in GB? [default: 8]", 8)
# https://calculator.aws/#/estimate
# AWS rates (in $USD)
ebs_1gb_cost = 0.1
ebs_1gb_daily_snapshot_cost = 2.40
# AWS t3.medium (2 vCPU, 4GB RAM)
server_cpu_cost = 31
# AWS t3.medium (2 vCPU, 4GB RAM)
node_cpu_cost = 31
# Server cost calculation.
#
# Note that this does not currently take into account the network bandwidth
# (the amount of data transferred to/from the VMs).
# Run history usage data for 30 days
run_history_storage_usage_in_mb = 30 * runids_per_day * tcs_per_runid * screenshot_count_per_tc * screenshot_size
# Database and attachment storage
db_and_misc_storage_usage_in_mb = db_and_misc_size * 1024
# Server cost
server_storage_usage = (run_history_storage_usage_in_mb + db_and_misc_storage_usage_in_mb) / 1024
server_storage_cost = server_storage_usage * ebs_1gb_cost
server_cost = server_storage_cost + server_cpu_cost
# Node cost
node_storage_cost = node_vm_storage * ebs_1gb_cost
node_cost = (node_storage_cost + node_cpu_cost) * number_of_nodes
print("-" * 10)
print("| REPORT |")
print("-" * 10)
print("Server storage required per month: ", server_storage_usage, "GB")
print("Server storage cost: $", server_storage_cost)
print("Node storage cost: $", node_storage_cost)
print("-" * 3)
print("Server cost (without 30 day daily backup): $", server_cost)
print("Server cost (with 30 day daily backup): $", server_cost + 650)
print("Node cost: $", node_cost)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment