From 544de012c2b9b269bf4e21def9203b393fcbd3e4 Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Wed, 25 Sep 2024 15:44:03 -0400 Subject: [PATCH 1/2] split existing test into v4-only and v6-enabled --- apstra/data_source_datacenter_blueprint_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apstra/data_source_datacenter_blueprint_test.go b/apstra/data_source_datacenter_blueprint_test.go index 7419dfee..8d4d90e2 100644 --- a/apstra/data_source_datacenter_blueprint_test.go +++ b/apstra/data_source_datacenter_blueprint_test.go @@ -55,7 +55,7 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { EvpnGenerateType5HostRoutes: &enum.FeatureSwitchEnabled, ExternalRouterMtu: utils.ToPtr(uint16(9002)), // FabricL3Mtu: nil, - Ipv6Enabled: utils.ToPtr(true), + Ipv6Enabled: utils.ToPtr(false), // JunosEvpnDuplicateMacRecoveryTime: nil, // JunosEvpnMaxNexthopAndInterfaceNumber: nil, // JunosEvpnRoutingInstanceVlanAware: nil, @@ -80,7 +80,7 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "external_router_count", "0"), resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "has_uncommitted_changes", "true"), resource.TestCheckResourceAttrWith("data.apstra_datacenter_blueprint.test", "version", testCheckIntGE1), - resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "build_errors_count", "58"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "build_errors_count", "52"), resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "build_warnings_count", "0"), resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_mode", apstra.AntiAffinityModeEnabledStrict.String()), @@ -93,7 +93,7 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "esi_mac_msb", "4"), resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "evpn_type_5_routes", "true"), // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "fabric_mtu", "9170"), - resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "ipv6_applications", "true"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "ipv6_applications", "false"), // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_evpn_max_nexthop_and_interface_number", "true"), // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_evpn_routing_instance_mode_mac_vrf", "true"), // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_ex_overlay_ecmp", "true"), From a0a2a7307e77d2ebc5305db425390bba1642fe26 Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Wed, 25 Sep 2024 16:10:02 -0400 Subject: [PATCH 2/2] use v4-only and v6-version of test --- .../data_source_datacenter_blueprint_test.go | 80 ++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/apstra/data_source_datacenter_blueprint_test.go b/apstra/data_source_datacenter_blueprint_test.go index 8d4d90e2..46dc5975 100644 --- a/apstra/data_source_datacenter_blueprint_test.go +++ b/apstra/data_source_datacenter_blueprint_test.go @@ -35,10 +35,11 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { templateId apstra.ObjectId fabricSettings apstra.FabricSettings checks []resource.TestCheckFunc + ipv6 bool } testCases := map[string]testCase{ - "evpn_all_versions": { + "evpn_all_versions_ipv4": { label: acctest.RandString(5), templateId: "L2_Virtual_EVPN", fabricSettings: apstra.FabricSettings{ @@ -105,6 +106,74 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "optimize_routing_zone_footprint", "true"), }, }, + "evpn_all_versions_ipv6": { + ipv6: true, + label: acctest.RandString(5), + templateId: "L2_Virtual_EVPN", + fabricSettings: apstra.FabricSettings{ + AntiAffinityPolicy: &apstra.AntiAffinityPolicy{ + Algorithm: apstra.AlgorithmHeuristic, + MaxLinksPerPort: 4, + MaxLinksPerSlot: 8, + MaxPerSystemLinksPerPort: 2, + MaxPerSystemLinksPerSlot: 4, + Mode: apstra.AntiAffinityModeEnabledStrict, + }, + // DefaultSviL3Mtu: nil, + EsiMacMsb: utils.ToPtr(uint8(4)), + EvpnGenerateType5HostRoutes: &enum.FeatureSwitchEnabled, + ExternalRouterMtu: utils.ToPtr(uint16(9002)), + // FabricL3Mtu: nil, + Ipv6Enabled: utils.ToPtr(false), + // JunosEvpnDuplicateMacRecoveryTime: nil, + // JunosEvpnMaxNexthopAndInterfaceNumber: nil, + // JunosEvpnRoutingInstanceVlanAware: nil, + // JunosExOverlayEcmp: nil, + // JunosGracefulRestart: nil, + MaxEvpnRoutes: utils.ToPtr(uint32(10001)), + MaxExternalRoutes: utils.ToPtr(uint32(10002)), + MaxFabricRoutes: utils.ToPtr(uint32(10003)), + MaxMlagRoutes: utils.ToPtr(uint32(10004)), + // OptimiseSzFootprint: nil, + // OverlayControlProtocol: nil, + // SpineLeafLinks: nil, + // SpineSuperspineLinks: nil, + }, + checks: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "status", "created"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "superspine_switch_count", "0"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "spine_switch_count", "2"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "leaf_switch_count", "4"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "access_switch_count", "0"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "generic_system_count", "8"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "external_router_count", "0"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "has_uncommitted_changes", "true"), + resource.TestCheckResourceAttrWith("data.apstra_datacenter_blueprint.test", "version", testCheckIntGE1), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "build_errors_count", "58"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "build_warnings_count", "0"), + + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_mode", apstra.AntiAffinityModeEnabledStrict.String()), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_policy.max_links_count_per_slot", "8"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_policy.max_links_count_per_system_per_slot", "4"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_policy.max_links_count_per_port", "4"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "anti_affinity_policy.max_links_count_per_system_per_port", "2"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "default_ip_links_to_generic_mtu", "9002"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "default_svi_l3_mtu", "9000"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "esi_mac_msb", "4"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "evpn_type_5_routes", "true"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "fabric_mtu", "9170"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "ipv6_applications", "true"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_evpn_max_nexthop_and_interface_number", "true"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_evpn_routing_instance_mode_mac_vrf", "true"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_ex_overlay_ecmp", "true"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "junos_graceful_restart", "true"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "max_evpn_routes_count", "10001"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "max_external_routes_count", "10002"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "max_fabric_routes_count", "10003"), + resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "max_mlag_routes_count", "10004"), + // resource.TestCheckResourceAttr("data.apstra_datacenter_blueprint.test", "optimize_routing_zone_footprint", "true"), + }, + }, } for tName, tCase := range testCases { @@ -127,11 +196,16 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { require.NoError(t, err) t.Cleanup(func() { require.NoError(t, client.DeleteBlueprint(ctx, id)) }) - if tCase.fabricSettings.Ipv6Enabled != nil && *tCase.fabricSettings.Ipv6Enabled == true { + if tCase.ipv6 { bpClient, err := client.NewTwoStageL3ClosClient(ctx, id) require.NoError(t, err) - require.NoError(t, bpClient.SetFabricSettings(ctx, &tCase.fabricSettings)) + fs, err := bpClient.GetFabricSettings(ctx) + require.NoError(t, err) + + fs.Ipv6Enabled = utils.ToPtr(true) + err = bpClient.SetFabricSettings(ctx, fs) + require.NoError(t, err) } // add unpredictable name and ID to existing checks