Skip to content

Commit

Permalink
Run TestAcc on new region
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Mar 11, 2023
1 parent 9627829 commit 1626b9b
Show file tree
Hide file tree
Showing 54 changed files with 315 additions and 324 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/acceptance_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:

jobs:
Acceptances_tests:
environment: RUNNER_ACCESS
concurrency: terraform-acceptance-test
runs-on: [self-hosted, linux]
runs-on: [self-hosted, linux, us-east-2]
steps:
- uses: actions/checkout@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions outscale/data_source_outscale_ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ func testAccDataCheckOutscaleCaDestroy(s *terraform.State) error {

func testAccDataOutscaleOAPICaConfig(ca_pem string) string {
return fmt.Sprintf(`
resource "outscale_ca" "ca_test" {
resource "outscale_ca" "ca_test" {
ca_pem = %[1]q
description = "Ca testacc create"
}
data "outscale_ca" "ca_data" {
filter {
name = "ca_ids"
values = ["${outscale_ca.ca_test.id}"]
}
filter {
name = "ca_ids"
values = [outscale_ca.ca_test.id]
}
}
`, ca_pem)
}
22 changes: 15 additions & 7 deletions outscale/data_source_outscale_cas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,25 @@ func testAccDataCheckOutscaleCasDestroy(s *terraform.State) error {

func testAccDataOutscaleOAPICasConfig(ca_pem string) string {
return fmt.Sprintf(`
resource "outscale_ca" "ca_test" {
resource "outscale_ca" "ca_test" {
ca_pem = %[1]q
description = "Ca testacc create"
}
data "outscale_cas" "cas_data" {
filter {
name = "ca_ids"
values = ["${outscale_ca.ca_test.id}"]
}
resource "outscale_ca" "ca_test2" {
ca_pem = %[1]q
description = "Ca testacc create2"
}
data "outscale_cas" "cas_data" {
filter {
name = "ca_ids"
values = [outscale_ca.ca_test.id]
}
filter {
name = "description"
values = ["Ca testacc create2"]
}
}
data "outscale_cas" "all_cas" {}
`, ca_pem)
}
15 changes: 7 additions & 8 deletions outscale/data_source_outscale_flexible_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package outscale

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func TestAccDataSourceOutscaleOAPIFlexibleGpu_basic(t *testing.T) {
t.Parallel()
region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION"))

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -19,18 +18,18 @@ func TestAccDataSourceOutscaleOAPIFlexibleGpu_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region),
Config: testAccDataSourceOutscaleOAPIFlexibleGpuConfig(utils.GetRegion()),
},
},
})
}

func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region1 string) string {
func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region string) string {
return fmt.Sprintf(`
resource "outscale_flexible_gpu" "fGPU-data1" {
resource "outscale_flexible_gpu" "fGPU-1" {
model_name = "nvidia-p6"
generation = "v5"
subregion_name = "%s"
subregion_name = "%sa"
delete_on_vm_deletion = true
}
Expand All @@ -57,8 +56,8 @@ func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region1 string) stri
}
filter {
name = "subregion_names"
values = ["%s"]
values = ["%[1]s"]
}
}
`, region, region)
`, region)
}
11 changes: 5 additions & 6 deletions outscale/data_source_outscale_flexible_gpus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package outscale

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func TestAccDataSourceOutscaleOAPIFlexibleGpus_basic(t *testing.T) {
t.Parallel()
region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION"))

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -19,18 +18,18 @@ func TestAccDataSourceOutscaleOAPIFlexibleGpus_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region),
Config: testAccDataSourceOutscaleOAPIFlexibleGpusConfig(utils.GetRegion()),
},
},
})
}

func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region1 string) string {
func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region string) string {
return fmt.Sprintf(`
resource "outscale_flexible_gpu" "fGPUS-1" {
model_name = "nvidia-p6"
generation = "v5"
subregion_name = "%s"
subregion_name = "%sb"
delete_on_vm_deletion = true
}
Expand All @@ -57,7 +56,7 @@ func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region1 string) str
}
filter {
name = "subregion_names"
values = ["%s"]
values = ["%[1]s"]
}
}
`, region, region)
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_image_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-outscale/utils"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccOutscaleOAPIImageExportTaskDataSource_basic(t *testing.T) {
omi := os.Getenv("OUTSCALE_IMAGEID")
region := os.Getenv("OUTSCALE_REGION")
imageName := acctest.RandomWithPrefix("test-image-name")

if os.Getenv("TEST_QUOTA") == "true" {
Expand All @@ -24,7 +24,7 @@ func TestAccOutscaleOAPIImageExportTaskDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName),
Config: testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImageExportTaskDataSourceID("data.outscale_image_export_task.test"),
),
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_image_export_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/terraform-providers/terraform-provider-outscale/utils"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccOutscaleOAPIImageExportTasksDataSource_basic(t *testing.T) {
omi := os.Getenv("OUTSCALE_IMAGEID")
region := os.Getenv("OUTSCALE_REGION")
imageName := acctest.RandomWithPrefix("test-image-name")

if os.Getenv("TEST_QUOTA") == "true" {
Expand All @@ -23,7 +23,7 @@ func TestAccOutscaleOAPIImageExportTasksDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleOAPIImageExportTasksDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName),
Config: testAccOutscaleOAPIImageExportTasksDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImageExportTaskDataSourceID("outscale_image_export_task.outscale_image_export_task"),
),
Expand Down
7 changes: 3 additions & 4 deletions outscale/data_source_outscale_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func TestAccOutscaleOAPIImageDataSource_Instance(t *testing.T) {
t.Parallel()
omi := os.Getenv("OUTSCALE_IMAGEID")
region := os.Getenv("OUTSCALE_REGION")
imageName := fmt.Sprintf("image-test-%d", acctest.RandInt())

resource.Test(t, resource.TestCase{
Expand All @@ -23,7 +23,7 @@ func TestAccOutscaleOAPIImageDataSource_Instance(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleOAPIImageConfigBasic(omi, "tinav4.c2r2p2", region, imageName),
Config: testAccCheckOutscaleOAPIImageConfigBasic(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPIImageDataSourceID("data.outscale_image.nat_ami"),
resource.TestCheckResourceAttr("data.outscale_image.nat_ami", "architecture", "x86_64"),
Expand All @@ -36,7 +36,6 @@ func TestAccOutscaleOAPIImageDataSource_Instance(t *testing.T) {
func TestAccOutscaleOAPIImageDataSource_basic(t *testing.T) {
t.Parallel()
omi := os.Getenv("OUTSCALE_IMAGEID")
region := os.Getenv("OUTSCALE_REGION")
imageName := fmt.Sprintf("image-test-%d", acctest.RandInt())

resource.Test(t, resource.TestCase{
Expand All @@ -46,7 +45,7 @@ func TestAccOutscaleOAPIImageDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, "tinav4.c2r2p2", region, imageName),
Config: testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPIImageDataSourceID("data.outscale_image.omi"),
),
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func TestAccOutscaleOAPIImagesDataSource_Instance(t *testing.T) {
t.Parallel()
omi := os.Getenv("OUTSCALE_IMAGEID")
region := os.Getenv("OUTSCALE_REGION")
imageName := fmt.Sprintf("image-test-%d", acctest.RandInt())

resource.Test(t, resource.TestCase{
Expand All @@ -23,7 +23,7 @@ func TestAccOutscaleOAPIImagesDataSource_Instance(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleOAPIImagesDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName),
Config: testAccCheckOutscaleOAPIImagesDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPIImagesDataSourceID("data.outscale_images.nat_ami"),
),
Expand Down
8 changes: 3 additions & 5 deletions outscale/data_source_outscale_load_balancer_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ package outscale

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func TestAccOutscaleOAPIDSLoadBalancerTags_basic(t *testing.T) {
t.Parallel()
r := acctest.RandString(4)
region := os.Getenv("OUTSCALE_REGION")
zone := fmt.Sprintf("%sa", region)

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -23,7 +21,7 @@ func TestAccOutscaleOAPIDSLoadBalancerTags_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: getTestAccDSODSutscaleOAPILBUDSTagsConfig(r, zone),
Config: getTestAccDSODSutscaleOAPILBUDSTagsConfig(r, utils.GetRegion()),
Check: resource.ComposeTestCheckFunc(
testAccCheckODSutscaleOAPILBUDSTagsExists("data.outscale_load_balancer_tags.testds"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -51,7 +49,7 @@ func testAccCheckODSutscaleOAPILBUDSTagsExists(n string) resource.TestCheckFunc
func getTestAccDSODSutscaleOAPILBUDSTagsConfig(r string, zone string) string {
return fmt.Sprintf(`
resource "outscale_load_balancer" "bar" {
subregion_names = ["%s"]
subregion_names = ["%sa"]
load_balancer_name = "foobar-terraform-elb-%s"
listeners {
Expand Down
5 changes: 2 additions & 3 deletions outscale/data_source_outscale_load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package outscale

import (
"fmt"
"os"
"testing"

oscgo "github.com/outscale/osc-sdk-go/v2"
"github.com/terraform-providers/terraform-provider-outscale/utils"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)
Expand All @@ -14,8 +14,7 @@ func TestAccOutscaleOAPIDSLBU_basic(t *testing.T) {
t.Parallel()
var conf oscgo.LoadBalancer

region := os.Getenv("OUTSCALE_REGION")
zone := fmt.Sprintf("%sa", region)
zone := fmt.Sprintf("%sa", utils.GetRegion())
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
Expand Down
12 changes: 5 additions & 7 deletions outscale/data_source_outscale_load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package outscale

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
Expand All @@ -11,8 +10,7 @@ import (

func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) {
t.Parallel()
region := os.Getenv("OUTSCALE_REGION")
zone := fmt.Sprintf("%sa", region)
region := fmt.Sprintf("%sa", utils.GetRegion())
numLbu := utils.RandIntRange(0, 50)

resource.Test(t, resource.TestCase{
Expand All @@ -24,18 +22,18 @@ func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) {
CheckDestroy: testAccCheckOutscaleOAPILBUDestroy,
Steps: []resource.TestStep{
{
Config: testAccDSOutscaleOAPILBsUConfig(zone, numLbu),
Config: testAccDSOutscaleOAPILBsUConfig(region, numLbu),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.outscale_load_balancers.test", "load_balancer.#", "1"),
)},
},
})
}

func testAccDSOutscaleOAPILBsUConfig(zone string, numLbu int) string {
func testAccDSOutscaleOAPILBsUConfig(region string, numLbu int) string {
return fmt.Sprintf(`
resource "outscale_load_balancer" "bar" {
subregion_names = ["%s"]
subregion_names = ["%sa"]
load_balancer_name = "foobar-terraform-elb%d"
listeners {
Expand All @@ -56,5 +54,5 @@ func testAccDSOutscaleOAPILBsUConfig(zone string, numLbu int) string {
data "outscale_load_balancers" "test" {
load_balancer_name = [outscale_load_balancer.bar.id]
}
`, zone, numLbu)
`, region, numLbu)
}
Loading

0 comments on commit 1626b9b

Please sign in to comment.