Skip to content

Commit

Permalink
Update e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Oct 9, 2024
1 parent 7ead341 commit 4b449d4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/e2e/nsx_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,11 @@ func SubnetCIDR(t *testing.T) {
})
assertNil(t, err)

nsxSubnets, err := testData.getSubnet(E2ENamespace)
t.Logf("Check NSX Subnet: %+v, error: %+v", nsxSubnets, err)
nsxSubnets, err := testData.getSubnet(E2ENamespace, true)
for i, nsxSubnet := range nsxSubnets {
t.Logf("Subnet in NSX: %d, id: %s, PATH: %s, DisplayName: %s, MarkedForDelete: %t, Tags: %v", i, *nsxSubnet.Id, *nsxSubnet.Path, *nsxSubnet.DisplayName, *nsxSubnet.MarkedForDelete, nsxSubnet.Tags)
}
t.Logf("Check NSX Subnet num: %d, error: %+v", len(nsxSubnets), err)

subnet.Spec.IPAddresses = []string{targetCIDR}
_, err = testData.crdClientset.CrdV1alpha1().Subnets(E2ENamespace).Create(context.TODO(), subnet, v1.CreateOptions{})
Expand All @@ -335,11 +338,20 @@ func SubnetCIDR(t *testing.T) {
})
assertNil(t, err)

nsxSubnets, err = testData.getSubnet(E2ENamespace)
t.Logf("Check NSX Subnet: %+v, error: %+v", nsxSubnets, err)
nsxSubnets, err = testData.getSubnet(E2ENamespace, true)
for i, nsxSubnet := range nsxSubnets {
t.Logf("Subnet in NSX: %d, id: %s, PATH: %s, DisplayName: %s, MarkedForDelete: %t, Tags: %v", i, *nsxSubnet.Id, *nsxSubnet.Path, *nsxSubnet.DisplayName, *nsxSubnet.MarkedForDelete, nsxSubnet.Tags)
}
t.Logf("Check NSX Subnet num: %d, error: %+v", len(nsxSubnets), err)

nsxSubnets, err = testData.getSubnet(E2ENamespace, false)
for i, nsxSubnet := range nsxSubnets {
t.Logf("Subnet in NSX: %d, id: %s, PATH: %s, DisplayName: %s, MarkedForDelete: %t, Tags: %v", i, *nsxSubnet.Id, *nsxSubnet.Path, *nsxSubnet.DisplayName, *nsxSubnet.MarkedForDelete, nsxSubnet.Tags)
}
t.Logf("Check NSX Subnet num(not include MarkForDelete): %d, error: %+v", len(nsxSubnets), err)
}

func (data *TestData) getSubnet(ns string) ([]model.VpcSubnet, error) {
func (data *TestData) getSubnet(ns string, includeMarkForDelete bool) ([]model.VpcSubnet, error) {
ctx := context.Background()
networkinfo, err := data.crdClientset.CrdV1alpha1().NetworkInfos(ns).Get(ctx, ns, v1.GetOptions{})
if err != nil {
Expand All @@ -358,7 +370,6 @@ func (data *TestData) getSubnet(ns string) ([]model.VpcSubnet, error) {

parts := strings.Split(vpcInfo, "/")
orgID, projectID, vpcID := parts[2], parts[4], parts[6]
includeMarkForDelete := true
nsxSubnets, err := testData.nsxClient.SubnetsClient.List(orgID, projectID, vpcID, nil, &includeMarkForDelete, nil, nil, nil, nil)
return nsxSubnets.Results, err
}

0 comments on commit 4b449d4

Please sign in to comment.