From ae21524825453ee51b53fb54b8ff38d4f566cbb1 Mon Sep 17 00:00:00 2001 From: outscale-toa Date: Thu, 10 Mar 2022 11:42:03 +0100 Subject: [PATCH] Update acceptance tests (#70) Signed-off-by: Thiery Ouattara --- .../data_source_outscale_access_key_test.go | 4 ++-- ...urce_outscale_flexible_gpu_catalog_test.go | 19 ++++--------------- ..._source_outscale_image_export_task_test.go | 10 +++++----- ...ata_source_outscale_load_balancers_test.go | 10 ++++++---- outscale/data_source_outscale_tag_test.go | 2 +- .../data_source_outscale_vm_state_test.go | 2 +- .../data_source_outscale_vm_states_test.go | 2 +- outscale/data_source_outscale_vm_test.go | 6 +++--- outscale/data_source_outscale_vms_test.go | 2 +- outscale/resource_outscale_access_key_test.go | 6 ++++-- outscale/resource_outscale_image.go | 2 +- ...esource_outscale_image_export_task_test.go | 10 +++++----- outscale/resource_outscale_image_test.go | 8 ++++---- .../resource_outscale_load_balancer_test.go | 2 +- outscale/resource_outscale_nic_link_test.go | 16 ++++++++-------- .../resource_outscale_route_table_test.go | 12 ++++++------ outscale/resource_outscale_tags_test.go | 6 +++--- 17 files changed, 56 insertions(+), 63 deletions(-) diff --git a/outscale/data_source_outscale_access_key_test.go b/outscale/data_source_outscale_access_key_test.go index 2b9d31239..eea628244 100644 --- a/outscale/data_source_outscale_access_key_test.go +++ b/outscale/data_source_outscale_access_key_test.go @@ -53,7 +53,7 @@ func testAccClientAccessKeyDataSourceBasic() string { resource "outscale_access_key" "outscale_access_key" {} data "outscale_access_key" "outscale_access_key" { - access_key_id = "${outscale_access_key.outscale_access_key.id}" + access_key_id = outscale_access_key.outscale_access_key.id } ` } @@ -65,7 +65,7 @@ func testAccClientAccessKeyDataSourceWithFilters() string { data "outscale_access_key" "outscale_access_key" { filter { name = "access_key_ids" - values = ["${outscale_access_key.outscale_access_key.id}"] + values = [outscale_access_key.outscale_access_key.id] } } ` diff --git a/outscale/data_source_outscale_flexible_gpu_catalog_test.go b/outscale/data_source_outscale_flexible_gpu_catalog_test.go index eb3f46ab1..bd6a138ee 100644 --- a/outscale/data_source_outscale_flexible_gpu_catalog_test.go +++ b/outscale/data_source_outscale_flexible_gpu_catalog_test.go @@ -2,14 +2,12 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) func TestAccDataSourceOutscaleOAPIFlexibleGpuCatalog_basic(t *testing.T) { - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -18,23 +16,14 @@ func TestAccDataSourceOutscaleOAPIFlexibleGpuCatalog_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPIFlexibleGpuCatalogConfig(region), + Config: testAccDataSourceOutscaleOAPIFlexibleGpuCatalogConfig(), }, }, }) } -func testAccDataSourceOutscaleOAPIFlexibleGpuCatalogConfig(region string) string { +func testAccDataSourceOutscaleOAPIFlexibleGpuCatalogConfig() string { return fmt.Sprintf(` - resource "outscale_flexible_gpu" "fGPU-1" { - model_name = "nvidia-k2" - generation = "v3" - subregion_name = "%s" - delete_on_vm_deletion = true - } - - data "outscale_flexible_gpu_catalog" "catalog-fGPU" { - - } - `, region) + data "outscale_flexible_gpu_catalog" "catalog-fGPU" { } + `) } diff --git a/outscale/data_source_outscale_image_export_task_test.go b/outscale/data_source_outscale_image_export_task_test.go index 112fdaba2..5874f43de 100644 --- a/outscale/data_source_outscale_image_export_task_test.go +++ b/outscale/data_source_outscale_image_export_task_test.go @@ -50,9 +50,9 @@ func testAccCheckOutscaleImageExportTaskDataSourceID(n string) resource.TestChec func testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, vmType, region, imageName string) string { return fmt.Sprintf(` resource "outscale_vm" "basic" { - image_id = "%s" - vm_type = "%s" - keypair_name = "terraform-basic" + image_id = "%s" + vm_type = "%s" + keypair_name = "terraform-basic" placement_subregion_name = "%sa" } @@ -63,7 +63,7 @@ func testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, vmType, region, ima description = "terraform testing" } resource "outscale_image_export_task" "outscale_image_export_task" { - image_id = outscale_image.foo.id + image_id = outscale_image.foo.id osu_export { osu_bucket = "terraform-export-%s" disk_image_format = "qcow2" @@ -73,7 +73,7 @@ func testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, vmType, region, ima data "outscale_image_export_task" "test" { filter { - name = "task_ids" + name = "task_ids" values = [outscale_image_export_task.outscale_image_export_task.id] } } diff --git a/outscale/data_source_outscale_load_balancers_test.go b/outscale/data_source_outscale_load_balancers_test.go index 46ace47e6..918fbfa96 100644 --- a/outscale/data_source_outscale_load_balancers_test.go +++ b/outscale/data_source_outscale_load_balancers_test.go @@ -5,12 +5,14 @@ import ( "os" "testing" + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { region := os.Getenv("OUTSCALE_REGION") zone := fmt.Sprintf("%sa", region) + numLbu := acctest.RandIntRange(0, 50) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -21,7 +23,7 @@ func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPILBUDestroy, Steps: []resource.TestStep{ { - Config: testAccDSOutscaleOAPILBsUConfig(zone), + Config: testAccDSOutscaleOAPILBsUConfig(zone, numLbu), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.outscale_load_balancers.test", "load_balancer.#", "1"), )}, @@ -29,11 +31,11 @@ func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { }) } -func testAccDSOutscaleOAPILBsUConfig(zone string) string { +func testAccDSOutscaleOAPILBsUConfig(zone string, numLbu int) string { return fmt.Sprintf(` resource "outscale_load_balancer" "bar" { subregion_names = ["%s"] - load_balancer_name = "foobar-terraform-elb" + load_balancer_name = "foobar-terraform-elb%d" listeners { backend_port = 8000 @@ -53,5 +55,5 @@ func testAccDSOutscaleOAPILBsUConfig(zone string) string { data "outscale_load_balancers" "test" { load_balancer_name = ["${outscale_load_balancer.bar.id}"] } -`, zone) +`, zone, numLbu) } diff --git a/outscale/data_source_outscale_tag_test.go b/outscale/data_source_outscale_tag_test.go index 509465f60..875f13e46 100644 --- a/outscale/data_source_outscale_tag_test.go +++ b/outscale/data_source_outscale_tag_test.go @@ -47,7 +47,7 @@ func testAccOAPITagDataSourceConfig(omi, vmType string) string { data "outscale_tag" "web" { filter { name = "resource_ids" - values = ["${outscale_vm.basic.id}"] + values = [outscale_vm.basic.id] } } `, omi, vmType) diff --git a/outscale/data_source_outscale_vm_state_test.go b/outscale/data_source_outscale_vm_state_test.go index 609007043..89836b4c8 100644 --- a/outscale/data_source_outscale_vm_state_test.go +++ b/outscale/data_source_outscale_vm_state_test.go @@ -61,7 +61,7 @@ func testAccDataSourceOutscaleOAPIVmStateConfig(omi, vmType string) string { } data "outscale_vm_state" "state" { - vm_id = "${outscale_vm.basic.id}" + vm_id = "outscale_vm.basic.id" } `, omi, vmType) } diff --git a/outscale/data_source_outscale_vm_states_test.go b/outscale/data_source_outscale_vm_states_test.go index 4e89db433..b179daf76 100644 --- a/outscale/data_source_outscale_vm_states_test.go +++ b/outscale/data_source_outscale_vm_states_test.go @@ -31,7 +31,7 @@ func testAccDataSourceOutscaleOAPIVMStatesConfig(omi, vmType string) string { } data "outscale_vm_states" "state" { - vm_ids = ["${outscale_vm.basic.id}"] + vm_ids = [outscale_vm.basic.id] } `, omi, vmType) } diff --git a/outscale/data_source_outscale_vm_test.go b/outscale/data_source_outscale_vm_test.go index ef114f3c5..2c1e4204a 100644 --- a/outscale/data_source_outscale_vm_test.go +++ b/outscale/data_source_outscale_vm_test.go @@ -40,7 +40,7 @@ func testAccOAPIVMDataSourceConfig(omi, vmType string) string { } resource "outscale_subnet" "outscale_subnet" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/24" subregion_name = "eu-west-2a" } @@ -49,7 +49,7 @@ func testAccOAPIVMDataSourceConfig(omi, vmType string) string { image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id tags { key = "name" @@ -60,7 +60,7 @@ func testAccOAPIVMDataSourceConfig(omi, vmType string) string { data "outscale_vm" "basic_web" { filter { name = "vm_ids" - values = ["${outscale_vm.outscale_vm.vm_id}"] + values = [outscale_vm.outscale_vm.vm_id] } } `, omi, vmType) diff --git a/outscale/data_source_outscale_vms_test.go b/outscale/data_source_outscale_vms_test.go index 7b34c29a9..11cb42de1 100644 --- a/outscale/data_source_outscale_vms_test.go +++ b/outscale/data_source_outscale_vms_test.go @@ -39,7 +39,7 @@ func testAccOAPIVMSDataSourceConfig(omi, vmType string) string { data "outscale_vms" "basic_web" { filter { name = "vm_ids" - values = ["${outscale_vm.basic.id}"] + values = [outscale_vm.basic.id] } }`, omi, vmType) } diff --git a/outscale/resource_outscale_access_key_test.go b/outscale/resource_outscale_access_key_test.go index bb5d98adb..569c1aab4 100644 --- a/outscale/resource_outscale_access_key_test.go +++ b/outscale/resource_outscale_access_key_test.go @@ -162,13 +162,15 @@ func testAccCheckOutscaleAccessKeyDestroy(s *terraform.State) error { } const testAccOutscaleAccessKeyBasicConfig = ` - resource "outscale_access_key" "outscale_access_key" {} -` + resource "outscale_access_key" "outscale_access_key" { + expiration_date = "2025-01-04" + }` func testAccOutscaleAccessKeyUpdatedConfig(state string) string { return fmt.Sprintf(` resource "outscale_access_key" "outscale_access_key" { state = "%s" + expiration_date = "2025-08-10T15:19:21" } `, state) } diff --git a/outscale/resource_outscale_image.go b/outscale/resource_outscale_image.go index 161e99971..666a8f980 100644 --- a/outscale/resource_outscale_image.go +++ b/outscale/resource_outscale_image.go @@ -21,7 +21,7 @@ const ( // OutscaleImageDeleteRetryTimeout ... OutscaleImageDeleteRetryTimeout = 90 * time.Minute // OutscaleImageRetryDelay ... - OutscaleImageRetryDelay = 5 * time.Second + OutscaleImageRetryDelay = 20 * time.Second // OutscaleImageRetryMinTimeout ... OutscaleImageRetryMinTimeout = 3 * time.Second ) diff --git a/outscale/resource_outscale_image_export_task_test.go b/outscale/resource_outscale_image_export_task_test.go index f0c1ac75d..cf9a67509 100644 --- a/outscale/resource_outscale_image_export_task_test.go +++ b/outscale/resource_outscale_image_export_task_test.go @@ -63,20 +63,20 @@ func testAccCheckOutscaleOAPImageExportTaskExists(n string) resource.TestCheckFu func testAccOAPIImageExportTaskConfigBasic(omi, vmType, region, imageName, tags string) string { return fmt.Sprintf(` resource "outscale_vm" "basic" { - image_id = "%s" - vm_type = "%s" - keypair_name = "terraform-basic" + image_id = "%s" + vm_type = "%s" + keypair_name = "terraform-basic" placement_subregion_name = "%sa" } resource "outscale_image" "foo" { image_name = "%s" - vm_id = "${outscale_vm.basic.id}" + vm_id = "outscale_vm.basic.id" no_reboot = "true" description = "terraform testing" } resource "outscale_image_export_task" "outscale_image_export_task" { - image_id = outscale_image.foo.id + image_id = outscale_image.foo.id osu_export { osu_bucket = "%s" disk_image_format = "qcow2" diff --git a/outscale/resource_outscale_image_test.go b/outscale/resource_outscale_image_test.go index f632080ed..1ae7380ce 100644 --- a/outscale/resource_outscale_image_test.go +++ b/outscale/resource_outscale_image_test.go @@ -94,15 +94,15 @@ func testAccCheckOAPIImageExists(n string, ami *oscgo.Image) resource.TestCheckF func testAccOAPIImageConfigBasic(omi, vmType, region string, rInt int) string { return fmt.Sprintf(` resource "outscale_vm" "basic" { - image_id = "%s" - vm_type = "%s" - keypair_name = "terraform-basic" + image_id = "%s" + vm_type = "%s" + keypair_name = "terraform-basic" placement_subregion_name = "%sa" } resource "outscale_image" "foo" { image_name = "tf-testing-%d" - vm_id = "${outscale_vm.basic.id}" + vm_id = outscale_vm.basic.id no_reboot = "true" description = "terraform testing" } diff --git a/outscale/resource_outscale_load_balancer_test.go b/outscale/resource_outscale_load_balancer_test.go index 05276b60e..ae884bc60 100644 --- a/outscale/resource_outscale_load_balancer_test.go +++ b/outscale/resource_outscale_load_balancer_test.go @@ -18,7 +18,7 @@ import ( func TestAccOutscaleOAPILBUBasic(t *testing.T) { var conf oscgo.LoadBalancer - r := acctest.RandIntRange(0, 10) + r := acctest.RandIntRange(0, 50) region := os.Getenv("OUTSCALE_REGION") zone := fmt.Sprintf("%sa", region) diff --git a/outscale/resource_outscale_nic_link_test.go b/outscale/resource_outscale_nic_link_test.go index 04fdb11fa..22f9d6a3f 100644 --- a/outscale/resource_outscale_nic_link_test.go +++ b/outscale/resource_outscale_nic_link_test.go @@ -141,7 +141,7 @@ func testAccOutscaleNicLinkConfigBasic(sg int, omi, vmType, region string) strin resource "outscale_security_group" "outscale_security_group" { security_group_name = "terraform_test_%d" description = "Used in the terraform acceptance tests" - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id tags { key = "Name" @@ -153,27 +153,27 @@ func testAccOutscaleNicLinkConfigBasic(sg int, omi, vmType, region string) strin image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" - security_group_ids = ["${outscale_security_group.outscale_security_group.id}"] + security_group_ids = [outscale_security_group.outscale_security_group.id] placement_subregion_name = "%[4]sa" - subnet_id = "${outscale_subnet.outscale_subnet.id}" + subnet_id = outscale_subnet.outscale_subnet.id } resource "outscale_subnet" "outscale_subnet" { subregion_name = "%[4]sa" ip_range = "10.0.0.0/16" - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id - depends_on = ["outscale_security_group.outscale_security_group"] + depends_on = [outscale_security_group.outscale_security_group] } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id } resource "outscale_nic_link" "outscale_nic_link" { device_number = 1 - vm_id = "${outscale_vm.vm.id}" - nic_id = "${outscale_nic.outscale_nic.id}" + vm_id = outscale_vm.vm.id + nic_id = outscale_nic.outscale_nic.id } `, sg, omi, vmType, region) } diff --git a/outscale/resource_outscale_route_table_test.go b/outscale/resource_outscale_route_table_test.go index d5cdb7ae3..1ec157a4f 100644 --- a/outscale/resource_outscale_route_table_test.go +++ b/outscale/resource_outscale_route_table_test.go @@ -392,7 +392,7 @@ resource "outscale_net" "foo" { resource "outscale_internet_service" "foo" {} resource "outscale_route_table" "foo" { - net_id = "${outscale_net.foo.id}" + net_id = "outscale_net.foo.id } ` @@ -409,7 +409,7 @@ resource "outscale_net" "foo" { resource "outscale_internet_service" "foo" {} resource "outscale_route_table" "foo" { - net_id = "${outscale_net.foo.id}" + net_id = outscale_net.foo.id } ` @@ -426,20 +426,20 @@ func testAccOAPIRouteTableConfigInstance(omi, vmType, region string) string { resource "outscale_subnet" "foo" { ip_range = "10.1.1.0/24" - net_id = "${outscale_net.foo.id}" + net_id = outscale_net.foo.id } resource "outscale_vm" "foo" { image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" - subnet_id = "${outscale_subnet.foo.id}" + subnet_id = outscale_subnet.foo.id placement_subregion_name = "%sa" placement_tenancy = "default" } resource "outscale_route_table" "foo" { - net_id = "${outscale_net.foo.id}" + net_id = outscale_net.foo.id } `, omi, vmType, region) } @@ -456,7 +456,7 @@ resource "outscale_net" "foo" { } resource "outscale_route_table" "foo" { - net_id = "${outscale_net.foo.id}" + net_id = outscale_net.foo.id %s diff --git a/outscale/resource_outscale_tags_test.go b/outscale/resource_outscale_tags_test.go index 088c3e8f8..8263ec9e6 100644 --- a/outscale/resource_outscale_tags_test.go +++ b/outscale/resource_outscale_tags_test.go @@ -152,7 +152,7 @@ func testAccCheckOAPIInstanceConfigTags(omi, vmType, region, key, value string) } resource "outscale_subnet" "outscale_subnet" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/24" subregion_name = "eu-west-2a" } @@ -161,12 +161,12 @@ func testAccCheckOAPIInstanceConfigTags(omi, vmType, region, key, value string) vm_type = "%s" keypair_name = "terraform-basic" placement_subregion_name = "%sa" - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id private_ips = ["10.0.0.12"] } resource "outscale_tag" "foo" { - resource_ids = ["${outscale_vm.vm.id}"] + resource_ids = [outscale_vm.vm.id] tag { key = "%s"