fix: fix wait test
[skip ci]
This commit is contained in:
parent
ece6ee8f28
commit
292d5af7a2
2 changed files with 28 additions and 7 deletions
|
|
@ -31,24 +31,24 @@ const (
|
|||
|
||||
// APIClientInstanceInterface Interface needed for tests
|
||||
type APIClientInstanceInterface interface {
|
||||
GetInstanceRequest(ctx context.Context, projectId, region, instanceId string) v3alpha1api.ApiGetInstanceRequestRequest
|
||||
GetInstanceRequest(ctx context.Context, projectID, region, instanceID string) v3alpha1api.ApiGetInstanceRequestRequest
|
||||
|
||||
ListUsersRequest(
|
||||
ctx context.Context,
|
||||
projectId string,
|
||||
projectID string,
|
||||
region string,
|
||||
instanceId string,
|
||||
instanceID string,
|
||||
) v3alpha1api.ApiListUsersRequestRequest
|
||||
}
|
||||
|
||||
// APIClientUserInterface Interface needed for tests
|
||||
type APIClientUserInterface interface {
|
||||
GetUserRequest(ctx context.Context, projectId, region, instanceId string, userId int32) v3alpha1api.ApiGetUserRequestRequest
|
||||
GetUserRequest(ctx context.Context, projectID, region, instanceID string, userID int32) v3alpha1api.ApiGetUserRequestRequest
|
||||
}
|
||||
|
||||
// APIClientDatabaseInterface Interface needed for tests
|
||||
type APIClientDatabaseInterface interface {
|
||||
GetDatabaseRequest(ctx context.Context, projectId string, region string, instanceId string, databaseId int32) v3alpha1api.ApiGetDatabaseRequestRequest
|
||||
GetDatabaseRequest(ctx context.Context, projectID string, region string, instanceID string, databaseID int32) v3alpha1api.ApiGetDatabaseRequestRequest
|
||||
}
|
||||
|
||||
// CreateInstanceWaitHandler will wait for instance creation
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package postgresflexalpha
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
wantErr bool
|
||||
wantRes *v3alpha1api.GetInstanceResponse
|
||||
timeout time.Duration
|
||||
onlyOnLong bool
|
||||
}{
|
||||
{
|
||||
desc: "create_succeeded",
|
||||
|
|
@ -47,6 +49,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
onlyOnLong: true,
|
||||
desc: "create_failed",
|
||||
instanceGetFails: false,
|
||||
instanceState: InstanceStateFailed,
|
||||
|
|
@ -67,7 +70,8 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
RouterAddress: utils.Ptr("10.0.0.1"),
|
||||
},
|
||||
},
|
||||
timeout: 30 * time.Second,
|
||||
// waiter uses random timeouts up to 8 times 30 secs
|
||||
timeout: 300 * time.Second,
|
||||
},
|
||||
{
|
||||
desc: "create_failed_2",
|
||||
|
|
@ -153,6 +157,13 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.onlyOnLong {
|
||||
_, ok := os.LookupEnv("TF_RUN_LONG_TESTS")
|
||||
if !ok {
|
||||
t.Logf("skipping test '%s' because TF_RUN_LONG_TESTS env var is missing", tt.desc)
|
||||
continue
|
||||
}
|
||||
}
|
||||
t.Run(
|
||||
tt.desc, func(t *testing.T) {
|
||||
instanceID := "foo-bar"
|
||||
|
|
@ -220,6 +231,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
wantErr bool
|
||||
wantRes *v3alpha1api.GetInstanceResponse
|
||||
timeout time.Duration
|
||||
onlyOnLong bool
|
||||
}{
|
||||
{
|
||||
desc: "update_succeeded",
|
||||
|
|
@ -244,6 +256,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
onlyOnLong: true,
|
||||
desc: "update_failed",
|
||||
instanceGetFails: false,
|
||||
instanceState: InstanceStateFailed,
|
||||
|
|
@ -264,7 +277,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
RouterAddress: utils.Ptr("10.0.0.1"),
|
||||
},
|
||||
},
|
||||
timeout: 30 * time.Second,
|
||||
timeout: 300 * time.Second,
|
||||
},
|
||||
{
|
||||
desc: "update_failed_2",
|
||||
|
|
@ -300,6 +313,14 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.onlyOnLong {
|
||||
_, ok := os.LookupEnv("TF_RUN_LONG_TESTS")
|
||||
if !ok {
|
||||
t.Logf("skipping test '%s' because TF_RUN_LONG_TESTS env var is missing", tt.desc)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
t.Run(
|
||||
tt.desc, func(t *testing.T) {
|
||||
instanceID := "foo-bar"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue