Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
65 changes: 0 additions & 65 deletions tests/networking/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ import (
"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/utils/deployment"
"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/utils/service"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"

"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/globalhelper"
appsv1 "k8s.io/api/apps/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -436,66 +434,3 @@ func DefineDeploymentWithContainerPorts(name, namespace string,

return deploymentStruct, nil
}

func DefineDpdkPod(podName, namespace string) *corev1.Pod {
cpuLimit := "1"
memoryLimit := "512Mi"
containerCommand := []string{"/bin/sh", "-c", "touch /tmp/healthy", "sleep infinity"}

containerResource := corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse(cpuLimit),
corev1.ResourceMemory: resource.MustParse(memoryLimit),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse(cpuLimit),
corev1.ResourceMemory: resource.MustParse(memoryLimit),
},
}

containerSecurityContext := &corev1.SecurityContext{
Privileged: ptr.To[bool](true),
RunAsUser: ptr.To[int64](0),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"IPC_LOCK", "SYS_RESOURCE", "NET_RAW"}},
}

annotations := make(map[string]string)
annotations["k8s.v1.cni.cncf.io/networks"] = "sriovnet1"

return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Namespace: namespace,
Labels: tsparams.TestDeploymentLabels,
Annotations: annotations,
},
Spec: corev1.PodSpec{
TerminationGracePeriodSeconds: ptr.To[int64](0),
Containers: []corev1.Container{
{
Name: "app-container",
Image: "registry.redhat.io/openshift4/dpdk-base-rhel8:v4.9",
Command: containerCommand,
Resources: containerResource,
SecurityContext: containerSecurityContext,
VolumeMounts: []corev1.VolumeMount{
{
Name: "hugepage",
MountPath: "/dev/hugepages",
},
}},
},
Volumes: []corev1.Volume{
{
Name: "hugepage",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumHugePages,
},
},
},
},
},
}
}
57 changes: 0 additions & 57 deletions tests/networking/helper/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestFindListIntersections(t *testing.T) {
Expand Down Expand Up @@ -108,58 +106,3 @@ func TestCreateContainerSpecsFromContainerPorts(t *testing.T) {
}
}
}

func TestDefineDpdkPod(t *testing.T) {
testCases := []struct {
name string
namespace string
expected *corev1.Pod
}{
{
name: "test-pod",
namespace: "test-namespace",
expected: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pod",
Namespace: "test-namespace",
Labels: map[string]string{
"app": "test-pod",
},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "app-container",
Image: "registry.redhat.io/openshift4/dpdk-base-rhel8:v4.9",
Ports: []corev1.ContainerPort{
{
Name: "port1",
ContainerPort: 80,
},
},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
"intel.com/intel_sriov_netdevice": resource.MustParse("1"),
},
},
},
},
NodeSelector: nil,
HostNetwork: false,
HostPID: false,
HostIPC: false,
},
},
},
}

for _, testCase := range testCases {
pod := DefineDpdkPod(testCase.name, testCase.namespace)
assert.Equal(t, testCase.expected.Spec.Containers[0].Name, pod.Spec.Containers[0].Name)
assert.Equal(t, testCase.expected.Spec.Containers[0].Image, pod.Spec.Containers[0].Image)
assert.Equal(t, testCase.expected.Spec.NodeSelector, pod.Spec.NodeSelector)
assert.Equal(t, testCase.expected.Spec.HostNetwork, pod.Spec.HostNetwork)
assert.Equal(t, testCase.expected.Spec.HostPID, pod.Spec.HostPID)
assert.Equal(t, testCase.expected.Spec.HostIPC, pod.Spec.HostIPC)
}
}
8 changes: 2 additions & 6 deletions tests/networking/parameters/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
CertsuiteUndeclaredContainerPortsUsageTcName = "networking-undeclared-container-ports-usage"
CertsuiteReservedPartnerPortsTcName = "networking-reserved-partner-ports"
CertsuiteDualStackServiceTcName = "networking-dual-stack-service"
CertsuiteDpdkCPUPinningExecProbe = "networking-dpdk-cpu-pinning-exec-probe"

