Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
teowa committed Sep 20, 2024
1 parent 1256aae commit be19ff0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func (r StackHCINetworkInterfaceResource) Create() sdk.ResourceFunc {
return fmt.Errorf("performing create %s: %+v", id, err)
}

time.Sleep(2 * time.Minute)
metadata.SetID(id)

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestAccStackHCINetworkInterface_requiresImport(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.dynamic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -181,51 +181,6 @@ resource "azurerm_stack_hci_network_interface" "import" {
`, config)
}

func (r StackHCINetworkInterfaceResource) basic(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%[1]s
provider "azurerm" {
features {}
}
resource "azurerm_stack_hci_logical_network" "test" {
name = "acctest-ln-%[2]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
virtual_switch_name = "ConvergedSwitch(managementcompute)"
dns_servers = ["10.0.0.7"]
subnet {
ip_allocation_method = "Static"
address_prefix = "10.0.11.0/24"
vlan_id = 123
route {
name = "test-route"
address_prefix = "0.0.0.0/0"
next_hop_ip_address = "10.0.0.1"
}
}
}
resource "azurerm_stack_hci_network_interface" "test" {
name = "acctest-ni-%[2]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
dns_servers = ["10.0.0.8"]
mac_address = "02:ec:01:0c:00:07"
ip_configuration {
private_ip_address = "10.0.11.%[4]d"
subnet_id = azurerm_stack_hci_logical_network.test.id
}
}
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100)
}

func (r StackHCINetworkInterfaceResource) updateNoTag(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
Expand All @@ -240,16 +195,15 @@ resource "azurerm_stack_hci_logical_network" "test" {
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
virtual_switch_name = "ConvergedSwitch(managementcompute)"
dns_servers = ["10.0.0.7"]
dns_servers = ["192.168.2.254"]
subnet {
ip_allocation_method = "Static"
address_prefix = "10.0.12.0/24"
vlan_id = 123
address_prefix = "192.168.2.0/24"
route {
name = "test-route"
address_prefix = "0.0.0.0/0"
next_hop_ip_address = "10.0.20.1"
next_hop_ip_address = "192.168.2.1"
}
}
}
Expand All @@ -259,15 +213,15 @@ resource "azurerm_stack_hci_network_interface" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
dns_servers = ["10.0.0.8"]
mac_address = "02:ec:01:0c:00:08"
dns_servers = ["192.168.2.254"]
mac_address = "02:ec:01:0c:00:07"
ip_configuration {
private_ip_address = "10.0.12.%[4]d"
private_ip_address = "192.168.2.%[4]d"
subnet_id = azurerm_stack_hci_logical_network.test.id
}
}
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100)
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100+2)
}

func (r StackHCINetworkInterfaceResource) updateTag(data acceptance.TestData) string {
Expand All @@ -285,16 +239,15 @@ resource "azurerm_stack_hci_logical_network" "test" {
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
virtual_switch_name = "ConvergedSwitch(managementcompute)"
dns_servers = ["10.0.0.7"]
dns_servers = ["192.168.2.254"]
subnet {
ip_allocation_method = "Static"
address_prefix = "10.0.12.0/24"
vlan_id = 123
address_prefix = "192.168.2.0/24"
route {
name = "test-route"
address_prefix = "0.0.0.0/0"
next_hop_ip_address = "10.0.20.1"
next_hop_ip_address = "192.168.2.1"
}
}
}
Expand All @@ -304,19 +257,19 @@ resource "azurerm_stack_hci_network_interface" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
dns_servers = ["10.0.0.8"]
mac_address = "02:ec:01:0c:00:08"
dns_servers = ["192.168.2.254"]
mac_address = "02:ec:01:0c:00:07"
ip_configuration {
private_ip_address = "10.0.12.%[4]d"
private_ip_address = "192.168.2.%[4]d"
subnet_id = azurerm_stack_hci_logical_network.test.id
}
tags = {
foo = "bar"
}
}
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100)
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100+2)
}

func (r StackHCINetworkInterfaceResource) updateTagAgain(data acceptance.TestData) string {
Expand All @@ -334,16 +287,15 @@ resource "azurerm_stack_hci_logical_network" "test" {
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
virtual_switch_name = "ConvergedSwitch(managementcompute)"
dns_servers = ["10.0.0.7"]
dns_servers = ["192.168.2.254"]
subnet {
ip_allocation_method = "Static"
address_prefix = "10.0.12.0/24"
vlan_id = 123
address_prefix = "192.168.2.0/24"
route {
name = "test-route"
address_prefix = "0.0.0.0/0"
next_hop_ip_address = "10.0.20.1"
next_hop_ip_address = "192.168.2.1"
}
}
}
Expand All @@ -353,11 +305,11 @@ resource "azurerm_stack_hci_network_interface" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
dns_servers = ["10.0.0.8"]
mac_address = "02:ec:01:0c:00:08"
dns_servers = ["192.168.2.254"]
mac_address = "02:ec:01:0c:00:07"
ip_configuration {
private_ip_address = "10.0.12.%[4]d"
private_ip_address = "192.168.2.%[4]d"
subnet_id = azurerm_stack_hci_logical_network.test.id
}
Expand All @@ -366,7 +318,7 @@ resource "azurerm_stack_hci_network_interface" "test" {
env = "test"
}
}
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100)
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100+2)
}

func (r StackHCINetworkInterfaceResource) complete(data acceptance.TestData) string {
Expand All @@ -384,16 +336,15 @@ resource "azurerm_stack_hci_logical_network" "test" {
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
virtual_switch_name = "ConvergedSwitch(managementcompute)"
dns_servers = ["10.0.0.7"]
dns_servers = ["192.168.1.254"]
subnet {
ip_allocation_method = "Static"
address_prefix = "10.0.13.0/24"
vlan_id = 123
address_prefix = "192.168.1.0/24"
route {
name = "test-route"
address_prefix = "0.0.0.0/0"
next_hop_ip_address = "10.0.20.1"
next_hop_ip_address = "192.168.1.1"
}
}
}
Expand All @@ -403,11 +354,11 @@ resource "azurerm_stack_hci_network_interface" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
custom_location_id = %[3]q
dns_servers = ["10.0.0.8"]
mac_address = "02:ec:01:0c:00:09"
dns_servers = ["192.168.1.254"]
mac_address = "02:ec:01:0c:00:07"
ip_configuration {
private_ip_address = "10.0.13.%[4]d"
private_ip_address = "192.168.1.%[4]d"
subnet_id = azurerm_stack_hci_logical_network.test.id
}
Expand All @@ -416,7 +367,7 @@ resource "azurerm_stack_hci_network_interface" "test" {
env = "test"
}
}
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100)
`, template, data.RandomString, os.Getenv(customLocationIdEnv), data.RandomInteger%100+3)
}

func (r StackHCINetworkInterfaceResource) template(data acceptance.TestData) string {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/stack_hci_network_interface.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ In addition to the Arguments listed above - the following Attributes are exporte

A `ip_configuration` block exports the following:

* `gateway` - The IPv4 address of the gateway for the Network Interface.
* `gateway` - The IPv4 address of the gateway for the Azure Stack HCI Network Interface.

* `prefix_length` - The prefix length for the address of the Network Interface.
* `prefix_length` - The prefix length for the address of the Azure Stack HCI Network Interface.

## Timeouts

Expand Down

0 comments on commit be19ff0

Please sign in to comment.