Skip to content

Commit

Permalink
add ovs vsctl , gw chassis, lb healthcheck ut (#4611)
Browse files Browse the repository at this point in the history
* ut: add ovn-vsctl


---------

Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 authored Oct 19, 2024
1 parent 2ac7e2c commit d16bb52
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/ovs/ovn-nb-gateway_chassis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ func (suite *OvnClientTestSuite) testCreateGatewayChassises() {
}
}

func (suite *OvnClientTestSuite) testUpdateGatewayChassis() {
t := suite.T()
t.Parallel()

nbClient := suite.ovnNBClient
lrName := "test-gateway-chassis-update-lr"
lrpName := "test-gateway-chassis-update-lrp"
chassis := "6c322ce8-02b7-42b3-925b-ae24020272a9"
gwChassisName := lrpName + "-" + chassis

err := nbClient.CreateLogicalRouter(lrName)
require.NoError(t, err)

err = nbClient.CreateLogicalRouterPort(lrName, lrpName, "00:11:22:37:af:62", []string{"fd00::c0a8:1001/120"})
require.NoError(t, err)

err = nbClient.CreateGatewayChassises(lrpName, chassis)
require.NoError(t, err)

gwChassis, err := nbClient.GetGatewayChassis(gwChassisName, false)
require.NoError(t, err)
require.NotNil(t, gwChassis)

gwChassis.Priority = 100
err = nbClient.UpdateGatewayChassis(gwChassis, &gwChassis.Priority)
require.NoError(t, err)

gwChassis, err = nbClient.GetGatewayChassis(gwChassisName, false)
require.NoError(t, err)
require.NotNil(t, gwChassis)
require.Equal(t, 100, gwChassis.Priority)
}

func (suite *OvnClientTestSuite) testDeleteGatewayChassises() {
t := suite.T()
t.Parallel()
Expand Down
40 changes: 40 additions & 0 deletions pkg/ovs/ovn-nb-load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,46 @@ func (suite *OvnClientTestSuite) testLoadBalancerAddVip() {
)
}

func (suite *OvnClientTestSuite) testLoadBalancerAddHealthCheck() {
t := suite.T()
t.Parallel()

nbClient := suite.ovnNBClient
lbName := "test-add-hc-lb"
vips := map[string]string{
"10.96.0.5:443": "192.168.20.3:6443",
"10.107.43.241:8080": "10.244.0.15:8080,10.244.0.16:8080,10.244.0.17:8080",
"[fd00:10:96::e86f]:8080": "[fc00::af4:a]:8080,[fc00::af4:b]:8080,[fc00::af4:c]:8080",
}
t.Run("add health check to load balancer",
func(t *testing.T) {
// create load balancer
err := nbClient.CreateLoadBalancer(lbName, "tcp", "")
require.NoError(t, err)
for vip, backends := range vips {
backends := strings.Split(backends, ",")
mappings := make(map[string]string)
for _, backend := range backends {
host, _, err := net.SplitHostPort(backend)
require.NoError(t, err)
mappings[host] = host
}

err := nbClient.LoadBalancerAddVip(lbName, vip, backends...)
require.NoError(t, err)

ignoreHealthCheck := false
err = nbClient.LoadBalancerAddHealthCheck(lbName, vip, ignoreHealthCheck, mappings, nil)
require.NoError(t, err)

lb, err := nbClient.GetLoadBalancer(lbName, false)
require.NoError(t, err)
require.NotNil(t, lb.HealthCheck)
}
},
)
}

