Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions stackit/internal/services/iaas/iaas_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func TestAccNetworkV1Min(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["project_id"])),
resource.TestCheckResourceAttr("stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["name"])),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "public_ip"),
),
},
Expand All @@ -541,7 +541,7 @@ func TestAccNetworkV1Min(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["project_id"])),
resource.TestCheckResourceAttr("data.stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["name"])),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "public_ip"),
),
},
Expand All @@ -567,7 +567,7 @@ func TestAccNetworkV1Min(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["project_id"])),
resource.TestCheckResourceAttr("stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMin["name"])),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "public_ip"),
),
},
Expand Down Expand Up @@ -599,7 +599,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix_length"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefix", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefixes.#", "1"),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["routed"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["label"])),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix", "public_ip"),
Expand All @@ -614,7 +614,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "ipv4_nameservers.1", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_nameserver_1"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix_length"])),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix_length", "ipv4_prefix"),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["routed"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["label"])),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix_length", "public_ip"),
Expand Down Expand Up @@ -650,7 +650,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network_prefix", "ipv4_prefix", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix"])),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix_length"])),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix", "ipv4_prefixes.#", "1"),
resource.TestCheckResourceAttrSet("data.stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("data.stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["routed"])),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["label"])),

Expand All @@ -664,7 +664,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network_prefix_length", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["ipv4_prefix_length"])),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix_length", "ipv4_prefixes.#", "1"),
resource.TestCheckResourceAttrSet("data.stackit_network.network_prefix_length", "ipv4_prefix"),
resource.TestCheckResourceAttrSet("data.stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("data.stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix_length", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["routed"])),
resource.TestCheckResourceAttr("data.stackit_network.network_prefix_length", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMax["label"])),
),
Expand Down Expand Up @@ -745,7 +745,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefix", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["ipv4_prefix"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["ipv4_prefix_length"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "ipv4_prefixes.#", "1"),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["routed"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["label"])),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix", "public_ip"),
Expand All @@ -760,7 +760,7 @@ func TestAccNetworkV1Max(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "ipv4_nameservers.1", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["ipv4_nameserver_1"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "ipv4_prefix_length", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["ipv4_prefix_length"])),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix_length", "ipv4_prefix"),
resource.TestCheckResourceAttrSet("stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix_length", "ipv6_prefixes.#"),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "routed", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["routed"])),
resource.TestCheckResourceAttr("stackit_network.network_prefix_length", "labels.acc-test", testutil.ConvertConfigVariable(testConfigNetworkV1VarsMaxUpdated["label"])),
resource.TestCheckNoResourceAttr("stackit_network.network_prefix_length", "public_ip"),
Expand Down Expand Up @@ -3110,7 +3110,7 @@ func TestAccNetworkInterfaceMin(t *testing.T) {
resource.TestCheckNoResourceAttr("stackit_network_interface.network_interface", "name"),
resource.TestCheckResourceAttr("stackit_network_interface.network_interface", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMin["project_id"])),
resource.TestCheckResourceAttrSet("stackit_network_interface.network_interface", "ipv4"),
resource.TestCheckResourceAttrSet("stackit_network_interface.network_interface", "allowed_addresses.#"),
resource.TestCheckNoResourceAttr("stackit_network_interface.network_interface", "allowed_addresses.#"),
resource.TestCheckResourceAttr("stackit_network_interface.network_interface", "security", "true"),
resource.TestCheckResourceAttr("stackit_network_interface.network_interface", "labels.#", "0"),
resource.TestCheckResourceAttr("stackit_network_interface.network_interface", "security_group_ids.#", "0"),
Expand All @@ -3127,7 +3127,7 @@ func TestAccNetworkInterfaceMin(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMin["project_id"])),
resource.TestCheckResourceAttr("stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMin["name"])),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "public_ip"),

// Public ip
Expand Down Expand Up @@ -3180,7 +3180,7 @@ func TestAccNetworkInterfaceMin(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMin["project_id"])),
resource.TestCheckResourceAttr("data.stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMin["name"])),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "public_ip"),

// Public ip
Expand Down Expand Up @@ -3298,7 +3298,7 @@ func TestAccNetworkInterfaceMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMax["project_id"])),
resource.TestCheckResourceAttr("stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMax["name"])),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "public_ip"),

// Public ip
Expand Down Expand Up @@ -3407,7 +3407,7 @@ func TestAccNetworkInterfaceMax(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMax["project_id"])),
resource.TestCheckResourceAttr("data.stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMax["name"])),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("data.stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("data.stackit_network.network", "public_ip"),

// Public ip
Expand Down Expand Up @@ -3603,7 +3603,7 @@ func TestAccNetworkInterfaceMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMaxUpdated["project_id"])),
resource.TestCheckResourceAttr("stackit_network.network", "name", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMaxUpdated["name"])),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv4_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckNoResourceAttr("stackit_network.network", "ipv6_prefixes.#"),
resource.TestCheckResourceAttrSet("stackit_network.network", "public_ip"),

// Public ip
Expand All @@ -3629,10 +3629,10 @@ func TestAccNetworkInterfaceMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_public_ip.public_ip_simple", "project_id", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMaxUpdated["project_id"])),
resource.TestCheckResourceAttrSet("stackit_public_ip.public_ip_simple", "public_ip_id"),
resource.TestCheckResourceAttrSet("stackit_public_ip.public_ip_simple", "ip"),
resource.TestCheckResourceAttrPair(
"stackit_public_ip.public_ip_simple", "network_interface_id",
"stackit_network_interface.network_interface_simple", "network_interface_id",
),
// The network gets re-created, which triggers a re-create of the 'network_interface_simple' NIC, which leads the 'stackit_public_ip_associate' resource to update the
// networkInterfaceId of the public IP. All that without the public ip resource noticing. So the public ip resource will still hold the networkInterfaceId of the old NIC.
// So we can only check that *some* network interface ID is set here, but can't compare it with the networkInterfaceId of the NIC resource (old vs. new NIC id)
resource.TestCheckResourceAttrSet("stackit_public_ip.public_ip_simple", "network_interface_id"),
Comment on lines -3632 to +3635
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blame on you, this test case was the last time changed by me, so probably I mixed up something.
I think we should adjust the tests, to prevent the recreation of the network interfaces. Actually not to prevent the error you commented, but to test the intended case here is. This would be in my opinion, to check if the Update function of network interface works as expected.

func (r *networkInterfaceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform

With the current test cases, the update function isn't covered in the tests

resource.TestCheckResourceAttr("stackit_public_ip.public_ip_simple", "labels.%", "0"),

// Nic and public ip attach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func mapFields(ctx context.Context, networkResp *iaas.Network, model *networkMod
if networkResp.Prefixes == nil {
model.Prefixes = types.ListNull(types.StringType)
model.IPv4Prefixes = types.ListNull(types.StringType)
model.IPv4PrefixLength = types.Int64Null()
} else {
respPrefixes := *networkResp.Prefixes
prefixesTF, diags := types.ListValueFrom(ctx, types.StringType, respPrefixes)
Expand Down Expand Up @@ -322,10 +323,10 @@ func mapFields(ctx context.Context, networkResp *iaas.Network, model *networkMod
model.IPv6Nameservers = ipv6NameserversTF
}

model.IPv6PrefixLength = types.Int64Null()
model.IPv6Prefix = types.StringNull()
if networkResp.PrefixesV6 == nil || len(*networkResp.PrefixesV6) == 0 {
model.IPv6Prefixes = types.ListNull(types.StringType)
model.IPv6Prefix = types.StringNull()
model.IPv6PrefixLength = types.Int64Null()
} else {
respPrefixesV6 := *networkResp.PrefixesV6
prefixesV6TF, diags := types.ListValueFrom(ctx, types.StringType, respPrefixesV6)
Expand All @@ -337,7 +338,6 @@ func mapFields(ctx context.Context, networkResp *iaas.Network, model *networkMod
_, netmask, err := net.ParseCIDR(respPrefixesV6[0])
if err != nil {
// silently ignore parsing error for the netmask
model.IPv6PrefixLength = types.Int64Null()
} else {
ones, _ := netmask.Mask.Size()
model.IPv6PrefixLength = types.Int64Value(int64(ones))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ func mapFields(ctx context.Context, networkResp *iaasalpha.Network, model *netwo
if networkResp.Ipv4 == nil || networkResp.Ipv4.Prefixes == nil {
model.Prefixes = types.ListNull(types.StringType)
model.IPv4Prefixes = types.ListNull(types.StringType)
model.IPv4PrefixLength = types.Int64Null()
} else {
respPrefixes := *networkResp.Ipv4.Prefixes
prefixesTF, diags := types.ListValueFrom(ctx, types.StringType, respPrefixes)
Expand Down Expand Up @@ -341,6 +342,8 @@ func mapFields(ctx context.Context, networkResp *iaasalpha.Network, model *netwo
model.IPv6Nameservers = ipv6NameserversTF
}

model.IPv6PrefixLength = types.Int64Null()
model.IPv6Prefix = types.StringNull()
if networkResp.Ipv6 == nil || networkResp.Ipv6.Prefixes == nil {
model.IPv6Prefixes = types.ListNull(types.StringType)
} else {
Expand All @@ -354,7 +357,6 @@ func mapFields(ctx context.Context, networkResp *iaasalpha.Network, model *netwo
_, netmask, err := net.ParseCIDR(respPrefixesV6[0])
if err != nil {
// silently ignore parsing error for the netmask
model.IPv6PrefixLength = types.Int64Null()
} else {
ones, _ := netmask.Mask.Size()
model.IPv6PrefixLength = types.Int64Value(int64(ones))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ resource "stackit_volume" "volume_source" {
availability_zone = var.availability_zone
name = var.name
description = var.description
performance_class = var.performance_class
size = var.size
# TODO: commented out because bug on IaaS API side
#performance_class = var.performance_class
size = var.size
source = {
id = stackit_volume.volume_size.volume_id
type = "volume"
Expand Down
Loading