Skip to content

Commit

Permalink
fixup flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Dec 20, 2023
1 parent e354234 commit ee34955
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 71 deletions.
2 changes: 1 addition & 1 deletion outscale/resource_outscale_flexible_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func testAccOutscaleOAPIFlexibleGpuConfig(region string) string {
resource "outscale_flexible_gpu" "fGPU-1" {
model_name = "nvidia-p6"
generation = "v5"
subregion_name = "%qa"
subregion_name = "%sa"
delete_on_vm_deletion = true
}
Expand Down
48 changes: 12 additions & 36 deletions outscale/resource_outscale_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func testAccCheckOutscaleVMImportStateIDFunc(resourceName string) resource.Impor
func TestAccNet_VM_withNicAttached(t *testing.T) {
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"
resourceName := "outscale_vm.basic"

resource.Test(t, resource.TestCase{
Expand All @@ -158,7 +158,7 @@ func TestAccVM_withTags(t *testing.T) {
t.Parallel()
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"
tagsValue := "test_tags1"

resource.Test(t, resource.TestCase{
Expand All @@ -167,7 +167,7 @@ func TestAccVM_withTags(t *testing.T) {
CheckDestroy: testAccCheckOutscaleOAPIVMDestroy,
Steps: []resource.TestStep{
{
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), tagsValue, "Terraform-VM", keypair),
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), tagsValue, keypair),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server),
testAccCheckOutscaleOAPIVMAttributes(t, &server, omi),
Expand All @@ -184,7 +184,7 @@ func TestAccVM_withTags(t *testing.T) {
func TestAccNet_VM_withNics(t *testing.T) {
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -209,7 +209,7 @@ func TestAccNet_VM_withNics(t *testing.T) {
func TestAccOutscaleOAPIVM_WithSubnet(t *testing.T) {
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -234,7 +234,7 @@ func TestAccOutscaleOAPIVM_WithSubnet(t *testing.T) {
func TestAccVM_UpdateDeletionProtection(t *testing.T) {
t.Parallel()
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -260,7 +260,7 @@ func TestAccVM_UpdateDeletionProtection(t *testing.T) {
func TestAccVM_UpdateTags(t *testing.T) {
t.Parallel()
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"
tagsValue := "test_tags1"

//TODO: check tags
Expand All @@ -270,11 +270,11 @@ func TestAccVM_UpdateTags(t *testing.T) {
CheckDestroy: testAccCheckOutscaleOAPIVMDestroy,
Steps: []resource.TestStep{
{
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), tagsValue, "Terraform-VM", keypair),
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), tagsValue, keypair),
//Check: resource.ComposeTestCheckFunc(),
},
{
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), tagsValue, "Terraform-VM2", keypair),
Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "Terraform-VM2", keypair),
//Check: resource.ComposeTestCheckFunc(),
},
},
Expand All @@ -284,7 +284,7 @@ func TestAccVM_UpdateTags(t *testing.T) {
func TestAccNet_WithVM_PublicIp_Link(t *testing.T) {
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"
vmType := "tinav4.c2r2p2"

resource.Test(t, resource.TestCase{
Expand All @@ -311,7 +311,7 @@ func TestAccVM_multiBlockDeviceMapping(t *testing.T) {
t.Parallel()
var server oscgo.Vm
omi := os.Getenv("OUTSCALE_IMAGEID")
keypair := os.Getenv("OUTSCALE_KEYPAIR")
keypair := "terraform-basic"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -602,12 +602,6 @@ func testAccCheckOutscaleOAPIVMConfigBasic(omi, vmType, region, keypair string)
vm_type = "%[2]s"
keypair_name = "%[4]s"
placement_subregion_name = "%[3]s"
#placement_tenancy = "dedicated"
#nested_virtualization = true
tags {
key = "name"
value = "Terraform-VM"
}
}`, omi, vmType, region, keypair)
}

Expand Down Expand Up @@ -722,26 +716,8 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair, region
}`, omi, vmType, keypair, region)
}

func testAccVmsConfigUpdateOAPIVMTags(omi, vmType, region, value, keypair, sgId string) string {
func testAccVmsConfigUpdateOAPIVMTags(omi, vmType, region, value, keypair string) string {
return fmt.Sprintf(`
resource "outscale_net" "net" {
ip_range = "10.0.0.0/16"
tags {
key = "Name"
value = "testacc-security-group-rs"
}
}
resource "outscale_security_group" "sg" {
security_group_name = "%[5]s"
description = "Used in the terraform acceptance tests"
tags {
key = "Name"
value = "tf-acc-test"
}
net_id = outscale_net.net.id
}
resource "outscale_vm" "basic" {
image_id = "%[1]s"
vm_type = "%[2]s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"source_net": [
{
"account_id": "##id-1##",
"ip_range": "10.20.0.0/16",
"ip_range": "10.31.0.0/16",
"net_id": "##id-4##"
}
],
Expand All @@ -39,7 +39,16 @@
"name": "pending-acceptance"
}
],
"tags": []
"tags": [
{
"key": "Key",
"value": "value-tags"
},
{
"key": "Key-2",
"value": "value-tags-2"
}
]
},
{
"accepter_net": [
Expand All @@ -53,7 +62,7 @@
"source_net": [
{
"account_id": "##id-1##",
"ip_range": "10.31.0.0/16",
"ip_range": "10.20.0.0/16",
"net_id": "##id-6##"
}
],
Expand All @@ -63,16 +72,7 @@
"name": "pending-acceptance"
}
],
"tags": [
{
"key": "Key",
"value": "value-tags"
},
{
"key": "Key-2",
"value": "value-tags-2"
}
]
"tags": []
}
],
"request_id": "########"
Expand All @@ -88,6 +88,7 @@
"provider": "provider[\"registry.terraform.io/outscale/outscale\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"dhcp_options_set_id": "##id-7##",
Expand All @@ -96,7 +97,12 @@
"net_id": "##id-2##",
"request_id": "########",
"state": "available",
"tags": [],
"tags": [
{
"key": "name",
"value": "net-1"
}
],
"tenancy": "default"
},
"sensitive_attributes": [],
Expand All @@ -114,12 +120,17 @@
"schema_version": 0,
"attributes": {
"dhcp_options_set_id": "##id-7##",
"id": "##id-6##",
"id": "##id-4##",
"ip_range": "10.31.0.0/16",
"net_id": "##id-6##",
"net_id": "##id-4##",
"request_id": "########",
"state": "available",
"tags": [],
"tags": [
{
"key": "name",
"value": "net-2"
}
],
"tenancy": "default"
},
"sensitive_attributes": [],
Expand All @@ -137,12 +148,17 @@
"schema_version": 0,
"attributes": {
"dhcp_options_set_id": "##id-7##",
"id": "##id-4##",
"id": "##id-6##",
"ip_range": "10.20.0.0/16",
"net_id": "##id-4##",
"net_id": "##id-6##",
"request_id": "########",
"state": "available",
"tags": [],
"tags": [
{
"key": "name",
"value": "net-3"
}
],
"tenancy": "default"
},
"sensitive_attributes": [],
Expand All @@ -167,18 +183,18 @@
}
],
"accepter_net_id": "##id-2##",
"id": "##id-5##",
"net_peering_id": "##id-5##",
"id": "##id-3##",
"net_peering_id": "##id-3##",
"request_id": "########",
"source_net": [
{
"account_id": "##id-1##",
"ip_range": "10.31.0.0/16",
"net_id": "##id-6##"
"net_id": "##id-4##"
}
],
"source_net_account_id": null,
"source_net_id": "##id-6##",
"source_net_id": "##id-4##",
"state": [
{
"message": "########",
Expand Down Expand Up @@ -222,18 +238,18 @@
}
],
"accepter_net_id": "##id-2##",
"id": "##id-3##",
"net_peering_id": "##id-3##",
"id": "##id-5##",
"net_peering_id": "##id-5##",
"request_id": "########",
"source_net": [
{
"account_id": "##id-1##",
"ip_range": "10.20.0.0/16",
"net_id": "##id-4##"
"net_id": "##id-6##"
}
],
"source_net_account_id": null,
"source_net_id": "##id-4##",
"source_net_id": "##id-6##",
"state": [
{
"message": "########",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ resource "outscale_net" "outscale_net" {
}

resource "outscale_net" "outscale_net2" {
count = 1

ip_range = "10.31.0.0/16"
tags {
key = "name"
Expand All @@ -19,7 +17,6 @@ resource "outscale_net" "outscale_net2" {
}

resource "outscale_net" "outscale_net3" {
count = 1
ip_range = "10.20.0.0/16"
tags {
key = "name"
Expand All @@ -28,7 +25,7 @@ resource "outscale_net" "outscale_net3" {
}

resource "outscale_net_peering" "outscale_net_peering" {
accepter_net_id = outscale_net.outscale_net.net_id
accepter_net_id = outscale_net.outscale_net[0].net_id
source_net_id = outscale_net.outscale_net2.net_id
tags {
key = "Key"
Expand All @@ -41,7 +38,7 @@ tags {
}

resource "outscale_net_peering" "outscale_net_peering2" {
accepter_net_id = outscale_net.outscale_net.net_id
accepter_net_id = outscale_net.outscale_net[0].net_id
source_net_id = outscale_net.outscale_net3.net_id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
"request_id": "########",
"state": "available",
"subnet_id": "##id-21##",
"subregion_name": "###region###a",
"subregion_name": "us-east-2a",
"tags": [
{
"key": "name",
Expand Down

0 comments on commit ee34955

Please sign in to comment.