From bbab2d93349c436fa62a300c8c5f979ef9b0ee9c Mon Sep 17 00:00:00 2001 From: Yurii Prokulevych Date: Thu, 5 Sep 2024 13:10:48 +0200 Subject: [PATCH] system-test: access URL is reachaable via FRR container --- .../rdscore/internal/rdscorecommon/frr-bgp.go | 70 +++++++++++++++++++ .../rdscore/internal/rdscoreconfig/config.go | 4 ++ .../internal/rdscoreconfig/default.yaml | 2 + .../rdscore/internal/rdscoreparams/const.go | 9 +++ .../rdscore/tests/00_validate_top_level.go | 12 ++++ 5 files changed, 97 insertions(+) create mode 100644 tests/system-tests/rdscore/internal/rdscorecommon/frr-bgp.go diff --git a/tests/system-tests/rdscore/internal/rdscorecommon/frr-bgp.go b/tests/system-tests/rdscore/internal/rdscorecommon/frr-bgp.go new file mode 100644 index 000000000..26bbe1dd2 --- /dev/null +++ b/tests/system-tests/rdscore/internal/rdscorecommon/frr-bgp.go @@ -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") + } + } +} diff --git a/tests/system-tests/rdscore/internal/rdscoreconfig/config.go b/tests/system-tests/rdscore/internal/rdscoreconfig/config.go index d99346844..b2491744c 100644 --- a/tests/system-tests/rdscore/internal/rdscoreconfig/config.go +++ b/tests/system-tests/rdscore/internal/rdscoreconfig/config.go @@ -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"` diff --git a/tests/system-tests/rdscore/internal/rdscoreconfig/default.yaml b/tests/system-tests/rdscore/internal/rdscoreconfig/default.yaml index c3eef4a6a..49810e71b 100644 --- a/tests/system-tests/rdscore/internal/rdscoreconfig/default.yaml +++ b/tests/system-tests/rdscore/internal/rdscoreconfig/default.yaml @@ -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: '' diff --git a/tests/system-tests/rdscore/internal/rdscoreparams/const.go b/tests/system-tests/rdscore/internal/rdscoreparams/const.go index 4e187ab8c..7facb9271 100644 --- a/tests/system-tests/rdscore/internal/rdscoreparams/const.go +++ b/tests/system-tests/rdscore/internal/rdscoreparams/const.go @@ -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" ) diff --git a/tests/system-tests/rdscore/tests/00_validate_top_level.go b/tests/system-tests/rdscore/tests/00_validate_top_level.go index ab96b2b78..7e04cd4fd 100644 --- a/tests/system-tests/rdscore/tests/00_validate_top_level.go +++ b/tests/system-tests/rdscore/tests/00_validate_top_level.go @@ -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) @@ -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() { @@ -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) }) })