Skip to content

Commit

Permalink
system-test: access URL is reachaable via FRR container
Browse files Browse the repository at this point in the history
  • Loading branch information
yprokule committed Sep 5, 2024
1 parent ec91e81 commit bbab2d9
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/system-tests/rdscore/internal/rdscorecommon/frr-bgp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package rdscorecommon

import (
"fmt"
"strings"
"time"

"github.com/golang/glog"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/openshift-kni/eco-gotests/tests/system-tests/rdscore/internal/rdscoreinittools"
"github.com/openshift-kni/eco-gotests/tests/system-tests/rdscore/internal/rdscoreparams"
)

// ReachURLviaFRRroute test URL via route learned by MetalLB FRR.
func ReachURLviaFRRroute(ctx SpecContext) {
By("Asserting if test URL is provided")

if RDSCoreConfig.MetalLBFRRTestURLIPv4 == "" && RDSCoreConfig.MetalLBFRRTestURLIPv6 == "" {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof(
"Test URLs for MetalLB FRR testing not specified or are empty. Skipping...")
Skip("Test URL for MetalLB FRR testing not specified or are empty")
}

By("Finding MetalLB-FRR pods")

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Searching for pods in %q namespace with %q label",
rdscoreparams.MetalLBOperatorNamespace, rdscoreparams.MetalLBFRRPodSelector)

frrPodList := findPodWithSelector(rdscoreparams.MetalLBOperatorNamespace,
rdscoreparams.MetalLBFRRPodSelector)

Expect(len(frrPodList)).ToNot(Equal(0), "No MetalLB FRR pods found")

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Found %d 'frr' pods", len(frrPodList))

for _, _pod := range frrPodList {
for _, testURL := range []string{RDSCoreConfig.MetalLBFRRTestURLIPv4, RDSCoreConfig.MetalLBFRRTestURLIPv6} {
if testURL == "" {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Empty URL continue")

continue
}

cmd := fmt.Sprintf("curl -Ls --max-time 5 -o /dev/null -w '%%{http_code}' %s", testURL)

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Running command %q from within pod %s",
cmd, _pod.Definition.Name)

Eventually(func() bool {
output, err := _pod.ExecCommand([]string{"/bin/sh", "-c", cmd},
rdscoreparams.MetalLBFRRContainerName)

if err != nil {
glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Failed to run command due to: %v", err)

return false
}

glog.V(rdscoreparams.RDSCoreLogLevel).Infof("Command's Output:\n%v\n", output.String())

codesPattern := "200 404"

return strings.Contains(codesPattern, strings.Trim(output.String(), "'"))
}).WithContext(ctx).WithPolling(5*time.Second).WithTimeout(1*time.Minute).Should(BeTrue(),
"Error fetching outside URL from within pod")
}
}
}
4 changes: 4 additions & 0 deletions tests/system-tests/rdscore/internal/rdscoreconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ type CoreConfig struct {
WlkdSRIOVTwoSa string `yaml:"rdscore_wlkd_sriov_two_sa" envconfig:"ECO_RDSCORE_WLKD_SRIOV_TWO_SA"`
NROPSchedulerName string `yaml:"rdscore_nrop_scheduler_name" envconfig:"ECO_RDSCORE_NROP_SCHEDULER_NAME"`
//nolint:lll
MetalLBFRRTestURLIPv4 string `yaml:"rdscore_metallb_frr_test_url_ipv4" envconfig:"ECO_RDSCORE_METALLB_FRR_TEST_URL_IPV4"`
//nolint:lll
MetalLBFRRTestURLIPv6 string `yaml:"rdscore_metallb_frr_test_url_ipv6" envconfig:"ECO_RDSCORE_METALLB_FRR_TEST_URL_IPV6"`
//nolint:lll
WlkdSRIOVConfigMapDataOne EnvMapString `yaml:"rdscore_wlkd_sriov_cm_data_one" envconfig:"ECO_RDSCORE_SRIOV_CM_DATA_ONE"`
//nolint:lll
WlkdSRIOVConfigMapDataTwo EnvMapString `yaml:"rdscore_wlkd_sriov_cm_data_two" envconfig:"ECO_RDSCORE_SRIOV_CM_DATA_TWO"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ rdscore_sc_cephrbd_name: ''
rdscore_kdump_cp_node_label: 'node-role.kubernetes.io/control-plane=""'
rdscore_kdump_worker_node_label: 'node-role.kubernetes.io/standard=""'
rdscore_kdump_cnf_node_label: 'node-role.kubernetes.io/customcnf=""'
rdscore_metallb_frr_test_url_ipv4: ''
rdscore_metallb_frr_test_url_ipv6: ''
9 changes: 9 additions & 0 deletions tests/system-tests/rdscore/internal/rdscoreparams/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ const (

// LabelValidateSRIOV a label to select tests for SR-IOV validation.
LabelValidateSRIOV = "rds-core-validate-sriov"

// MetalLBOperatorNamespace MetalLB operator namespace.
MetalLBOperatorNamespace = "metallb-system"

// MetalLBFRRPodSelector pod selector for MetalLB-FRR pods.
MetalLBFRRPodSelector = "app=frr-k8s"

// MetalLBFRRContainerName name of the FRR container within a pod.
MetalLBFRRContainerName = "frr"
)
12 changes: 12 additions & 0 deletions tests/system-tests/rdscore/tests/00_validate_top_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var _ = Describe(
ContinueOnFailure,
Label("rds-core-workflow"), func() {
Context("Configured Cluster", Label("clean-cluster"), func() {
It("Verifies workload reachable over BGP route",
Label("frr"), reportxml.ID("76009"),
rdscorecommon.ReachURLviaFRRroute)

It("Verifies KDump service on Control Plane node",
Label("kdump", "kdump-cp"), reportxml.ID("75620"),
rdscorecommon.VerifyKDumpOnControlPlane)
Expand Down Expand Up @@ -279,6 +283,10 @@ var _ = Describe(
It("Verifies IPVLAN workloads on different nodes post hard reboot",
Label("ipvlan", "verify-ipvlan-different-nodes"), reportxml.ID("75059"),
rdscorecommon.VerifyIPVLANConnectivityBetweenDifferentNodes)

It("Verifies workload reachable over BGP route post hard reboot",
Label("frr"), reportxml.ID("76010"),
rdscorecommon.ReachURLviaFRRroute)
})

Context("Graceful Cluster Reboot", Label("graceful-cluster-reboot"), func() {
Expand Down Expand Up @@ -409,5 +417,9 @@ var _ = Describe(
It("Verifies IPVLAN workloads on different nodes post soft reboot",
Label("ipvlan", "verify-ipvlan-different-nodes"), reportxml.ID("75058"),
rdscorecommon.VerifyIPVLANConnectivityBetweenDifferentNodes)

It("Verifies workload reachable over BGP route post soft reboot",
Label("frr"), reportxml.ID("76011"),
rdscorecommon.ReachURLviaFRRroute)
})
})

0 comments on commit bbab2d9

Please sign in to comment.