Commit 7578114
Add Spot/On-demand price to table-wide output irrespective of the price 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 <mikedball@gmail.com>
* rename aZones var to 'availabilityZones'
This was requested by @bwagner here:
#78 (comment)
Signed-off-by: Mike Ball <mikedball@gmail.com>
* 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 <mikedball@gmail.com>
* 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 <mikedball@gmail.com>
* remove invalid 'FIXME' code comment
This issue is now resolved.
Signed-off-by: Mike Ball <mikedball@gmail.com>
* commit `go mod tidy` results
Signed-off-by: Mike Ball <mikedball@gmail.com>
* 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 <mikedball@gmail.com>
* report received value in test output
This seeks to make the specifics of test failures a bit more clear.
Signed-off-by: Mike Ball <mikedball@gmail.com>
* 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 <mikedball@gmail.com>
* 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 <mikedball@gmail.com>
Co-authored-by: Krishna Birla <krishna.birla@cloudera.com>1 parent 4448edf commit 7578114
File tree
8 files changed
+217
-106
lines changed- cmd
- pkg
- ec2pricing
- selector
- outputs
8 files changed
+217
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
193 | 212 | | |
194 | | - | |
| 213 | + | |
195 | 214 | | |
196 | 215 | | |
197 | 216 | | |
| |||
252 | 271 | | |
253 | 272 | | |
254 | 273 | | |
255 | | - | |
256 | 274 | | |
257 | 275 | | |
258 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
58 | 80 | | |
59 | 81 | | |
60 | 82 | | |
| |||
67 | 89 | | |
68 | 90 | | |
69 | 91 | | |
70 | | - | |
| 92 | + | |
71 | 93 | | |
72 | 94 | | |
73 | 95 | | |
74 | | - | |
| 96 | + | |
75 | 97 | | |
76 | 98 | | |
77 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
78 | 104 | | |
79 | | - | |
80 | 105 | | |
81 | 106 | | |
82 | 107 | | |
83 | 108 | | |
84 | 109 | | |
85 | 110 | | |
86 | 111 | | |
87 | | - | |
88 | | - | |
| 112 | + | |
| 113 | + | |
89 | 114 | | |
90 | 115 | | |
91 | | - | |
| 116 | + | |
92 | 117 | | |
93 | 118 | | |
94 | 119 | | |
| |||
113 | 138 | | |
114 | 139 | | |
115 | 140 | | |
116 | | - | |
| 141 | + | |
117 | 142 | | |
118 | 143 | | |
119 | 144 | | |
| |||
134 | 159 | | |
135 | 160 | | |
136 | 161 | | |
137 | | - | |
| 162 | + | |
138 | 163 | | |
139 | 164 | | |
140 | 165 | | |
141 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
142 | 172 | | |
143 | 173 | | |
144 | 174 | | |
| |||
154 | 184 | | |
155 | 185 | | |
156 | 186 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 187 | | |
163 | | - | |
164 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
165 | 191 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
171 | 198 | | |
172 | 199 | | |
173 | 200 | | |
174 | | - | |
175 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
176 | 206 | | |
177 | 207 | | |
178 | 208 | | |
| |||
182 | 212 | | |
183 | 213 | | |
184 | 214 | | |
185 | | - | |
| 215 | + | |
186 | 216 | | |
187 | 217 | | |
188 | 218 | | |
| |||
192 | 222 | | |
193 | 223 | | |
194 | 224 | | |
195 | | - | |
| 225 | + | |
196 | 226 | | |
197 | | - | |
198 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
199 | 232 | | |
200 | 233 | | |
201 | 234 | | |
202 | | - | |
| 235 | + | |
203 | 236 | | |
204 | 237 | | |
205 | 238 | | |
| |||
208 | 241 | | |
209 | 242 | | |
210 | 243 | | |
211 | | - | |
212 | | - | |
| 244 | + | |
| 245 | + | |
213 | 246 | | |
| 247 | + | |
214 | 248 | | |
| 249 | + | |
215 | 250 | | |
216 | 251 | | |
217 | 252 | | |
218 | 253 | | |
219 | 254 | | |
220 | 255 | | |
221 | 256 | | |
222 | | - | |
223 | | - | |
224 | | - | |
| 257 | + | |
| 258 | + | |
225 | 259 | | |
226 | 260 | | |
227 | 261 | | |
| |||
234 | 268 | | |
235 | 269 | | |
236 | 270 | | |
237 | | - | |
| 271 | + | |
| 272 | + | |
238 | 273 | | |
239 | | - | |
240 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
241 | 277 | | |
242 | 278 | | |
243 | | - | |
| 279 | + | |
244 | 280 | | |
245 | 281 | | |
246 | 282 | | |
247 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
248 | 290 | | |
249 | 291 | | |
250 | 292 | | |
| |||
0 commit comments