Last active
October 4, 2023 18:36
-
-
Save organom/162741c35aa1436db8478dba77ba1ff9 to your computer and use it in GitHub Desktop.
Test volume creation times in AWS (NGS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ngs | |
F ebs(volumeSize: Int) { | |
volumeId = null | |
took = time({ | |
volumeId = ``log:'Creating volume' aws ec2 create-volume --availability-zone eu-central-1a --size ${volumeSize}``.VolumeId | |
retry( | |
times = 100 | |
sleep = 0 | |
logger = log | |
title = "Waiting for volume ${volumeId} to be created" | |
body = { | |
``aws ec2 describe-volume-status --volume-id ${volumeId}``.the_one().VolumeStatus =~ {'Status': 'ok'} # last is always return | |
} | |
) | |
}); | |
``log:"Asserting volume state" aws ec2 describe-volume-status --volume-id ${volumeId}``.the_one().VolumeStatus.assert({'Status': 'ok'}) | |
$(log:"Deleting volume" aws ec2 delete-volume --volume-id ${volumeId}) | |
tookSeconds = Real(took)/Real(1000000) | |
log("Took ${tookSeconds} seconds to create a ${volumeSize}GB volume ${volumeId}") | |
tookSeconds | |
} | |
F +(x: Int, y: Real) Real(x) + y | |
F +(x: Real, y: Int) x + Real(y) | |
F /(x: Int, y: Real) Real(x) / y | |
F /(x: Real, y: Int) x / Real(y) | |
F avg(x: Arr) x.sum() / x.len() | |
F main(volumeSize: Int = 100, runs: Int = 10) { | |
log("Running ${runs} times") | |
log("VolumeSize ${volumeSize}GB\n") | |
results = runs.map({ebs(volumeSize)}) | |
log ("Average is ${results.avg()}") | |
log ("Max is ${results.max()}") | |
log ("Min is ${results.min()}") | |
results.avg() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment