Skip to content

Commit

Permalink
add test case for orphan lag with CT attached
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Apr 30, 2024
1 parent 0285d98 commit 9f3fb7b
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions apstra/resource_datacenter_generic_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,36 @@ func TestResourceDatacenterGenericSystem_A(t *testing.T) {
require.NoError(t, err)
}

attachCtToLag := func(groupLabel string) {
query := new(apstra.PathQuery).
SetBlueprintId(bpClient.Id()).
SetClient(bpClient.Client()).
Node([]apstra.QEEAttribute{{Key: "id", Value: apstra.QEStringVal(leafIds[0])}}).
Out([]apstra.QEEAttribute{apstra.RelationshipTypeHostedInterfaces.QEEAttribute()}).
Node([]apstra.QEEAttribute{
apstra.NodeTypeInterface.QEEAttribute(),
{Key: "name", Value: apstra.QEStringVal("n_interface")},
}).
Out([]apstra.QEEAttribute{apstra.RelationshipTypeLink.QEEAttribute()}).
Node([]apstra.QEEAttribute{
apstra.NodeTypeLink.QEEAttribute(),
{Key: "group_label", Value: apstra.QEStringVal(groupLabel)},
{Key: "link_type", Value: apstra.QEStringVal("aggregate_link")},
})
var response struct {
Items []struct {
Interface struct {
Id apstra.ObjectId `json:"id"`
} `json:"n_interface"`
} `json:"items"`
}
err := query.Do(context.Background(), &response)
require.NoError(t, err)

err = bpClient.SetApplicationPointConnectivityTemplates(context.Background(), response.Items[0].Interface.Id, []apstra.ObjectId{*ct.Id})
require.NoError(t, err)
}

type testStep struct {
genericSystem genericSystem
testCheckFunc resource.TestCheckFunc
Expand Down Expand Up @@ -682,6 +712,65 @@ func TestResourceDatacenterGenericSystem_A(t *testing.T) {
},
},
},
"orphan_lag_with_attached_ct": {
steps: []testStep{
{
genericSystem: genericSystem{
clearCtsOnDestroy: true,
links: []link{
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/11",
targetSwitchTf: 1,
},
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/12",
targetSwitchTf: 1,
groupLabel: "foo",
lagMode: apstra.RackLinkLagModeActive,
},
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/13",
targetSwitchTf: 1,
groupLabel: "bar",
lagMode: apstra.RackLinkLagModeActive,
},
},
},
},
{
preConfig: func() {
attachCtToLag("bar")
},
genericSystem: genericSystem{
clearCtsOnDestroy: true,
links: []link{
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/11",
targetSwitchTf: 1,
},
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/12",
targetSwitchTf: 1,
groupLabel: "foo",
lagMode: apstra.RackLinkLagModeActive,
},
{
targetSwitchId: leafIds[0],
targetSwitchIf: "xe-0/0/13",
targetSwitchTf: 1,
groupLabel: "foo",
lagMode: apstra.RackLinkLagModeActive,
},
},
},
},
},
},
}

for tName, tCase := range testCases {
Expand Down

0 comments on commit 9f3fb7b

Please sign in to comment.