Skip to content

Commit

Permalink
Update acceptance tests (outscale#70)
Browse files Browse the repository at this point in the history
Signed-off-by: Thiery Ouattara <[email protected]>
  • Loading branch information
outscale-toa authored Mar 10, 2022
1 parent c3e8605 commit ae21524
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 63 deletions.
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
`
}
Expand All @@ -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]
}
}
`
Expand Down
19 changes: 4 additions & 15 deletions outscale/data_source_outscale_flexible_gpu_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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" { }
`)
}
10 changes: 5 additions & 5 deletions outscale/data_source_outscale_image_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
Expand All @@ -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]
}
}
Expand Down
10 changes: 6 additions & 4 deletions outscale/data_source_outscale_load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -21,19 +23,19 @@ 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"),
)},
},
})
}

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
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_vm_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_vm_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions outscale/data_source_outscale_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_vms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 4 additions & 2 deletions outscale/resource_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion outscale/resource_outscale_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
// OutscaleImageDeleteRetryTimeout ...
OutscaleImageDeleteRetryTimeout = 90 * time.Minute
// OutscaleImageRetryDelay ...
OutscaleImageRetryDelay = 5 * time.Second
OutscaleImageRetryDelay = 20 * time.Second
// OutscaleImageRetryMinTimeout ...
OutscaleImageRetryMinTimeout = 3 * time.Second
)
Expand Down
10 changes: 5 additions & 5 deletions outscale/resource_outscale_image_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions outscale/resource_outscale_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion outscale/resource_outscale_load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 8 additions & 8 deletions outscale/resource_outscale_nic_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
12 changes: 6 additions & 6 deletions outscale/resource_outscale_route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
`

Expand All @@ -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
}
`

Expand All @@ -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)
}
Expand All @@ -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
Expand Down
Loading

0 comments on commit ae21524

Please sign in to comment.