@@ -121,60 +121,20 @@ func TestAccDataSourceServerType_CompareWithPCU(t *testing.T) {
121
121
pcuAPI := product_catalog .NewPublicCatalogAPI (client )
122
122
steps := []resource.TestStep (nil )
123
123
124
- serversTypesToTestByZone := map [scw.Zone ][]string {
125
- scw .ZoneFrPar1 : {
126
- "COPARM1-2C-8G" ,
127
- "DEV1-M" ,
128
- "RENDER-S" ,
129
- "STARDUST1-S" ,
130
- },
131
- scw .ZoneFrPar2 : {
132
- "COPARM1-32C-128G" ,
133
- "DEV1-L" ,
134
- "GP1-M" ,
135
- "H100-SXM-2-80G" ,
136
- "PLAY2-MICRO" ,
137
- },
138
- scw .ZoneFrPar3 : {
139
- "GP1-S" ,
140
- "POP2-HM-16C-128G" ,
141
- "PRO2-XXS" ,
142
- },
143
- scw .ZoneNlAms1 : {
144
- "COPARM1-8C-32G" ,
145
- "GP1-XL" ,
146
- "PRO2-XS" ,
147
- },
148
- scw .ZoneNlAms2 : {
149
- "DEV1-XL" ,
150
- "POP2-HN-5" ,
151
- "PRO2-S" ,
152
- },
153
- scw .ZoneNlAms3 : {
154
- "PLAY2-NANO" ,
155
- "POP2-2C-8G" ,
156
- "PRO2-L" ,
157
- },
158
- scw .ZonePlWaw1 : {
159
- "DEV1-S" ,
160
- "GP1-L" ,
161
- "POP2-64C-256G" ,
162
- },
163
- scw .ZonePlWaw2 : {
164
- "GP1-XS" ,
165
- "H100-1-80G" ,
166
- "L4-1-24G" ,
167
- "L40S-4-48G" ,
168
- },
169
- scw .ZonePlWaw3 : {
170
- "PLAY2-PICO" ,
171
- "POP2-HC-32C-64G" ,
172
- "PRO2-M" ,
173
- },
124
+ serverTypeToTestByZone := map [scw.Zone ]string {
125
+ scw .ZoneFrPar1 : "RENDER-S" ,
126
+ scw .ZoneFrPar2 : "H100-SXM-2-80G" ,
127
+ scw .ZoneFrPar3 : "POP2-HM-16C-128G" ,
128
+ scw .ZoneNlAms1 : "COPARM1-8C-32G" ,
129
+ scw .ZoneNlAms2 : "DEV1-XL" ,
130
+ scw .ZoneNlAms3 : "PLAY2-NANO" ,
131
+ scw .ZonePlWaw1 : "GP1-L" ,
132
+ scw .ZonePlWaw2 : "L4-1-24G" ,
133
+ scw .ZonePlWaw3 : "PRO2-M" ,
174
134
}
175
135
176
- for zone , serverTypesToTest := range serversTypesToTestByZone {
177
- // List all available server types in selected zone
136
+ for zone , serverTypeToTest := range serverTypeToTestByZone {
137
+ // List all available server types in the zone to test
178
138
pcuInstances , err := pcuAPI .ListPublicCatalogProducts (& product_catalog.PublicCatalogAPIListPublicCatalogProductsRequest {
179
139
ProductTypes : []product_catalog.ListPublicCatalogProductsRequestProductType {
180
140
product_catalog .ListPublicCatalogProductsRequestProductTypeInstance ,
@@ -185,61 +145,59 @@ func TestAccDataSourceServerType_CompareWithPCU(t *testing.T) {
185
145
t .Fatal (err )
186
146
}
187
147
188
- // Look for each server type to be tested in the zone in the PCU
189
- for _ , serverTypeToTest := range serverTypesToTest {
190
- for _ , pcuInstance := range pcuInstances .Products {
191
- if pcuInstance .Properties .Instance .OfferID != serverTypeToTest {
192
- continue
193
- }
148
+ // Look for the server type to test in the PCU
149
+ for _ , pcuInstance := range pcuInstances .Products {
150
+ if pcuInstance .Properties .Instance .OfferID != serverTypeToTest {
151
+ continue
152
+ }
194
153
195
- // Fetch expected values from the PCU to be compared with the data source's info
196
- datasourceTFName := "data.scaleway_instance_server_type." + serverTypeToTest
197
- hardwareSpecs := pcuInstance .Properties .Hardware
154
+ // Fetch expected values from the PCU to be compared with the data source's info
155
+ datasourceTFName := "data.scaleway_instance_server_type." + serverTypeToTest
156
+ hardwareSpecs := pcuInstance .Properties .Hardware
198
157
199
- expectedArch := ""
158
+ expectedArch := ""
200
159
201
- switch hardwareSpecs .CPU .Arch {
202
- case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchX64 :
203
- expectedArch = instance .ArchX86_64 .String ()
204
- case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchArm64 :
205
- expectedArch = instance .ArchArm64 .String ()
206
- case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchUnknownArch :
207
- expectedArch = instance .ArchUnknownArch .String ()
208
- }
160
+ switch hardwareSpecs .CPU .Arch {
161
+ case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchX64 :
162
+ expectedArch = instance .ArchX86_64 .String ()
163
+ case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchArm64 :
164
+ expectedArch = instance .ArchArm64 .String ()
165
+ case product_catalog .PublicCatalogProductPropertiesHardwareCPUArchUnknownArch :
166
+ expectedArch = instance .ArchUnknownArch .String ()
167
+ }
209
168
210
- expectedCPU := strconv .FormatUint (uint64 (hardwareSpecs .CPU .Threads ), 10 )
211
- expectedRAM := hardwareSpecs .RAM .Size .String ()
169
+ expectedCPU := strconv .FormatUint (uint64 (hardwareSpecs .CPU .Threads ), 10 )
170
+ expectedRAM := hardwareSpecs .RAM .Size .String ()
212
171
213
- expectedGPU := "0"
214
- if hardwareSpecs .Gpu != nil {
215
- expectedGPU = strconv .FormatUint (uint64 (hardwareSpecs .Gpu .Count ), 10 )
216
- }
172
+ expectedGPU := "0"
173
+ if hardwareSpecs .Gpu != nil {
174
+ expectedGPU = strconv .FormatUint (uint64 (hardwareSpecs .Gpu .Count ), 10 )
175
+ }
217
176
218
- expectedInternalBandwidth := strconv .FormatUint (hardwareSpecs .Network .InternalBandwidth , 10 )
219
- expectedPublicBandwidth := strconv .FormatUint (hardwareSpecs .Network .PublicBandwidth , 10 )
177
+ expectedInternalBandwidth := strconv .FormatUint (hardwareSpecs .Network .InternalBandwidth , 10 )
178
+ expectedPublicBandwidth := strconv .FormatUint (hardwareSpecs .Network .PublicBandwidth , 10 )
220
179
221
- expectedHourlyPrice := strings .TrimPrefix (pcuInstance .Price .RetailPrice .String (), "€ " )
180
+ expectedHourlyPrice := strings .TrimPrefix (pcuInstance .Price .RetailPrice .String (), "€ " )
222
181
223
- // Create test step
224
- steps = append (steps , resource.TestStep {
225
- Config : fmt .Sprintf (`
182
+ // Create test step
183
+ steps = append (steps , resource.TestStep {
184
+ Config : fmt .Sprintf (`
226
185
data "scaleway_instance_server_type" "%[1]s" {
227
186
name = "%[1]s"
228
187
zone = "%[2]s"
229
188
}` , serverTypeToTest , zone ),
230
- Check : resource .ComposeTestCheckFunc (
231
- resource .TestCheckResourceAttr (datasourceTFName , "name" , serverTypeToTest ),
232
- resource .TestCheckResourceAttr (datasourceTFName , "zone" , zone .String ()),
233
- resource .TestCheckResourceAttr (datasourceTFName , "arch" , expectedArch ),
234
- resource .TestCheckResourceAttr (datasourceTFName , "cpu" , expectedCPU ),
235
- resource .TestCheckResourceAttr (datasourceTFName , "ram" , expectedRAM ),
236
- resource .TestCheckResourceAttr (datasourceTFName , "gpu" , expectedGPU ),
237
- resource .TestCheckResourceAttr (datasourceTFName , "network.0.internal_bandwidth" , expectedInternalBandwidth ),
238
- resource .TestCheckResourceAttr (datasourceTFName , "network.0.public_bandwidth" , expectedPublicBandwidth ),
239
- resource .TestCheckResourceAttr (datasourceTFName , "hourly_price" , expectedHourlyPrice ),
240
- ),
241
- })
242
- }
189
+ Check : resource .ComposeTestCheckFunc (
190
+ resource .TestCheckResourceAttr (datasourceTFName , "name" , serverTypeToTest ),
191
+ resource .TestCheckResourceAttr (datasourceTFName , "zone" , zone .String ()),
192
+ resource .TestCheckResourceAttr (datasourceTFName , "arch" , expectedArch ),
193
+ resource .TestCheckResourceAttr (datasourceTFName , "cpu" , expectedCPU ),
194
+ resource .TestCheckResourceAttr (datasourceTFName , "ram" , expectedRAM ),
195
+ resource .TestCheckResourceAttr (datasourceTFName , "gpu" , expectedGPU ),
196
+ resource .TestCheckResourceAttr (datasourceTFName , "network.0.internal_bandwidth" , expectedInternalBandwidth ),
197
+ resource .TestCheckResourceAttr (datasourceTFName , "network.0.public_bandwidth" , expectedPublicBandwidth ),
198
+ resource .TestCheckResourceAttr (datasourceTFName , "hourly_price" , expectedHourlyPrice ),
199
+ ),
200
+ })
243
201
}
244
202
}
245
203
0 commit comments