From ae178a459fbe1bfc38cdef4ae46ffeb84954e6ea Mon Sep 17 00:00:00 2001 From: danischm Date: Thu, 6 Jun 2024 16:31:47 -0700 Subject: [PATCH] Fix test prerequisites --- gen/definitions/physical_interface_vrf.yaml | 2 ++ gen/definitions/pim_interface.yaml | 7 ++++++ gen/definitions/subinterface.yaml | 8 +++++++ gen/definitions/subinterface_vrf.yaml | 7 ++++++ gen/definitions/vrf_route_target.yaml | 6 +++++ .../vrf_route_target_address_family.yaml | 6 +++++ .../vrf_route_target_direction.yaml | 6 +++++ gen/definitions/vrf_routing.yaml | 6 +++++ ...source_nxos_physical_interface_vrf_test.go | 1 + .../data_source_nxos_pim_interface_test.go | 17 ++++++++++---- .../data_source_nxos_subinterface_test.go | 15 +++++++++++- .../data_source_nxos_subinterface_vrf_test.go | 11 ++++++++- ...os_vrf_route_target_address_family_test.go | 17 ++++++++++---- ...ce_nxos_vrf_route_target_direction_test.go | 19 +++++++++++---- .../data_source_nxos_vrf_route_target_test.go | 21 ++++++++++++----- .../data_source_nxos_vrf_routing_test.go | 13 +++++++++-- ...source_nxos_physical_interface_vrf_test.go | 1 + .../resource_nxos_pim_interface_test.go | 19 +++++++++++---- .../resource_nxos_subinterface_test.go | 16 ++++++++++++- .../resource_nxos_subinterface_vrf_test.go | 13 +++++++++-- ...os_vrf_route_target_address_family_test.go | 19 +++++++++++---- ...ce_nxos_vrf_route_target_direction_test.go | 21 ++++++++++++----- .../resource_nxos_vrf_route_target_test.go | 23 +++++++++++++------ .../resource_nxos_vrf_routing_test.go | 15 +++++++++--- 24 files changed, 237 insertions(+), 52 deletions(-) diff --git a/gen/definitions/physical_interface_vrf.yaml b/gen/definitions/physical_interface_vrf.yaml index b6fe531e..12aebd48 100644 --- a/gen/definitions/physical_interface_vrf.yaml +++ b/gen/definitions/physical_interface_vrf.yaml @@ -30,3 +30,5 @@ test_prerequisites: attributes: - name: id value: eth1/10 + - name: layer + value: Layer3 diff --git a/gen/definitions/pim_interface.yaml b/gen/definitions/pim_interface.yaml index 894da5b5..a8ff24e3 100644 --- a/gen/definitions/pim_interface.yaml +++ b/gen/definitions/pim_interface.yaml @@ -62,6 +62,13 @@ attributes: default_value: false example: true test_prerequisites: + - dn: sys/intf/phys-[eth1/10] + class_name: l1PhysIf + attributes: + - name: id + value: eth1/10 + - name: layer + value: Layer3 - dn: sys/fm/pim class_name: fmPim no_delete: true diff --git a/gen/definitions/subinterface.yaml b/gen/definitions/subinterface.yaml index 9e0931ed..2dadba08 100644 --- a/gen/definitions/subinterface.yaml +++ b/gen/definitions/subinterface.yaml @@ -78,3 +78,11 @@ attributes: max_int: 9216 default_value: 1500 example: 1500 +test_prerequisites: + - dn: sys/intf/phys-[eth1/10] + class_name: l1PhysIf + attributes: + - name: id + value: eth1/10 + - name: layer + value: Layer3 diff --git a/gen/definitions/subinterface_vrf.yaml b/gen/definitions/subinterface_vrf.yaml index f2d0c0b7..13477557 100644 --- a/gen/definitions/subinterface_vrf.yaml +++ b/gen/definitions/subinterface_vrf.yaml @@ -25,6 +25,13 @@ attributes: description: 'DN of VRF. For example: `sys/inst-VRF1`.' example: sys/inst-VRF123 test_prerequisites: + - dn: sys/intf/phys-[eth1/10] + class_name: l1PhysIf + attributes: + - name: id + value: eth1/10 + - name: layer + value: Layer3 - dn: sys/intf/encrtd-[eth1/10.124] class_name: l3EncRtdIf attributes: diff --git a/gen/definitions/vrf_route_target.yaml b/gen/definitions/vrf_route_target.yaml index 5dea73bf..3e855a9d 100644 --- a/gen/definitions/vrf_route_target.yaml +++ b/gen/definitions/vrf_route_target.yaml @@ -54,6 +54,12 @@ attributes: description: 'Route Target in NX-OS DME format.' example: route-target:as2-nn2:2:2 test_prerequisites: + - dn: sys/fm/bgp + class_name: fmBgp + no_delete: true + attributes: + - name: adminSt + value: enabled - dn: sys/inst-[VRF1] class_name: l3Inst attributes: diff --git a/gen/definitions/vrf_route_target_address_family.yaml b/gen/definitions/vrf_route_target_address_family.yaml index 2bdbad44..0cd02733 100644 --- a/gen/definitions/vrf_route_target_address_family.yaml +++ b/gen/definitions/vrf_route_target_address_family.yaml @@ -39,6 +39,12 @@ attributes: - l2vpn-evpn example: ipv4-ucast test_prerequisites: + - dn: sys/fm/bgp + class_name: fmBgp + no_delete: true + attributes: + - name: adminSt + value: enabled - dn: sys/inst-[VRF1] class_name: l3Inst attributes: diff --git a/gen/definitions/vrf_route_target_direction.yaml b/gen/definitions/vrf_route_target_direction.yaml index 2691f127..97ce73f6 100644 --- a/gen/definitions/vrf_route_target_direction.yaml +++ b/gen/definitions/vrf_route_target_direction.yaml @@ -49,6 +49,12 @@ attributes: - export example: import test_prerequisites: + - dn: sys/fm/bgp + class_name: fmBgp + no_delete: true + attributes: + - name: adminSt + value: enabled - dn: sys/inst-[VRF1] class_name: l3Inst attributes: diff --git a/gen/definitions/vrf_routing.yaml b/gen/definitions/vrf_routing.yaml index 86415ee4..7032e12e 100644 --- a/gen/definitions/vrf_routing.yaml +++ b/gen/definitions/vrf_routing.yaml @@ -25,6 +25,12 @@ attributes: default_value: 'unknown:unknown:0:0' example: 'rd:unknown:0:0' test_prerequisites: + - dn: sys/fm/bgp + class_name: fmBgp + no_delete: true + attributes: + - name: adminSt + value: enabled - dn: sys/inst-[VRF1] class_name: l3Inst attributes: diff --git a/internal/provider/data_source_nxos_physical_interface_vrf_test.go b/internal/provider/data_source_nxos_physical_interface_vrf_test.go index 7a29c349..f96d7e7f 100644 --- a/internal/provider/data_source_nxos_physical_interface_vrf_test.go +++ b/internal/provider/data_source_nxos_physical_interface_vrf_test.go @@ -46,6 +46,7 @@ resource "nxos_rest" "PreReq0" { class_name = "l1PhysIf" content = { id = "eth1/10" + layer = "Layer3" } } diff --git a/internal/provider/data_source_nxos_pim_interface_test.go b/internal/provider/data_source_nxos_pim_interface_test.go index 0439943c..a1f870a8 100644 --- a/internal/provider/data_source_nxos_pim_interface_test.go +++ b/internal/provider/data_source_nxos_pim_interface_test.go @@ -47,6 +47,15 @@ func TestAccDataSourceNxosPIMInterface(t *testing.T) { const testAccDataSourceNxosPIMInterfacePrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/fm/pim" class_name = "fmPim" delete = false @@ -55,19 +64,19 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/pim" class_name = "pimEntity" depends_on = [nxos_rest.PreReq0, ] } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/pim/inst" class_name = "pimInst" depends_on = [nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/pim/inst/dom-[default]" class_name = "pimDom" content = { @@ -88,7 +97,7 @@ resource "nxos_pim_interface" "test" { dr_priority = 10 passive = false sparse_mode = true - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } data "nxos_pim_interface" "test" { diff --git a/internal/provider/data_source_nxos_subinterface_test.go b/internal/provider/data_source_nxos_subinterface_test.go index 09168d03..4d0ab6c1 100644 --- a/internal/provider/data_source_nxos_subinterface_test.go +++ b/internal/provider/data_source_nxos_subinterface_test.go @@ -31,7 +31,7 @@ func TestAccDataSourceNxosSubinterface(t *testing.T) { ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { - Config: testAccDataSourceNxosSubinterfaceConfig, + Config: testAccDataSourceNxosSubinterfacePrerequisitesConfig + testAccDataSourceNxosSubinterfaceConfig, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.nxos_subinterface.test", "interface_id", "eth1/10.124"), resource.TestCheckResourceAttr("data.nxos_subinterface.test", "admin_state", "down"), @@ -48,6 +48,18 @@ func TestAccDataSourceNxosSubinterface(t *testing.T) { }) } +const testAccDataSourceNxosSubinterfacePrerequisitesConfig = ` +resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +` + const testAccDataSourceNxosSubinterfaceConfig = ` resource "nxos_subinterface" "test" { @@ -60,6 +72,7 @@ resource "nxos_subinterface" "test" { link_logging = "enable" medium = "broadcast" mtu = 1500 + depends_on = [nxos_rest.PreReq0, ] } data "nxos_subinterface" "test" { diff --git a/internal/provider/data_source_nxos_subinterface_vrf_test.go b/internal/provider/data_source_nxos_subinterface_vrf_test.go index 5d64183b..cc67fe76 100644 --- a/internal/provider/data_source_nxos_subinterface_vrf_test.go +++ b/internal/provider/data_source_nxos_subinterface_vrf_test.go @@ -42,6 +42,15 @@ func TestAccDataSourceNxosSubinterfaceVRF(t *testing.T) { const testAccDataSourceNxosSubinterfaceVRFPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/intf/encrtd-[eth1/10.124]" class_name = "l3EncRtdIf" content = { @@ -56,7 +65,7 @@ const testAccDataSourceNxosSubinterfaceVRFConfig = ` resource "nxos_subinterface_vrf" "test" { interface_id = "eth1/10.124" vrf_dn = "sys/inst-VRF123" - depends_on = [nxos_rest.PreReq0, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } data "nxos_subinterface_vrf" "test" { diff --git a/internal/provider/data_source_nxos_vrf_route_target_address_family_test.go b/internal/provider/data_source_nxos_vrf_route_target_address_family_test.go index eae1e703..17523feb 100644 --- a/internal/provider/data_source_nxos_vrf_route_target_address_family_test.go +++ b/internal/provider/data_source_nxos_vrf_route_target_address_family_test.go @@ -42,6 +42,15 @@ func TestAccDataSourceNxosVRFRouteTargetAddressFamily(t *testing.T) { const testAccDataSourceNxosVRFRouteTargetAddressFamilyPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -49,7 +58,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -57,13 +66,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -80,7 +89,7 @@ resource "nxos_vrf_route_target_address_family" "test" { vrf = "VRF1" address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } data "nxos_vrf_route_target_address_family" "test" { diff --git a/internal/provider/data_source_nxos_vrf_route_target_direction_test.go b/internal/provider/data_source_nxos_vrf_route_target_direction_test.go index f2e6f595..8c14b5cd 100644 --- a/internal/provider/data_source_nxos_vrf_route_target_direction_test.go +++ b/internal/provider/data_source_nxos_vrf_route_target_direction_test.go @@ -42,6 +42,15 @@ func TestAccDataSourceNxosVRFRouteTargetDirection(t *testing.T) { const testAccDataSourceNxosVRFRouteTargetDirectionPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -49,7 +58,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -57,13 +66,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -72,7 +81,7 @@ resource "nxos_rest" "PreReq3" { depends_on = [nxos_rest.PreReq2, ] } -resource "nxos_rest" "PreReq4" { +resource "nxos_rest" "PreReq5" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]" class_name = "rtctrlAfCtrl" content = { @@ -90,7 +99,7 @@ resource "nxos_vrf_route_target_direction" "test" { address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" direction = "import" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] } data "nxos_vrf_route_target_direction" "test" { diff --git a/internal/provider/data_source_nxos_vrf_route_target_test.go b/internal/provider/data_source_nxos_vrf_route_target_test.go index 884d9340..8033b0fa 100644 --- a/internal/provider/data_source_nxos_vrf_route_target_test.go +++ b/internal/provider/data_source_nxos_vrf_route_target_test.go @@ -42,6 +42,15 @@ func TestAccDataSourceNxosVRFRouteTarget(t *testing.T) { const testAccDataSourceNxosVRFRouteTargetPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -49,7 +58,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -57,13 +66,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -72,7 +81,7 @@ resource "nxos_rest" "PreReq3" { depends_on = [nxos_rest.PreReq2, ] } -resource "nxos_rest" "PreReq4" { +resource "nxos_rest" "PreReq5" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]" class_name = "rtctrlAfCtrl" content = { @@ -81,7 +90,7 @@ resource "nxos_rest" "PreReq4" { depends_on = [nxos_rest.PreReq3, ] } -resource "nxos_rest" "PreReq5" { +resource "nxos_rest" "PreReq6" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]/rttp-[import]" class_name = "rtctrlRttP" content = { @@ -100,7 +109,7 @@ resource "nxos_vrf_route_target" "test" { route_target_address_family = "ipv4-ucast" direction = "import" route_target = "route-target:as2-nn2:2:2" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, nxos_rest.PreReq6, ] } data "nxos_vrf_route_target" "test" { diff --git a/internal/provider/data_source_nxos_vrf_routing_test.go b/internal/provider/data_source_nxos_vrf_routing_test.go index 5e396eea..29ef6f20 100644 --- a/internal/provider/data_source_nxos_vrf_routing_test.go +++ b/internal/provider/data_source_nxos_vrf_routing_test.go @@ -42,6 +42,15 @@ func TestAccDataSourceNxosVRFRouting(t *testing.T) { const testAccDataSourceNxosVRFRoutingPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -49,7 +58,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -64,7 +73,7 @@ const testAccDataSourceNxosVRFRoutingConfig = ` resource "nxos_vrf_routing" "test" { vrf = "VRF1" route_distinguisher = "rd:unknown:0:0" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, ] } data "nxos_vrf_routing" "test" { diff --git a/internal/provider/resource_nxos_physical_interface_vrf_test.go b/internal/provider/resource_nxos_physical_interface_vrf_test.go index 3a563929..609bb51c 100644 --- a/internal/provider/resource_nxos_physical_interface_vrf_test.go +++ b/internal/provider/resource_nxos_physical_interface_vrf_test.go @@ -52,6 +52,7 @@ resource "nxos_rest" "PreReq0" { class_name = "l1PhysIf" content = { id = "eth1/10" + layer = "Layer3" } } diff --git a/internal/provider/resource_nxos_pim_interface_test.go b/internal/provider/resource_nxos_pim_interface_test.go index 032b7690..e21f7c89 100644 --- a/internal/provider/resource_nxos_pim_interface_test.go +++ b/internal/provider/resource_nxos_pim_interface_test.go @@ -53,6 +53,15 @@ func TestAccNxosPIMInterface(t *testing.T) { const testAccNxosPIMInterfacePrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/fm/pim" class_name = "fmPim" delete = false @@ -61,19 +70,19 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/pim" class_name = "pimEntity" depends_on = [nxos_rest.PreReq0, ] } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/pim/inst" class_name = "pimInst" depends_on = [nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/pim/inst/dom-[default]" class_name = "pimDom" content = { @@ -89,7 +98,7 @@ func testAccNxosPIMInterfaceConfig_minimum() string { resource "nxos_pim_interface" "test" { vrf_name = "default" interface_id = "eth1/10" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } ` } @@ -104,7 +113,7 @@ func testAccNxosPIMInterfaceConfig_all() string { dr_priority = 10 passive = false sparse_mode = true - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } ` } diff --git a/internal/provider/resource_nxos_subinterface_test.go b/internal/provider/resource_nxos_subinterface_test.go index 82a102d4..fcae8367 100644 --- a/internal/provider/resource_nxos_subinterface_test.go +++ b/internal/provider/resource_nxos_subinterface_test.go @@ -31,7 +31,7 @@ func TestAccNxosSubinterface(t *testing.T) { ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { - Config: testAccNxosSubinterfaceConfig_all(), + Config: testAccNxosSubinterfacePrerequisitesConfig + testAccNxosSubinterfaceConfig_all(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("nxos_subinterface.test", "interface_id", "eth1/10.124"), resource.TestCheckResourceAttr("nxos_subinterface.test", "admin_state", "down"), @@ -53,10 +53,23 @@ func TestAccNxosSubinterface(t *testing.T) { }) } +const testAccNxosSubinterfacePrerequisitesConfig = ` +resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +` + func testAccNxosSubinterfaceConfig_minimum() string { return ` resource "nxos_subinterface" "test" { interface_id = "eth1/10.124" + depends_on = [nxos_rest.PreReq0, ] } ` } @@ -73,6 +86,7 @@ func testAccNxosSubinterfaceConfig_all() string { link_logging = "enable" medium = "broadcast" mtu = 1500 + depends_on = [nxos_rest.PreReq0, ] } ` } diff --git a/internal/provider/resource_nxos_subinterface_vrf_test.go b/internal/provider/resource_nxos_subinterface_vrf_test.go index ec634cc8..270de24a 100644 --- a/internal/provider/resource_nxos_subinterface_vrf_test.go +++ b/internal/provider/resource_nxos_subinterface_vrf_test.go @@ -48,6 +48,15 @@ func TestAccNxosSubinterfaceVRF(t *testing.T) { const testAccNxosSubinterfaceVRFPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/intf/phys-[eth1/10]" + class_name = "l1PhysIf" + content = { + id = "eth1/10" + layer = "Layer3" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/intf/encrtd-[eth1/10.124]" class_name = "l3EncRtdIf" content = { @@ -62,7 +71,7 @@ func testAccNxosSubinterfaceVRFConfig_minimum() string { resource "nxos_subinterface_vrf" "test" { interface_id = "eth1/10.124" vrf_dn = "sys/inst-VRF123" - depends_on = [nxos_rest.PreReq0, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } ` } @@ -72,7 +81,7 @@ func testAccNxosSubinterfaceVRFConfig_all() string { resource "nxos_subinterface_vrf" "test" { interface_id = "eth1/10.124" vrf_dn = "sys/inst-VRF123" - depends_on = [nxos_rest.PreReq0, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } ` } diff --git a/internal/provider/resource_nxos_vrf_route_target_address_family_test.go b/internal/provider/resource_nxos_vrf_route_target_address_family_test.go index f7902ef6..cc03b537 100644 --- a/internal/provider/resource_nxos_vrf_route_target_address_family_test.go +++ b/internal/provider/resource_nxos_vrf_route_target_address_family_test.go @@ -49,6 +49,15 @@ func TestAccNxosVRFRouteTargetAddressFamily(t *testing.T) { const testAccNxosVRFRouteTargetAddressFamilyPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -56,7 +65,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -64,13 +73,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -87,7 +96,7 @@ func testAccNxosVRFRouteTargetAddressFamilyConfig_minimum() string { vrf = "VRF1" address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } ` } @@ -98,7 +107,7 @@ func testAccNxosVRFRouteTargetAddressFamilyConfig_all() string { vrf = "VRF1" address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] } ` } diff --git a/internal/provider/resource_nxos_vrf_route_target_direction_test.go b/internal/provider/resource_nxos_vrf_route_target_direction_test.go index bcbba942..fe8574e9 100644 --- a/internal/provider/resource_nxos_vrf_route_target_direction_test.go +++ b/internal/provider/resource_nxos_vrf_route_target_direction_test.go @@ -50,6 +50,15 @@ func TestAccNxosVRFRouteTargetDirection(t *testing.T) { const testAccNxosVRFRouteTargetDirectionPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -57,7 +66,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -65,13 +74,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -80,7 +89,7 @@ resource "nxos_rest" "PreReq3" { depends_on = [nxos_rest.PreReq2, ] } -resource "nxos_rest" "PreReq4" { +resource "nxos_rest" "PreReq5" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]" class_name = "rtctrlAfCtrl" content = { @@ -98,7 +107,7 @@ func testAccNxosVRFRouteTargetDirectionConfig_minimum() string { address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" direction = "import" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] } ` } @@ -110,7 +119,7 @@ func testAccNxosVRFRouteTargetDirectionConfig_all() string { address_family = "ipv4-ucast" route_target_address_family = "ipv4-ucast" direction = "import" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] } ` } diff --git a/internal/provider/resource_nxos_vrf_route_target_test.go b/internal/provider/resource_nxos_vrf_route_target_test.go index 70bcd82e..1a65dd4b 100644 --- a/internal/provider/resource_nxos_vrf_route_target_test.go +++ b/internal/provider/resource_nxos_vrf_route_target_test.go @@ -51,6 +51,15 @@ func TestAccNxosVRFRouteTarget(t *testing.T) { const testAccNxosVRFRouteTargetPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -58,7 +67,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -66,13 +75,13 @@ resource "nxos_rest" "PreReq1" { } } -resource "nxos_rest" "PreReq2" { +resource "nxos_rest" "PreReq3" { dn = "sys/inst-[VRF1]/dom-[VRF1]" class_name = "rtctrlDom" depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] } -resource "nxos_rest" "PreReq3" { +resource "nxos_rest" "PreReq4" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]" class_name = "rtctrlDomAf" content = { @@ -81,7 +90,7 @@ resource "nxos_rest" "PreReq3" { depends_on = [nxos_rest.PreReq2, ] } -resource "nxos_rest" "PreReq4" { +resource "nxos_rest" "PreReq5" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]" class_name = "rtctrlAfCtrl" content = { @@ -90,7 +99,7 @@ resource "nxos_rest" "PreReq4" { depends_on = [nxos_rest.PreReq3, ] } -resource "nxos_rest" "PreReq5" { +resource "nxos_rest" "PreReq6" { dn = "sys/inst-[VRF1]/dom-[VRF1]/af-[ipv4-ucast]/ctrl-[ipv4-ucast]/rttp-[import]" class_name = "rtctrlRttP" content = { @@ -109,7 +118,7 @@ func testAccNxosVRFRouteTargetConfig_minimum() string { route_target_address_family = "ipv4-ucast" direction = "import" route_target = "route-target:as2-nn2:2:2" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, nxos_rest.PreReq6, ] } ` } @@ -122,7 +131,7 @@ func testAccNxosVRFRouteTargetConfig_all() string { route_target_address_family = "ipv4-ucast" direction = "import" route_target = "route-target:as2-nn2:2:2" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, nxos_rest.PreReq3, nxos_rest.PreReq4, nxos_rest.PreReq5, nxos_rest.PreReq6, ] } ` } diff --git a/internal/provider/resource_nxos_vrf_routing_test.go b/internal/provider/resource_nxos_vrf_routing_test.go index 5a19e1ed..ad88197a 100644 --- a/internal/provider/resource_nxos_vrf_routing_test.go +++ b/internal/provider/resource_nxos_vrf_routing_test.go @@ -48,6 +48,15 @@ func TestAccNxosVRFRouting(t *testing.T) { const testAccNxosVRFRoutingPrerequisitesConfig = ` resource "nxos_rest" "PreReq0" { + dn = "sys/fm/bgp" + class_name = "fmBgp" + delete = false + content = { + adminSt = "enabled" + } +} + +resource "nxos_rest" "PreReq1" { dn = "sys/inst-[VRF1]" class_name = "l3Inst" content = { @@ -55,7 +64,7 @@ resource "nxos_rest" "PreReq0" { } } -resource "nxos_rest" "PreReq1" { +resource "nxos_rest" "PreReq2" { dn = "sys/ipv4/inst/dom-[VRF1]" class_name = "ipv4Dom" content = { @@ -69,7 +78,7 @@ func testAccNxosVRFRoutingConfig_minimum() string { return ` resource "nxos_vrf_routing" "test" { vrf = "VRF1" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, ] } ` } @@ -79,7 +88,7 @@ func testAccNxosVRFRoutingConfig_all() string { resource "nxos_vrf_routing" "test" { vrf = "VRF1" route_distinguisher = "rd:unknown:0:0" - depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, ] + depends_on = [nxos_rest.PreReq0, nxos_rest.PreReq1, nxos_rest.PreReq2, ] } ` }