diff --git a/test/conformance/tests/test_sriov_operator.go b/test/conformance/tests/test_sriov_operator.go index bba12fab2..ed537749f 100644 --- a/test/conformance/tests/test_sriov_operator.go +++ b/test/conformance/tests/test_sriov_operator.go @@ -18,6 +18,7 @@ import ( admission "k8s.io/api/admissionregistration/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -108,7 +109,7 @@ var _ = Describe("[sriov] operator", func() { Describe("No SriovNetworkNodePolicy", func() { Context("SR-IOV network config daemon can be set by nodeselector", func() { // 26186 - FIt("Should schedule the config daemon on selected nodes", func() { + It("Should schedule the config daemon on selected nodes", func() { if discovery.Enabled() { Skip("Test unsuitable to be run in discovery mode") } @@ -930,6 +931,35 @@ var _ = Describe("[sriov] operator", func() { }, 3*time.Minute, time.Second).Should(Equal(corev1.PodRunning)) }) }) + + Context("CNI Logging level", func() { + // 25874 + It("Debug logging should be visible in multus pod", func() { + + err := network.CreateSriovNetwork(clients, sriovDevice, "test-log-level-debug-no-file", namespaces.Test, operatorNamespace, resourceName, ipamIpv4, func(sn *sriovv1.SriovNetwork) { + sn.Spec.LogLevel = "debug" + }) + Expect(err).ToNot(HaveOccurred()) + + podDeployTime := time.Now() + + testPod := createTestPod(node, []string{"test-log-level-debug-no-file"}) + + recentMultusLogs := getMultusPodLogs(testPod.Spec.NodeName, podDeployTime) + + Expect(recentMultusLogs).To( + ContainElement( + // Assert against multiple ContainSubstring condition because we can't make assumption on the order of the chunks + And( + ContainSubstring(`level="debug"`), + ContainSubstring(`msg="1. Set link down"`), + ContainSubstring(`cniName="sriov-cni"`), + ContainSubstring(`ifname="net1"`), + ContainSubstring(`func="SetupVF"`), + ), + )) + }) + }) }) Describe("Custom SriovNetworkNodePolicy", func() { @@ -2427,3 +2457,25 @@ func assertDevicePluginConfigurationContains(node, configuration string) { HaveKeyWithValue(node, ContainSubstring(configuration)), ) } + +func getMultusPodLogs(nodeName string, since time.Time) []string { + + podList, err := clients.Pods("").List(context.Background(), metav1.ListOptions{ + LabelSelector: "app=multus", + FieldSelector: "spec.nodeName=" + nodeName, + }) + ExpectWithOffset(1, err).ToNot(HaveOccurred()) + ExpectWithOffset(1, podList.Items).To(HaveLen(1), "One multus pod expected") + + multusPod := podList.Items[0] + logStart := metav1.NewTime(since) + rawLogs, err := clients.Pods(multusPod.Namespace). + GetLogs(multusPod.Name, &v1.PodLogOptions{ + Container: multusPod.Spec.Containers[0].Name, + SinceTime: &logStart, + }). + DoRaw(context.Background()) + ExpectWithOffset(1, err).ToNot(HaveOccurred()) + + return strings.Split(string(rawLogs), "\n") +}