Skip to content

Commit ddb385b

Browse files
committed
lint and update tests
1 parent c16118a commit ddb385b

18 files changed

+4708
-8109
lines changed

internal/services/k8s/pool_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,18 +476,18 @@ func TestAccPool_PublicIPDisabled(t *testing.T) {
476476
resource "scaleway_vpc_private_network" "public_ip" {
477477
name = "test-k8s-public-ip"
478478
}
479+
479480
resource "scaleway_vpc_public_gateway" "public_ip" {
480481
name = "test-k8s-public-ip"
481482
type = "VPC-GW-S"
482483
}
483-
resource "scaleway_vpc_public_gateway_dhcp" "public_ip" {
484-
subnet = "192.168.0.0/22"
485-
push_default_route = true
486-
}
484+
487485
resource "scaleway_vpc_gateway_network" "public_ip" {
488486
gateway_id = scaleway_vpc_public_gateway.public_ip.id
489487
private_network_id = scaleway_vpc_private_network.public_ip.id
490-
dhcp_id = scaleway_vpc_public_gateway_dhcp.public_ip.id
488+
ipam_config {
489+
push_default_route = true
490+
}
491491
}
492492
493493
resource "scaleway_k8s_cluster" "public_ip" {

internal/services/k8s/testdata/pool-public-ip-disabled.cassette.yaml

Lines changed: 2910 additions & 2563 deletions
Large diffs are not rendered by default.

internal/services/lb/lb_test.go

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ import (
1212
lbSDK "github.com/scaleway/scaleway-sdk-go/api/lb/v1"
1313
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
15-
instancechecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/instance/testfuncs"
1615
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/lb"
17-
lbchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/lb/testfuncs"
1816
vpcchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/vpc/testfuncs"
19-
vpcgwchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/vpcgw/testfuncs"
2017
)
2118

2219
func TestAccLB_Basic(t *testing.T) {
@@ -361,106 +358,6 @@ func TestAccLB_Migrate(t *testing.T) {
361358
})
362359
}
363360

364-
func TestAccLB_WithPrivateNetworksOnDHCPConfig(t *testing.T) {
365-
tt := acctest.NewTestTools(t)
366-
defer tt.Cleanup()
367-
resource.ParallelTest(t, resource.TestCase{
368-
PreCheck: func() { acctest.PreCheck(t) },
369-
ProviderFactories: tt.ProviderFactories,
370-
CheckDestroy: resource.ComposeTestCheckFunc(
371-
instancechecks.IsServerDestroyed(tt),
372-
isLbDestroyed(tt),
373-
lbchecks.IsIPDestroyed(tt),
374-
vpcgwchecks.IsGatewayNetworkDestroyed(tt),
375-
vpcchecks.CheckPrivateNetworkDestroy(tt),
376-
vpcgwchecks.IsDHCPDestroyed(tt),
377-
vpcgwchecks.IsGatewayDestroyed(tt),
378-
vpcgwchecks.IsIPDestroyed(tt),
379-
),
380-
Steps: []resource.TestStep{
381-
{
382-
Config: `
383-
### IP for Public Gateway
384-
resource "scaleway_vpc_public_gateway_ip" "main" {
385-
}
386-
387-
### The Public Gateway with the Attached IP
388-
resource "scaleway_vpc_public_gateway" "main" {
389-
name = "tf-test-public-gw"
390-
type = "VPC-GW-S"
391-
ip_id = scaleway_vpc_public_gateway_ip.main.id
392-
}
393-
394-
### Scaleway Private Network
395-
resource "scaleway_vpc_private_network" "main" {
396-
name = "private network with a DHCP config"
397-
}
398-
399-
### DHCP Space of VPC
400-
resource "scaleway_vpc_public_gateway_dhcp" "main" {
401-
subnet = "10.0.0.0/24"
402-
}
403-
404-
### VPC Gateway Network
405-
resource "scaleway_vpc_gateway_network" "main" {
406-
gateway_id = scaleway_vpc_public_gateway.main.id
407-
private_network_id = scaleway_vpc_private_network.main.id
408-
dhcp_id = scaleway_vpc_public_gateway_dhcp.main.id
409-
cleanup_dhcp = true
410-
enable_masquerade = true
411-
}
412-
413-
### Scaleway Instance
414-
resource "scaleway_instance_server" "main" {
415-
name = "Scaleway Terraform Provider"
416-
type = "DEV1-S"
417-
image = "debian_bullseye"
418-
enable_ipv6 = false
419-
420-
private_network {
421-
pn_id = scaleway_vpc_private_network.main.id
422-
}
423-
}
424-
425-
### IP for LB IP
426-
resource scaleway_lb_ip ip01 {
427-
}
428-
429-
resource scaleway_lb lb01 {
430-
ip_id = scaleway_lb_ip.ip01.id
431-
name = "test-lb-with-private-network-configs"
432-
type = "LB-S"
433-
434-
private_network {
435-
private_network_id = scaleway_vpc_private_network.main.id
436-
dhcp_config = true
437-
}
438-
439-
depends_on = [scaleway_vpc_public_gateway.main]
440-
}
441-
`,
442-
Check: resource.ComposeTestCheckFunc(
443-
isLbPresent(tt, "scaleway_lb.lb01"),
444-
isIPPresent(tt, "scaleway_lb_ip.ip01"),
445-
resource.TestCheckResourceAttrSet("scaleway_vpc_private_network.main", "name"),
446-
resource.TestCheckResourceAttrPair(
447-
"scaleway_lb.lb01", "private_network.0.private_network_id",
448-
"scaleway_vpc_private_network.main", "id"),
449-
resource.TestCheckResourceAttrPair(
450-
"scaleway_instance_server.main", "private_network.0.pn_id",
451-
"scaleway_vpc_private_network.main", "id"),
452-
resource.TestCheckResourceAttr("scaleway_lb.lb01",
453-
"private_network.0.status", lbSDK.PrivateNetworkStatusReady.String()),
454-
resource.TestCheckResourceAttr("scaleway_lb.lb01",
455-
"private_network.0.dhcp_config", "true"),
456-
resource.TestCheckResourceAttr("scaleway_lb.lb01",
457-
"private_network.0.status", lbSDK.PrivateNetworkStatusReady.String()),
458-
),
459-
},
460-
},
461-
})
462-
}
463-
464361
func TestAccLB_WithPrivateNetworksIPAMIDs(t *testing.T) {
465362
tt := acctest.NewTestTools(t)
466363
defer tt.Cleanup()

internal/services/rdb/instance_test.go

Lines changed: 1 addition & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -314,192 +314,6 @@ func TestAccInstance_Capitalize(t *testing.T) {
314314
})
315315
}
316316

317-
func TestAccInstance_PrivateNetwork(t *testing.T) {
318-
tt := acctest.NewTestTools(t)
319-
defer tt.Cleanup()
320-
321-
latestEngineVersion := rdbchecks.GetLatestEngineVersion(tt, postgreSQLEngineName)
322-
323-
resource.ParallelTest(t, resource.TestCase{
324-
PreCheck: func() { acctest.PreCheck(t) },
325-
ProviderFactories: tt.ProviderFactories,
326-
CheckDestroy: rdbchecks.IsInstanceDestroyed(tt),
327-
Steps: []resource.TestStep{
328-
{
329-
Config: `
330-
resource scaleway_vpc_private_network pn01 {
331-
name = "my_private_network"
332-
region= "nl-ams"
333-
}
334-
`,
335-
Check: resource.ComposeTestCheckFunc(
336-
resource.TestCheckResourceAttr("scaleway_vpc_private_network.pn01", "name", "my_private_network"),
337-
),
338-
},
339-
{
340-
Config: fmt.Sprintf(`
341-
resource scaleway_vpc_private_network pn01 {
342-
name = "my_private_network"
343-
region= "nl-ams"
344-
}
345-
346-
resource scaleway_rdb_instance main {
347-
name = "test-rdb-private-network"
348-
node_type = "db-dev-s"
349-
engine = %q
350-
is_ha_cluster = false
351-
disable_backup = true
352-
user_name = "my_initial_user"
353-
password = "thiZ_is_v&ry_s3cret"
354-
region= "nl-ams"
355-
tags = [ "terraform-test", "scaleway_rdb_instance", "volume", "rdb_pn" ]
356-
volume_type = "bssd"
357-
volume_size_in_gb = 10
358-
private_network {
359-
ip_net = "192.168.1.42/24"
360-
pn_id = "${scaleway_vpc_private_network.pn01.id}"
361-
}
362-
}
363-
`, latestEngineVersion),
364-
Check: resource.ComposeTestCheckFunc(
365-
isInstancePresent(tt, "scaleway_rdb_instance.main"),
366-
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "private_network.#", "1"),
367-
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "private_network.0.ip_net", "192.168.1.42/24"),
368-
),
369-
},
370-
{
371-
Config: fmt.Sprintf(`
372-
resource scaleway_vpc_private_network pn01 {
373-
name = "my_private_network_to_be_replaced"
374-
region= "nl-ams"
375-
}
376-
377-
resource scaleway_vpc_private_network pn02 {
378-
name = "my_private_network"
379-
region= "nl-ams"
380-
}
381-
382-
resource scaleway_rdb_instance main {
383-
name = "test-rdb-private-network"
384-
node_type = "db-dev-s"
385-
engine = %q
386-
is_ha_cluster = false
387-
disable_backup = true
388-
user_name = "my_initial_user"
389-
password = "thiZ_is_v&ry_s3cret"
390-
region= "nl-ams"
391-
tags = [ "terraform-test", "scaleway_rdb_instance", "volume", "rdb_pn" ]
392-
volume_type = "bssd"
393-
volume_size_in_gb = 10
394-
private_network {
395-
ip_net = "192.168.1.254/24"
396-
pn_id = "${scaleway_vpc_private_network.pn02.id}"
397-
}
398-
}
399-
`, latestEngineVersion),
400-
Check: resource.ComposeTestCheckFunc(
401-
isInstancePresent(tt, "scaleway_rdb_instance.main"),
402-
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "private_network.#", "1"),
403-
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "private_network.0.ip_net", "192.168.1.254/24"),
404-
),
405-
},
406-
{
407-
Config: fmt.Sprintf(`
408-
resource scaleway_vpc_private_network pn01 {
409-
name = "my_private_network_to_be_replaced"
410-
region= "nl-ams"
411-
}
412-
413-
resource scaleway_vpc_private_network pn02 {
414-
name = "my_private_network"
415-
region= "nl-ams"
416-
}
417-
418-
resource scaleway_vpc_public_gateway_dhcp main {
419-
subnet = "192.168.1.0/24"
420-
zone = "nl-ams-1"
421-
}
422-
423-
resource scaleway_vpc_public_gateway_ip main {
424-
zone = "nl-ams-1"
425-
}
426-
427-
resource scaleway_vpc_public_gateway main {
428-
name = "foobar"
429-
type = "VPC-GW-S"
430-
zone = "nl-ams-1"
431-
ip_id = scaleway_vpc_public_gateway_ip.main.id
432-
}
433-
434-
resource scaleway_vpc_public_gateway_pat_rule main {
435-
gateway_id = scaleway_vpc_public_gateway.main.id
436-
private_ip = scaleway_vpc_public_gateway_dhcp.main.address
437-
private_port = scaleway_rdb_instance.main.private_network.0.port
438-
public_port = 42
439-
protocol = "both"
440-
zone = "nl-ams-1"
441-
depends_on = [scaleway_vpc_gateway_network.main, scaleway_vpc_private_network.pn02]
442-
}
443-
444-
resource scaleway_vpc_gateway_network main {
445-
gateway_id = scaleway_vpc_public_gateway.main.id
446-
private_network_id = scaleway_vpc_private_network.pn02.id
447-
dhcp_id = scaleway_vpc_public_gateway_dhcp.main.id
448-
cleanup_dhcp = true
449-
enable_masquerade = true
450-
zone = "nl-ams-1"
451-
depends_on = [scaleway_vpc_public_gateway_ip.main, scaleway_vpc_private_network.pn02]
452-
}
453-
454-
resource scaleway_rdb_instance main {
455-
name = "test-rdb-private-network"
456-
node_type = "db-dev-s"
457-
engine = %q
458-
is_ha_cluster = false
459-
disable_backup = true
460-
user_name = "my_initial_user"
461-
password = "thiZ_is_v&ry_s3cret"
462-
region= "nl-ams"
463-
tags = [ "terraform-test", "scaleway_rdb_instance", "volume", "rdb_pn" ]
464-
volume_type = "bssd"
465-
volume_size_in_gb = 10
466-
private_network {
467-
ip_net = "192.168.1.254/24" #pool high
468-
pn_id = "${scaleway_vpc_private_network.pn02.id}"
469-
}
470-
}
471-
`, latestEngineVersion),
472-
Check: resource.ComposeTestCheckFunc(
473-
isInstancePresent(tt, "scaleway_rdb_instance.main"),
474-
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "private_network.0.ip_net", "192.168.1.254/24"),
475-
),
476-
},
477-
{
478-
Config: fmt.Sprintf(`
479-
resource scaleway_vpc_private_network pn02 {
480-
name = "my_private_network"
481-
region= "nl-ams"
482-
}
483-
484-
resource scaleway_rdb_instance main {
485-
name = "test-rdb-private-network"
486-
node_type = "db-dev-s"
487-
engine = %q
488-
is_ha_cluster = false
489-
disable_backup = true
490-
user_name = "my_initial_user"
491-
password = "thiZ_is_v&ry_s3cret"
492-
region= "nl-ams"
493-
tags = [ "terraform-test", "scaleway_rdb_instance", "volume", "rdb_pn" ]
494-
volume_type = "bssd"
495-
volume_size_in_gb = 10
496-
}
497-
`, latestEngineVersion),
498-
},
499-
},
500-
})
501-
}
502-
503317
func TestAccInstance_PrivateNetworkUpdate(t *testing.T) {
504318
tt := acctest.NewTestTools(t)
505319
defer tt.Cleanup()
@@ -696,7 +510,7 @@ func TestAccInstance_PrivateNetworkUpdate(t *testing.T) {
696510
}
697511

698512
// TODO: Refactor this test when rdb is ipam-compatible
699-
func TestAccInstance_PrivateNetwork_DHCP(t *testing.T) {
513+
func TestAccInstance_PrivateNetwork(t *testing.T) {
700514
tt := acctest.NewTestTools(t)
701515
defer tt.Cleanup()
702516

internal/services/rdb/testdata/instance-private-network.cassette.yaml

Lines changed: 842 additions & 2804 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package vpc

0 commit comments

Comments
 (0)