DpdkPodName = "dpdk-pod"
NetworkingTestSkipLabel = map[string]string{"redhat-best-practices-for-k8s.com/skip_connectivity_tests": ""}
NetworkingTestMultusSkipLabel = map[string]string{"redhat-best-practices-for-k8s.com/skip_multus_connectivity_tests": ""}
NetworkingTestSkipLabel = map[string]string{"redhat-best-practices-for-k8s.com/skip_connectivity_tests": ""}
NetworkingTestMultusSkipLabel = map[string]string{"redhat-best-practices-for-k8s.com/skip_multus_connectivity_tests": ""}

Check failure on line 37 in tests/networking/parameters/parameters.go

View workflow job for this annotation

GitHub Actions / lint

The line is 137 characters long, which exceeds the maximum of 135 characters. (lll)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebrandon1 How did this pass linting before? It looks like someone manual adjusted the formatting, which isn't great, can we just update the linter? Otherwise every PR in this file has to be manually edited.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rocrisp Just add an "Enter" between the lines and the gofmt will fix it. It's just since the variables are now "together" the gofmt is trying to space everything the same.

)

type IPOutputInterface struct {
Expand Down Expand Up @@ -71,7 +68,6 @@
CertsuiteNetworkingPtpDaemonTcName = "networking-ptp-daemon"
CertsuiteNetworkingRestartUnderTestTcName = "networking-restart-on-reboot"
CertsuiteNetworkingDpdkCPUPinningTcName = "networking-dpdk-cpu-pinning"
CertsuiteNetworkingDpdkExecProbeTcName = "networking-dpdk-cpu-pinning-exec-probe"
CertsuiteNetworkingMultipleIPTcName = "networking-multiple-ip-families"
CertsuiteNetworkingMultusBridgeTcName = "networking-multus-bridge"
CertsuiteNetworkingMultusIpamTcName = "networking-multus-ipam"
Expand Down
63 changes: 63 additions & 0 deletions tests/performance/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,66 @@ func DefineRtPodInIsolatedCPUPool(namespace string, rtc *nodev1.RuntimeClass) (*

return testPod, nil
}

func DefineDpdkPod(podName, namespace string) *corev1.Pod {
cpuLimit := "1"
memoryLimit := "512Mi"
containerCommand := []string{"/bin/sh", "-c", "touch /tmp/healthy && sleep infinity"}

containerResource := corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse(cpuLimit),
corev1.ResourceMemory: resource.MustParse(memoryLimit),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse(cpuLimit),
corev1.ResourceMemory: resource.MustParse(memoryLimit),
},
}

containerSecurityContext := &corev1.SecurityContext{
Privileged: ptr.To[bool](true),
RunAsUser: ptr.To[int64](0),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"IPC_LOCK", "SYS_RESOURCE", "NET_RAW"}},
}

annotations := make(map[string]string)
annotations["k8s.v1.cni.cncf.io/networks"] = "sriovnet1"

