-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instance_server): always default to sbs volume root volume (#2920)
* feat(instance_server): default to sbs volume root volume, even if l_ssd is available l_ssd servers are planned to disappear with the arrival of high perfomance block. * refactor(block): extract test checks helpers * update tests * add image test with sbs * update cassettes * update lb cassette * update vpcgw cassettes * update invalid cassettes * lint
- Loading branch information
Showing
41 changed files
with
38,264 additions
and
24,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package blocktestfuncs | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" | ||
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest" | ||
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors" | ||
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/block" | ||
) | ||
|
||
func IsSnapshotPresent(tt *acctest.TestTools, n string) resource.TestCheckFunc { | ||
return func(state *terraform.State) error { | ||
rs, ok := state.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("resource not found: %s", n) | ||
} | ||
|
||
api, zone, id, err := block.NewAPIWithZoneAndID(tt.Meta, rs.Primary.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = api.GetSnapshot(&blockSDK.GetSnapshotRequest{ | ||
SnapshotID: id, | ||
Zone: zone, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func IsVolumePresent(tt *acctest.TestTools, n string) resource.TestCheckFunc { | ||
return func(state *terraform.State) error { | ||
rs, ok := state.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("resource not found: %s", n) | ||
} | ||
|
||
api, zone, id, err := block.NewAPIWithZoneAndID(tt.Meta, rs.Primary.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = api.GetVolume(&blockSDK.GetVolumeRequest{ | ||
VolumeID: id, | ||
Zone: zone, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func IsVolumeDestroyed(tt *acctest.TestTools) resource.TestCheckFunc { | ||
return func(state *terraform.State) error { | ||
for _, rs := range state.RootModule().Resources { | ||
if rs.Type != "scaleway_block_volume" { | ||
continue | ||
} | ||
|
||
api, zone, id, err := block.NewAPIWithZoneAndID(tt.Meta, rs.Primary.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = api.DeleteVolume(&blockSDK.DeleteVolumeRequest{ | ||
VolumeID: id, | ||
Zone: zone, | ||
}) | ||
|
||
if err == nil { | ||
return fmt.Errorf("block volume (%s) still exists", rs.Primary.ID) | ||
} | ||
|
||
if !httperrors.Is404(err) && !httperrors.Is410(err) { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func IsSnapshotDestroyed(tt *acctest.TestTools) resource.TestCheckFunc { | ||
return func(state *terraform.State) error { | ||
for _, rs := range state.RootModule().Resources { | ||
if rs.Type != "scaleway_block_snapshot" { | ||
continue | ||
} | ||
|
||
api, zone, id, err := block.NewAPIWithZoneAndID(tt.Meta, rs.Primary.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = api.DeleteSnapshot(&blockSDK.DeleteSnapshotRequest{ | ||
SnapshotID: id, | ||
Zone: zone, | ||
}) | ||
|
||
if err == nil { | ||
return fmt.Errorf("block snapshot (%s) still exists", rs.Primary.ID) | ||
} | ||
|
||
if !httperrors.Is404(err) { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.