fix: adjust tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Prepare GO cache (pull_request) Successful in 5m57s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 15m57s
CI Workflow / CI run build and linting (pull_request) Successful in 20m47s
CI Workflow / Code coverage report (pull_request) Successful in 15s
CI Workflow / CI run tests (pull_request) Failing after 1h16m42s
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Prepare GO cache (pull_request) Successful in 5m57s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 15m57s
CI Workflow / CI run build and linting (pull_request) Successful in 20m47s
CI Workflow / Code coverage report (pull_request) Successful in 15s
CI Workflow / CI run tests (pull_request) Failing after 1h16m42s
This commit is contained in:
parent
bb3a2a37b1
commit
a8701d37e6
4 changed files with 33 additions and 13 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"math"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/path"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource"
|
||||
|
|
@ -241,6 +242,8 @@ func (r *instanceResource) Create(
|
|||
}
|
||||
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client.DefaultAPI, projectID, region, *instanceID).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
|
|||
|
|
@ -672,8 +672,8 @@ func defaultInstanceTestChecks(testItemID string, data resData) resource.TestChe
|
|||
resource.TestCheckResourceAttrSet(testItemID, "backup_schedule"),
|
||||
resource.TestCheckResourceAttr(testItemID, "backup_schedule", data.BackupSchedule),
|
||||
|
||||
resource.TestCheckResourceAttrSet(testItemID, "connection_info"),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "connection_info.write"),
|
||||
resource.TestCheckResourceAttr(testItemID, "connection_info.%", "1"),
|
||||
resource.TestCheckResourceAttr(testItemID, "connection_info.write.%", "2"),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "connection_info.write.host"),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "connection_info.write.port"),
|
||||
|
||||
|
|
@ -694,10 +694,9 @@ func defaultInstanceTestChecks(testItemID string, data resData) resource.TestChe
|
|||
resource.TestCheckResourceAttrSet(testItemID, "network"),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "network.access_scope"),
|
||||
resource.TestCheckResourceAttr(testItemID, "network.access_scope", data.AccessScope),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "network.acl"),
|
||||
// resource.TestCheckResourceAttrSet(testItemID, "network.acl"),
|
||||
resource.TestCheckResourceAttr(testItemID, "network.acl.#", strconv.Itoa(len(data.ACLStrings))),
|
||||
resource.TestCheckResourceAttrSet(testItemID, "network.instance_address"),
|
||||
// router address is checken in noenc/ enc
|
||||
// instance_address and router_address are only checked in enc
|
||||
|
||||
resource.TestCheckResourceAttrSet(testItemID, "project_id"),
|
||||
resource.TestCheckResourceAttr(testItemID, "project_id", data.ProjectID),
|
||||
|
|
|
|||
|
|
@ -171,8 +171,6 @@ func CreateInstanceWaitHandler(
|
|||
return false, nil, nil
|
||||
},
|
||||
)
|
||||
// Sleep before wait is set because sometimes API returns 404 right after creation request
|
||||
handler.SetTimeout(90 * time.Minute).SetSleepBeforeWait(30 * time.Second)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +220,6 @@ func PartialUpdateInstanceWaitHandler(
|
|||
}
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(45 * time.Minute).SetSleepBeforeWait(30 * time.Second)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
usersGetErrorStatus int
|
||||
wantErr bool
|
||||
wantRes *v3alpha1api.GetInstanceResponse
|
||||
timeout time.Duration
|
||||
}{
|
||||
{
|
||||
desc: "create_succeeded",
|
||||
|
|
@ -56,7 +57,17 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
RouterAddress: utils.Ptr("10.0.0.1"),
|
||||
},
|
||||
wantErr: true,
|
||||
wantRes: nil,
|
||||
wantRes: &v3alpha1api.GetInstanceResponse{
|
||||
Id: "foo-bar",
|
||||
Status: InstanceStateFailed,
|
||||
Network: v3alpha1api.InstanceNetwork{
|
||||
AccessScope: nil,
|
||||
Acl: nil,
|
||||
InstanceAddress: utils.Ptr("10.0.0.1"),
|
||||
RouterAddress: utils.Ptr("10.0.0.1"),
|
||||
},
|
||||
},
|
||||
timeout: 30 * time.Second,
|
||||
},
|
||||
{
|
||||
desc: "create_failed_2",
|
||||
|
|
@ -181,9 +192,13 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
ListUsersRequestExecuteMock: &listUsersMock,
|
||||
}
|
||||
|
||||
handler := CreateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID)
|
||||
handler := CreateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID).
|
||||
SetTimeout(10 * time.Millisecond)
|
||||
if tt.timeout != 0 {
|
||||
handler.SetTimeout(tt.timeout)
|
||||
}
|
||||
|
||||
gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
|
||||
gotRes, err := handler.SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
|
|
@ -204,6 +219,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
instanceNetwork v3alpha1api.InstanceNetwork
|
||||
wantErr bool
|
||||
wantRes *v3alpha1api.GetInstanceResponse
|
||||
timeout time.Duration
|
||||
}{
|
||||
{
|
||||
desc: "update_succeeded",
|
||||
|
|
@ -248,6 +264,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
RouterAddress: utils.Ptr("10.0.0.1"),
|
||||
},
|
||||
},
|
||||
timeout: 30 * time.Second,
|
||||
},
|
||||
{
|
||||
desc: "update_failed_2",
|
||||
|
|
@ -316,9 +333,13 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
ListUsersRequestExecuteMock: &listUsersMock,
|
||||
}
|
||||
|
||||
handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID)
|
||||
handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID).
|
||||
SetTimeout(10 * time.Millisecond)
|
||||
if tt.timeout > 0 {
|
||||
handler.SetTimeout(tt.timeout)
|
||||
}
|
||||
|
||||
gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
|
||||
gotRes, err := handler.WaitWithContext(context.Background())
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue