Skip to content

Commit

Permalink
cnf network: add-frrk8-test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Kopels committed Oct 3, 2024
1 parent 13f370c commit 905384c
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 206 deletions.
2 changes: 2 additions & 0 deletions tests/cnf/core/network/metallb/internal/tsparams/mlbvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ var (
ExternalMacVlanNADName = "external"
// HubMacVlanNADName represents default external NetworkAttachmentDefinition name.
HubMacVlanNADName = "nad-hub"
// HubMacVlanNADSecIntName represents a NetworkAttachmentDefinition that includes the master interface.
HubMacVlanNADSecIntName = "nad-hub-sec-int"
// SleepCMD represents shel sleep command.
SleepCMD = []string{"/bin/bash", "-c", "sleep INF"}
// FRRContainerName represents default FRR's container name.
Expand Down
33 changes: 21 additions & 12 deletions tests/cnf/core/network/metallb/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ func createExternalNad(name string) {
Expect(externalNad.Exists()).To(BeTrue(), "Failed to detect external NetworkAttachmentDefinition")
}

func createExternalNadWithMasterInterface(name, masterInterface string) {
By("Creating external BR-EX NetworkAttachmentDefinition")

macVlanPlugin, err := define.MasterNadPlugin(name, "bridge", nad.IPAMStatic(), masterInterface)
Expect(err).ToNot(HaveOccurred(), "Failed to define master nad plugin")
externalNad, err = nad.NewBuilder(APIClient, name, tsparams.TestNamespaceName).
WithMasterPlugin(macVlanPlugin).Create()
Expect(err).ToNot(HaveOccurred(), "Failed to create external NetworkAttachmentDefinition")
Expect(externalNad.Exists()).To(BeTrue(), "Failed to detect external NetworkAttachmentDefinition")
}

func createBGPPeerAndVerifyIfItsReady(
peerIP, bfdProfileName string, remoteAsn uint32, eBgpMultiHop bool, connectTime int,
frrk8sPods []*pod.Builder) {
Expand Down Expand Up @@ -205,28 +216,26 @@ func createFrrPod(

By("Creating FRR container")

frrContainer := pod.NewContainerBuilder(
tsparams.FRRSecondContainerName, NetConfig.CnfNetTestContainer, tsparams.SleepCMD).
WithSecurityCapabilities([]string{"NET_ADMIN", "NET_RAW", "SYS_ADMIN"}, true)
if configmapName != "" {
frrContainer := pod.NewContainerBuilder(
tsparams.FRRSecondContainerName, NetConfig.CnfNetTestContainer, tsparams.SleepCMD).
WithSecurityCapabilities([]string{"NET_ADMIN", "NET_RAW", "SYS_ADMIN"}, true)

frrCtr, err := frrContainer.GetContainerCfg()
Expect(err).ToNot(HaveOccurred(), "Failed to get container configuration")
frrPod.WithAdditionalContainer(frrCtr).WithLocalVolume(configmapName, "/etc/frr")
frrCtr, err := frrContainer.GetContainerCfg()
Expect(err).ToNot(HaveOccurred(), "Failed to get container configuration")
frrPod.WithAdditionalContainer(frrCtr).WithLocalVolume(configmapName, "/etc/frr")
}

By("Creating FRR pod in the test namespace")

frrPod, err = frrPod.WithPrivilegedFlag().CreateAndWaitUntilRunning(time.Minute)
frrPod, err := frrPod.WithPrivilegedFlag().CreateAndWaitUntilRunning(time.Minute)
Expect(err).ToNot(HaveOccurred(), "Failed to create FRR test pod")

return frrPod
}

func createFrrHubPod(name, nodeName, configmapName string, defaultCMD []string,
secondaryNetConfig []*types.NetworkSelectionElement, podName ...string) *pod.Builder {
if len(podName) > 0 {
name = podName[0]
}

secondaryNetConfig []*types.NetworkSelectionElement) *pod.Builder {
frrPod := pod.NewBuilder(APIClient, name, tsparams.TestNamespaceName, NetConfig.FrrImage).
DefineOnNode(nodeName).
WithTolerationToMaster().
Expand Down
Loading

0 comments on commit 905384c

Please sign in to comment.