@@ -129,6 +129,80 @@ func TestValidateMachinePool(t *testing.T) {
129129 },
130130 expected : `^test-path\.authentication: Invalid value: \"foobarbaz\": must be either Required or Optional$` ,
131131 },
132+ {
133+ name : "valid root volume throughput, within allowed range" ,
134+ pool : & aws.MachinePool {
135+ EC2RootVolume : aws.EC2RootVolume {
136+ Type : "gp3" ,
137+ Size : 100 ,
138+ Throughput : ptr .To (int32 (1200 )),
139+ },
140+ },
141+ },
142+ {
143+ name : "valid root volume throughput, nil or unspecified" ,
144+ pool : & aws.MachinePool {
145+ EC2RootVolume : aws.EC2RootVolume {
146+ Type : "gp3" ,
147+ Size : 100 ,
148+ },
149+ },
150+ },
151+ {
152+ name : "invalid root volume throughput, below minimum" ,
153+ pool : & aws.MachinePool {
154+ EC2RootVolume : aws.EC2RootVolume {
155+ Type : "gp3" ,
156+ Size : 100 ,
157+ Throughput : ptr .To (int32 (124 )),
158+ },
159+ },
160+ expected : `^test-path\.throughput: Invalid value: 124: throughput must be between 125 MiB/s and 2000 MiB/s$` ,
161+ },
162+ {
163+ name : "invalid root volume throughput, above maximum" ,
164+ pool : & aws.MachinePool {
165+ EC2RootVolume : aws.EC2RootVolume {
166+ Type : "gp3" ,
167+ Size : 100 ,
168+ Throughput : ptr .To (int32 (2001 )),
169+ },
170+ },
171+ expected : `^test-path\.throughput: Invalid value: 2001: throughput must be between 125 MiB/s and 2000 MiB/s$` ,
172+ },
173+ {
174+ name : "invalid root volume throughput, zero" ,
175+ pool : & aws.MachinePool {
176+ EC2RootVolume : aws.EC2RootVolume {
177+ Type : "gp3" ,
178+ Size : 100 ,
179+ Throughput : ptr .To (int32 (0 )),
180+ },
181+ },
182+ expected : `^test-path\.throughput: Invalid value: 0: throughput must be between 125 MiB/s and 2000 MiB/s$` ,
183+ },
184+ {
185+ name : "invalid root volume throughput, negative" ,
186+ pool : & aws.MachinePool {
187+ EC2RootVolume : aws.EC2RootVolume {
188+ Type : "gp3" ,
189+ Size : 100 ,
190+ Throughput : ptr .To (int32 (- 100 )),
191+ },
192+ },
193+ expected : `^test-path\.throughput: Invalid value: -100: throughput must be between 125 MiB/s and 2000 MiB/s$` ,
194+ },
195+ {
196+ name : "invalid root volume throughput, unsupported volume type" ,
197+ pool : & aws.MachinePool {
198+ EC2RootVolume : aws.EC2RootVolume {
199+ Type : "gp2" ,
200+ Size : 100 ,
201+ Throughput : ptr .To (int32 (125 )),
202+ },
203+ },
204+ expected : `^test-path\.throughput: Invalid value: 125: throughput not supported for type gp2$` ,
205+ },
132206 }
133207 for _ , tc := range cases {
134208 t .Run (tc .name , func (t * testing.T ) {
0 commit comments