Skip to content

Commit

Permalink
Fix testacc for us-east-2
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericBerot-Armand committed Mar 16, 2023
1 parent 49f06df commit cc8447c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
40 changes: 21 additions & 19 deletions outscale/resource_outscale_snapshot_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package outscale

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
Expand All @@ -14,6 +15,7 @@ func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) {
acctest.RandomWithPrefix("terraform-export-bucket-"),
acctest.RandomWithPrefix("terraform-export-bucket-"),
}
region := os.Getenv("OUTSCALE_REGION")
tags := `tags {
key = "test"
value = "test"
Expand All @@ -29,13 +31,13 @@ func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleOAPISnapshotExportTaskConfig("", osuBucketNames[0]),
Config: testAccOutscaleOAPISnapshotExportTaskConfig(region, "", osuBucketNames[0]),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"),
),
},
{
Config: testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketNames[1]),
Config: testAccOutscaleOAPISnapshotExportTaskConfig(region, tags, osuBucketNames[1]),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"),
),
Expand All @@ -59,23 +61,23 @@ func testAccCheckOutscaleOAPISnapshotExportTaskExists(n string) resource.TestChe
}
}

func testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketName string) string {
func testAccOutscaleOAPISnapshotExportTaskConfig(region, tags, osuBucketName string) string {
return fmt.Sprintf(`
resource "outscale_volume" "outscale_volume_snap" {
subregion_name = "eu-west-2a"
size = 10
}
resource "outscale_snapshot" "outscale_snapshot" {
volume_id = outscale_volume.outscale_volume_snap.volume_id
}
resource "outscale_snapshot_export_task" "outscale_snapshot_export_task" {
snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id
osu_export {
disk_image_format = "qcow2"
osu_bucket = "%[2]s"
osu_prefix = "new-export"
resource "outscale_volume" "outscale_volume_snap" {
subregion_name = "%[1]sa"
size = 10
}
%[1]s
}
`, tags, osuBucketName)
resource "outscale_snapshot" "outscale_snapshot" {
volume_id = outscale_volume.outscale_volume_snap.volume_id
}
resource "outscale_snapshot_export_task" "outscale_snapshot_export_task" {
snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id
osu_export {
disk_image_format = "qcow2"
osu_bucket = "%[3]s"
osu_prefix = "new-export"
}
%[2]s
}
`, region, tags, osuBucketName)
}
10 changes: 5 additions & 5 deletions outscale/resource_outscale_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ func TestAccOutscaleOAPIVM_withNics(t *testing.T) {
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")

region := os.Getenv("OUTSCALE_REGION")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckOutscaleOAPIVMDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, "tinav4.c2r2p2", keypair),
Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(region, omi, "tinav4.c2r2p2", keypair),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server),
testAccCheckOutscaleOAPIVMAttributes(t, &server, omi),
Expand Down Expand Up @@ -695,15 +695,15 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNicAttached(omi, vmType, region, k
}`, omi, vmType, region, keypair)
}

func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) string {
func testAccCheckOutscaleOAPIVMConfigBasicWithNics(region, omi, vmType, keypair string) string {
return fmt.Sprintf(`resource "outscale_net" "outscale_net" {
ip_range = "10.0.0.0/16"
}
resource "outscale_subnet" "outscale_subnet" {
net_id = outscale_net.outscale_net.net_id
ip_range = "10.0.0.0/24"
subregion_name = "eu-west-2a"
subregion_name = "%sa"
}
resource "outscale_nic" "outscale_nic" {
Expand Down Expand Up @@ -736,7 +736,7 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string)
is_primary = false
}
}
}`, omi, vmType, keypair)
}`, region, omi, vmType, keypair)
}

func testAccVmsConfigUpdateOAPIVMTags(omi, vmType string, region, value, keypair, sgId string) string {
Expand Down

0 comments on commit cc8447c

Please sign in to comment.