Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: server an vcpu test, debug logs #717

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Testing
- Fix template test
- Remove cpu_family from server test
- Fix server and vcpu server tests with multiple firewall rules

## 6.6.3
### Documentation
Expand Down
2 changes: 1 addition & 1 deletion ionoscloud/resource_cube_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ func resourceCubeServerUpdate(ctx context.Context, d *schema.ResourceData, meta
}

if errState := cloudapi.WaitForStateChange(ctx, meta, d, apiResponse, schema.TimeoutCreate); errState != nil {
return diag.FromErr(fmt.Errorf("an error occurred while waiting for state change dcId: %s server_id: %s nic_id %s ID: %s Response: %w", dcId, *server.Id, *nic.Id, firewallId, errState))
return diag.FromErr(fmt.Errorf("on cube update an error occurred while waiting for state change dcId: %s server_id: %s nic_id %s ID: %s Response: %w", dcId, *server.Id, *nic.Id, firewallId, errState))
}

if firewallId == "" && firewall.Id != nil {
Expand Down
32 changes: 16 additions & 16 deletions ionoscloud/resource_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,14 @@ func TestAccServerResolveImageNameAdd5FwRulesOnUpdate(t *testing.T) {
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.4.name", "test_server5"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.0.icmp_code", "5"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.0.icmp_type", "6"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_start", "24"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_end", "24"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_start", "25"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_end", "25"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_start", "26"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_end", "26"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_start", "27"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_end", "27"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_start", "204"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_end", "204"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_start", "205"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_end", "205"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_start", "206"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_end", "206"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_start", "207"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_end", "207"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.0.type", "INGRESS"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.1.type", "INGRESS"),
resource.TestCheckResourceAttr(constant.ServerResource+"."+constant.ServerTestResource, "nic.0.firewall.2.type", "INGRESS"),
Expand Down Expand Up @@ -1458,29 +1458,29 @@ resource ` + constant.ServerResource + ` ` + constant.ServerTestResource + ` {
protocol = "TCP"
name = "` + constant.ServerTestResource + `2"
type = "INGRESS"
port_range_start = 24
port_range_end = 24
port_range_start = 204
port_range_end = 204
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `3"
type = "INGRESS"
port_range_start = 25
port_range_end = 25
port_range_start = 205
port_range_end = 205
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `4"
type = "INGRESS"
port_range_start = 26
port_range_end = 26
port_range_start = 206
port_range_end = 206
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `5"
type = "EGRESS"
port_range_start = 27
port_range_end = 27
port_range_start = 207
port_range_end = 207
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions ionoscloud/resource_vcpu_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,14 @@ func TestAccServerVCPUResolveImageNameAdd5FwRulesOnUpdate(t *testing.T) {
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.4.name", "test_server5"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.0.icmp_code", "5"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.0.icmp_type", "6"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_start", "24"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_end", "24"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_start", "25"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_end", "25"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_start", "26"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_end", "26"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_start", "27"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_end", "27"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_start", "204"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.1.port_range_end", "204"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_start", "205"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.2.port_range_end", "205"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_start", "206"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.3.port_range_end", "206"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_start", "207"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.4.port_range_end", "207"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.0.type", "INGRESS"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.1.type", "INGRESS"),
resource.TestCheckResourceAttr(constant.ServerVCPUResource+"."+constant.ServerTestResource, "nic.0.firewall.2.type", "INGRESS"),
Expand Down Expand Up @@ -1348,29 +1348,29 @@ resource ` + constant.ServerVCPUResource + ` ` + constant.ServerTestResource + `
protocol = "TCP"
name = "` + constant.ServerTestResource + `2"
type = "INGRESS"
port_range_start = 24
port_range_end = 24
port_range_start = 204
port_range_end = 204
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `3"
type = "INGRESS"
port_range_start = 25
port_range_end = 25
port_range_start = 205
port_range_end = 205
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `4"
type = "INGRESS"
port_range_start = 26
port_range_end = 26
port_range_start = 206
port_range_end = 206
}
firewall {
protocol = "TCP"
name = "` + constant.ServerTestResource + `5"
type = "EGRESS"
port_range_start = 27
port_range_end = 27
port_range_start = 207
port_range_end = 207
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions services/cloudapi/cloudapifirewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (fs *Service) Create(ctx context.Context, datacenterId, serverId, nicId str
return nil, apiResponse, fmt.Errorf("an error occurred while creating firewall rule for dcId: %s, server_id: %s, nic_id: %s, Response: (%w)", datacenterId, serverId, nicId, err)
}
if errState := cloudapi.WaitForStateChange(ctx, fs.Meta, fs.D, apiResponse, schema.TimeoutCreate); errState != nil {
return nil, apiResponse, fmt.Errorf("an error occurred while waiting for state change dcId: %s, server_id: %s, nic_id: %s, Response: (%w)", datacenterId, serverId, nicId, errState)
return nil, apiResponse, fmt.Errorf("on create an error occurred while waiting for state change dcId: %s, server_id: %s, nic_id: %s, Response: (%w)", datacenterId, serverId, nicId, errState)
}
return &firewall, apiResponse, nil
}
Expand All @@ -80,7 +80,7 @@ func (fs *Service) Update(ctx context.Context, datacenterId, serverId, nicId, id
return nil, apiResponse, fmt.Errorf("an error occurred while updating firewall rule for dcId: %s, server_id: %s, nic_id: %s, id %s, Response: (%w)", datacenterId, serverId, nicId, id, err)
}
if errState := cloudapi.WaitForStateChange(ctx, fs.Meta, fs.D, apiResponse, schema.TimeoutUpdate); errState != nil {
return nil, apiResponse, fmt.Errorf("an error occurred while waiting for state change dcId: %s, server_id: %s, nic_id: %s, Response: (%w)", datacenterId, serverId, nicId, errState)
return nil, apiResponse, fmt.Errorf("on update an error occurred while waiting for state change dcId: %s, server_id: %s, nic_id: %s, Response: (%w)", datacenterId, serverId, nicId, errState)
}
return &firewall, apiResponse, nil
}
Expand Down
Loading