-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Spot/On-demand price to table-wide output irrespective of the pri…
…ce filters (#106) * Add Spot/On-demand price to table-wide output irrespective of the price filters * Minor clean-up * adjust ec2pricing imports * remove the importing of un-used Lightsail packages, as [requested by @bwagner](#78 (comment)) * move non-standard lib imports to their own stanza, as [requested by @bwagner](#78 (comment)) Signed-off-by: Mike Ball <[email protected]> * rename aZones var to 'availabilityZones' This was requested by @bwagner here: #78 (comment) Signed-off-by: Mike Ball <[email protected]> * rename fields/methods `*CacheUTC` Per code review from @bwagner, this renames various methods and fields to be `*CacheUTC` rather than `*CachedUTC`: #78 (comment) * update selector to use `LastSpotCacheUTC()` Previously, `selector` was incorrectly using the old `LastSpotCachedUTC` method name. * make `ec2PricingMock` proper `EC2PricingIface` * remove invalid 'FIXME' comment This is now fixed, as the Pricing client is always initialized to us-east-1. Signed-off-by: Mike Ball <[email protected]> * move error check inside loop Per [code review feedback](#106 (comment)), the error checking should appear within the `range pricingOutput.PriceList`. Signed-off-by: Mike Ball <[email protected]> * remove invalid 'FIXME' code comment This issue is now resolved. Signed-off-by: Mike Ball <[email protected]> * commit `go mod tidy` results Signed-off-by: Mike Ball <[email protected]> * protect against panics during unit tests This protects against panics like the following, for example: ``` --- FAIL: TestFilter_X8664_AMD64 (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x153ec41] goroutine 153 [running]: testing.tRunner.func1.2({0x1613ee0, 0x1cdfe70}) /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1209 +0x24e testing.tRunner.func1() /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1212 +0x218 panic({0x1613ee0, 0x1cdfe70}) /usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:1038 +0x215 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.rawFilter.func1(0x100e6e7, 0x68) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:192 +0x241 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector_test.mockedEC2.DescribeInstanceTypesPages(...) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector_test.go:70 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.rawFilter({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:184 +0x5c2 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.FilterWithOutput({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}, ...) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:116 +0xc5 github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector.Selector.Filter({{_, _}, {_, _}, {_}}, {0x0, 0x0, 0x0, 0xc0003854a0, 0x0, ...}) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector.go:98 +0xcc github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector_test.TestFilter_X8664_AMD64(0xc0002de820) /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector/pkg/selector/selector_test.go:583 +0x14e testing.tRunner(0xc00059b520, 0x177e1b0) /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x102 created by testing.(*T).Run /usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x35a exit status 2 ``` Signed-off-by: Mike Ball <[email protected]> * report received value in test output This seeks to make the specifics of test failures a bit more clear. Signed-off-by: Mike Ball <[email protected]> * run `go mod tidy` This addresses the following: ``` $ make unit-test go test -bench=. /Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector//... -v -coverprofile=coverage.out -covermode=atomic -outputdir=/Users/mball/dev/go/src/github.com/aws/amazon-ec2-instance-selector//build go: updates to go.mod needed; to update it: go mod tidy make: *** [unit-test] Error 1 ``` Signed-off-by: Mike Ball <[email protected]> * fix failing selector.Filter unit tests By populating the `lastOnDemandCacheUTC` and `lastSpotCacheUTC` fields with non-`nil` values, the `Filter` tests exercise relevant code paths. Note that this doesn't change @krishna-birla's original implementation (see PR #78) or vision; it only ensures the tests pass. Signed-off-by: Mike Ball <[email protected]> Co-authored-by: Krishna Birla <[email protected]>
- Loading branch information
Showing
8 changed files
with
217 additions
and
106 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
### Go ### | ||
# IDE | ||
.idea | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
|
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
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
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
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
Oops, something went wrong.