return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Namespace: namespace,
Labels: tsparams.CertsuiteTargetPodLabels,
Annotations: annotations,
},
Spec: corev1.PodSpec{
TerminationGracePeriodSeconds: ptr.To[int64](0),
Containers: []corev1.Container{
{
Name: "app-container",
Image: "registry.redhat.io/openshift4/dpdk-base-rhel8:v4.9",
Command: containerCommand,
Resources: containerResource,
SecurityContext: containerSecurityContext,
VolumeMounts: []corev1.VolumeMount{
{
Name: "hugepage",
MountPath: "/dev/hugepages",
},
}},
},
Volumes: []corev1.Volume{
{
Name: "hugepage",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumHugePages,
},
},
},
},
},
}
}
2 changes: 2 additions & 0 deletions tests/performance/parameters/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
testPodLabelValue = "testing"
TestPodLabel = fmt.Sprintf("%s: %s", testPodLabelPrefixName, testPodLabelValue)
TestPodName = "performance-pod"
DpdkPodName = "dpdk-pod"
CertsuiteTargetPodLabels = map[string]string{
testPodLabelPrefixName: testPodLabelValue,
"app": "test",
Expand All @@ -32,6 +33,7 @@ const (
CertsuiteRtIsolatedCPUPoolSchedulingPolicy = "performance-isolated-cpu-pool-rt-scheduling-policy"
CertsuiteRtExclusiveCPUPoolSchedulingPolicy = "performance-exclusive-cpu-pool-rt-scheduling-policy"
CertsuiteRtAppsNoExecProbes = "performance-rt-apps-no-exec-probes"
CertsuiteCPUPinningNoExecProbes = "performance-cpu-pinning-no-exec-probes"

PrivilegedRoleName = "privileged-role"
CertsuiteRunTimeClass = "performance-rtc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import (
"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/globalhelper"
"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/globalparameters"

tshelper "github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/networking/helper"
tsparams "github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/networking/parameters"
tshelper "github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/performance/helper"
tsparams "github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/performance/parameters"
"github.com/redhat-best-practices-for-k8s/certsuite-qe/tests/utils/pod"
)

/*
The setup needs to be as mentioned here :
The setup needs to be as mentioned here:
https://developers.redhat.com/articles/2021/08/27/using-virtual-functions-dpdk-red-hat-openshift
*/

var _ = Describe("Networking dpdk-cpu-pinning-exec-probe,", func() {
var _ = Describe("performance-cpu-pinning-no-exec-probes", func() {
var randomNamespace string
var randomReportDir string
var randomCertsuiteConfigDir string

BeforeEach(func() {
// Create random namespace and keep original report and certsuite config directories
randomNamespace, randomReportDir, randomCertsuiteConfigDir =
globalhelper.BeforeEachSetupWithRandomNamespace(tsparams.TestNetworkingNameSpace)
globalhelper.BeforeEachSetupWithRandomNamespace(tsparams.PerformanceNamespace)

By("Define certsuite config file")
err := globalhelper.DefineCertsuiteConfig(
Expand Down Expand Up @@ -54,28 +54,28 @@ var _ = Describe("Networking dpdk-cpu-pinning-exec-probe,", func() {
})

It("one dpdk pod with no probe", func() {
By("Deploy dpdk pod namespace")
By("Deploy dpdk pod")
dpdkPod := tshelper.DefineDpdkPod(tsparams.DpdkPodName, randomNamespace)
err := globalhelper.CreateAndWaitUntilPodIsReady(dpdkPod, tsparams.WaitingTime)
if err != nil {
Skip("DPDK is not deployed. There may be some problems in setup. Hence, skipping.")
}

By("Start tests")
By("Start cpu-pinning-no-exec-probes test")
err = globalhelper.LaunchTests(
tsparams.CertsuiteDpdkCPUPinningExecProbe,
tsparams.CertsuiteCPUPinningNoExecProbes,
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()), randomReportDir, randomCertsuiteConfigDir)
Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteDpdkCPUPinningExecProbe,
tsparams.CertsuiteCPUPinningNoExecProbes,
globalparameters.TestCasePassed, randomReportDir)
Expect(err).ToNot(HaveOccurred())
})

It("one dpdk pod with exec probe [negative]", func() {
By("Deploy dpdk pod namespace")
By("Deploy dpdk pod")
dpdkPod := tshelper.DefineDpdkPod(tsparams.DpdkPodName, randomNamespace)

By("Redefine liveness probe")
Expand All @@ -86,15 +86,15 @@ var _ = Describe("Networking dpdk-cpu-pinning-exec-probe,", func() {
Skip("DPDK is not deployed. There may be some problems in setup. Hence, skipping.")
}

By("Start tests")
By("Start cpu-pinning-no-exec-probes test")
err = globalhelper.LaunchTests(
tsparams.CertsuiteDpdkCPUPinningExecProbe,
tsparams.CertsuiteCPUPinningNoExecProbes,
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()), randomReportDir, randomCertsuiteConfigDir)
Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteDpdkCPUPinningExecProbe,
tsparams.CertsuiteCPUPinningNoExecProbes,
globalparameters.TestCaseFailed, randomReportDir)
Expect(err).ToNot(HaveOccurred())
})
Expand Down
1 change: 1 addition & 0 deletions tests/performance/tests/cpu_pinning_no_exec_probes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package tests
Loading