func (suite *OvnClientTestSuite) testLoadBalancerDeleteVip() {
t := suite.T()
t.Parallel()
Expand Down
104 changes: 104 additions & 0 deletions pkg/ovs/ovn-nb-suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ func (suite *OvnClientTestSuite) Test_CreateGatewayChassises() {
suite.testCreateGatewayChassises()
}

func (suite *OvnClientTestSuite) Test_UpdateGatewayChassis() {
suite.testUpdateGatewayChassis()
}

func (suite *OvnClientTestSuite) Test_DeleteGatewayChassises() {
suite.testDeleteGatewayChassises()
}
Expand All @@ -469,6 +473,10 @@ func (suite *OvnClientTestSuite) Test_UpdateLoadBalancer() {
suite.testUpdateLoadBalancer()
}

func (suite *OvnClientTestSuite) Test_LoadBalancerAddHealthCheck() {
suite.testLoadBalancerAddHealthCheck()
}

func (suite *OvnClientTestSuite) Test_DeleteLoadBalancers() {
suite.testDeleteLoadBalancers()
}
Expand Down Expand Up @@ -1033,6 +1041,102 @@ func (suite *OvnClientTestSuite) Test_CheckAndUpdateHtbQos() {
suite.testCheckAndUpdateHtbQos()
}

func (suite *OvnClientTestSuite) Test_UpdateOVSVsctlLimiter() {
suite.testUpdateOVSVsctlLimiter()
}

func (suite *OvnClientTestSuite) Test_OvsExec() {
suite.testOvsExec()
}

func (suite *OvnClientTestSuite) Test_OvsCreate() {
suite.testOvsCreate()
}

func (suite *OvnClientTestSuite) Test_OvsDestroy() {
suite.testOvsDestroy()
}

func (suite *OvnClientTestSuite) Test_OvsSet() {
suite.testOvsSet()
}

func (suite *OvnClientTestSuite) Test_OvsAdd() {
suite.testOvsAdd()
}

func (suite *OvnClientTestSuite) Test_OvsFind() {
suite.testOvsFind()
}

func (suite *OvnClientTestSuite) Test_OvsClear() {
suite.testOvsClear()
}

func (suite *OvnClientTestSuite) Test_OvsGet() {
suite.testOvsGet()
}

func (suite *OvnClientTestSuite) Test_OvsFindBridges() {
suite.testOvsFindBridges()
}

func (suite *OvnClientTestSuite) Test_OvsBridgeExists() {
suite.testOvsBridgeExists()
}

func (suite *OvnClientTestSuite) Test_OvsPortExists() {
suite.testOvsPortExists()
}

func (suite *OvnClientTestSuite) Test_GetOvsQosList() {
suite.testGetOvsQosList()
}

func (suite *OvnClientTestSuite) Test_OvsClearPodBandwidth() {
suite.testOvsClearPodBandwidth()
}

func (suite *OvnClientTestSuite) Test_OvsCleanLostInterface() {
suite.testOvsCleanLostInterface()
}

func (suite *OvnClientTestSuite) Test_OvsCleanDuplicatePort() {
suite.testOvsCleanDuplicatePort()
}

func (suite *OvnClientTestSuite) Test_OvsSetPortTag() {
suite.testOvsSetPortTag()
}

func (suite *OvnClientTestSuite) Test_ValidatePortVendor() {
suite.testValidatePortVendor()
}

func (suite *OvnClientTestSuite) Test_GetInterfacePodNs() {
suite.testGetInterfacePodNs()
}

func (suite *OvnClientTestSuite) Test_ConfigInterfaceMirror() {
suite.testConfigInterfaceMirror()
}

func (suite *OvnClientTestSuite) Test_GetResidualInternalPorts() {
suite.testGetResidualInternalPorts()
}

func (suite *OvnClientTestSuite) Test_ClearPortQosBinding() {
suite.testClearPortQosBinding()
}

func (suite *OvnClientTestSuite) Test_OvsListExternalIDs() {
suite.testOvsListExternalIDs()
}

func (suite *OvnClientTestSuite) Test_ListQosQueueIDs() {
suite.testListQosQueueIDs()
}

func Test_scratch(t *testing.T) {
t.SkipNow()
endpoint := "tcp:[172.20.149.35]:6641"
Expand Down
Loading

0 comments on commit d16bb52

Please sign in to comment.