Conversation
Since we need privileged settings for the Docker container
brikis98
commented
Apr 12, 2018
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/log.sh" | ||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/aws.sh" | ||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/assertions.sh" | ||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/assert.sh" |
brikis98
commented
Apr 12, 2018
| local readonly max_retries=60 | ||
| local readonly sleep_between_retries=5 | ||
| asg_size=$(aws_wrapper_get_asg_size "$asg_name" "$aws_region" "$max_retries" "$sleep_between_retries") | ||
| assert_not_empty_or_null "$asg_size" "size of ASG $asg_name in $aws_region" |
brikis98
commented
Apr 12, 2018
| local readonly aws_region="$2" | ||
| local readonly use_public_ips="$3" | ||
| local readonly max_retries="${4:-60}" | ||
| local readonly sleep_between_retries="${5:-5}" |
Member
Author
There was a problem hiding this comment.
Also, I've made retries/timeouts optionally configurable throughout this code, which I needed for testing, but is actually a handy feature to have in general.
brikis98
commented
Apr 12, 2018
| @@ -0,0 +1,41 @@ | |||
| # A dirt-simple mock for the EC2 metadata service, built on top of Python and Flask. It allows you to set a mock value | |||
Member
Author
There was a problem hiding this comment.
This is my mock EC2 metadata server. I tried a bunch of open source ones, and they were all poorly supported, buggy, and only mocked a few of the endpoints I needed. Perhaps some day, we can clean this one up and open source it as a standalone project...
Member
Author
|
Merging now. Please take a look, as there are some handy patterns here for mocking out EC2 metadata, AWS APIs, overriding AWS CLI behavior, etc. Feedback welcome! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #1, I had test for everything but the two AWS bash scripts, as those are tricky to unit test. I started to use those scripts in another project, and, not too surprisingly, hit a bug.
So, I bit the bullet, and figured out how to unit test these suckers using
moto, a mock EC2 metadata server, and some other hacks. It was a PITA, that included some yak shaving around bats, but the upside is I actually found and fixed several bugs, so I guess it was worth the effort.