Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cnf network: add-metallb-frr-test-cases #239

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading