manirajv06 commented on code in PR #444:
URL: https://github.com/apache/yunikorn-k8shim/pull/444#discussion_r937355002


##########
test/e2e/predicates/predicates_test.go:
##########
@@ -1064,31 +1044,25 @@ var _ = Describe("Predicates", func() {
                        },
                }
 
-               var success bool
                initPod, podErr = k8s.InitTestPod(conf)
                Ω(podErr).NotTo(HaveOccurred())
-               success, err = 
kClient.WaitForSchedulerAfterAction(kClient.CreateTestPodAction(initPod, 
anotherNS), anotherNS, labelPodName2, false)
+               _, err = kClient.CreatePod(initPod, anotherNS)
                Ω(err).NotTo(HaveOccurred())
-               Ω(success).Should(BeTrue())
 
                By(fmt.Sprintf("Verify pod:%s is in pending state", 
labelPodName2))
                err = kClient.WaitForPodPending(anotherNS, labelPodName2, 
time.Duration(60)*time.Second)
                Ω(err).NotTo(HaveOccurred())
 
-               By("Verify the Yunikorn events: failed scheduling")
-               var events *v1.EventList
-               events, err = kClient.GetEvents(anotherNS)
+               By("Verify the YuniKorn request failed scheduling")
+
+               err = restClient.WaitForAllocationLog("default", 
"root."+anotherNS, initPod.ObjectMeta.Labels["applicationId"], labelPodName2, 
60)
                Ω(err).NotTo(HaveOccurred())
-               Ω(len(events.Items)).NotTo(BeZero(), "Events cant be empty")
-               for _, event := range events.Items {
-                       framework.Logf("Event source is : %s", 
event.Source.Component)
-                       if event.Source.Component == 
configmanager.SchedulerName && event.Type == WARNING && 
!strings.Contains(event.Message, "node affinity") {
-                               framework.Logf("Yunikorn Event Reason: %s", 
event.Reason)
-                               
Ω(event.Reason).Should(Equal("FailedScheduling"), "Event reason mismatch")
-                               framework.Logf("Yunikorn Event Message: %s", 
event.Message)
-                               Ω(event.Message).Should(MatchRegexp("predicate 
is not satisfied.*free ports.*"), "Event message mismatch")
-                       }
-               }
+               log, err := restClient.GetAllocationLog("default", 
"root."+anotherNS, initPod.ObjectMeta.Labels["applicationId"], labelPodName2)
+               Ω(err).NotTo(HaveOccurred())
+               Ω(len(log)).NotTo(BeZero(), "Log can't be empty")
+
+               Ω(log).Should(ContainElement(HaveKeyWithValue("message", 
MatchRegexp(".*free ports.*"))),

Review Comment:
   Like commented above



##########
test/e2e/predicates/predicates_test.go:
##########
@@ -78,20 +77,19 @@ func runTestPod(k *k8s.KubeCtl, conf k8s.SleepPodConfig) 
*v1.Pod {
 
 var _ = Describe("Predicates", func() {
        var kClient k8s.KubeCtl
-       //var restClient yunikorn.RClient
+       var restClient yunikorn.RClient
        var err error
        var ns, anotherNS string
        var nodeList *v1.NodeList
        const LABELVALUE = "testing-label-value"
-       const WARNING = "Warning"
-       //var sleepRespPod *v1.Pod
+       // var sleepRespPod *v1.Pod

Review Comment:
   can be removed



##########
test/e2e/predicates/predicates_test.go:
##########
@@ -251,31 +243,25 @@ var _ = Describe("Predicates", func() {
                        },
                }
 
-               var success bool
                initPod, podErr := k8s.InitTestPod(conf)
                Ω(podErr).NotTo(HaveOccurred())
-               success, err = 
kClient.WaitForSchedulerAfterAction(kClient.CreateTestPodAction(initPod, ns), 
ns, podName, false)
-               Ω(err).NotTo(HaveOccurred())
-               Ω(success).Should(BeTrue())
+               _, podErr = kClient.CreatePod(initPod, ns)
+               Ω(podErr).NotTo(HaveOccurred())
 
                By(fmt.Sprintf("Verify pod:%s is in pending state", podName))
-               err = kClient.WaitForPodPending(ns, podName, 
time.Duration(60)*time.Second)
-               Ω(err).NotTo(HaveOccurred())
+               podErr = kClient.WaitForPodPending(ns, podName, 
time.Duration(60)*time.Second)
+               Ω(podErr).NotTo(HaveOccurred())
 
-               By("Verify the Yunikorn events: failed scheduling")
-               var events *v1.EventList
-               events, err = kClient.GetEvents(ns)
-               Ω(err).NotTo(HaveOccurred())
-               Ω(len(events.Items)).NotTo(BeZero(), "Events cant be empty")
-               for _, event := range events.Items {
-                       framework.Logf("Event source is : %s", 
event.Source.Component)
-                       if event.Source.Component == 
configmanager.SchedulerName && event.Type == WARNING {
-                               framework.Logf("Yunikorn Event Reason: %s", 
event.Reason)
-                               
Ω(event.Reason).Should(Equal("FailedScheduling"), "Event reason mismatch")
-                               framework.Logf("Yunikorn Event Message: %s", 
event.Message)
-                               Ω(event.Message).Should(MatchRegexp("predicate 
is not satisfied.*didn't match Pod's node affinity"), "Event message mismatch")
-                       }
-               }
+               By("Verify the YuniKorn request failed scheduling")
+
+               podErr = restClient.WaitForAllocationLog("default", "root."+ns, 
initPod.ObjectMeta.Labels["applicationId"], podName, 60)
+               Ω(podErr).NotTo(HaveOccurred())
+               log, podErr := restClient.GetAllocationLog("default", 
"root."+ns, initPod.ObjectMeta.Labels["applicationId"], podName)
+               Ω(podErr).NotTo(HaveOccurred())
+               Ω(len(log)).NotTo(BeZero(), "Log can't be empty")
+
+               Ω(log).Should(ContainElement(HaveKeyWithValue("message", 
MatchRegexp(".*didn't match Pod's node affinity"))),

Review Comment:
   Can we check by matching with earlier message? I am assuming allocation log 
contains same message.



##########
pkg/plugin/predicates/predicate_manager.go:
##########
@@ -75,12 +74,7 @@ func (p *predicateManagerImpl) predicatesReserve(pod 
*v1.Pod, node *framework.No
 func (p *predicateManagerImpl) predicatesAllocate(pod *v1.Pod, node 
*framework.NodeInfo) (plugin string, error error) {
        ctx := context.Background()
        state := framework.NewCycleState()
-       plugin, err := p.podFitsNode(ctx, state, *p.allocationPreFilters, 
*p.allocationFilters, pod, node)
-       if err != nil {
-               events.GetRecorder().Eventf(pod.DeepCopy(), nil, 
v1.EventTypeWarning,
-                       "FailedScheduling", "FailedScheduling", "predicate is 
not satisfied, error: %s", err.Error())
-       }
-       return plugin, err
+       return p.podFitsNode(ctx, state, *p.allocationPreFilters, 
*p.allocationFilters, pod, node)

Review Comment:
   Should we log this as debug statement?



##########
test/e2e/basic_scheduling/basic_scheduling_test.go:
##########
@@ -96,7 +96,6 @@ var _ = ginkgo.Describe("", func() {
                gomega.Ω(allocations["partition"]).NotTo(gomega.BeNil())
                gomega.Ω(allocations["uuid"]).NotTo(gomega.BeNil())
                
gomega.Ω(allocations["applicationId"]).To(gomega.Equal(sleepRespPod.ObjectMeta.Labels["applicationId"]))
-               
gomega.Ω(allocations["queueName"]).To(gomega.ContainSubstring(sleepRespPod.ObjectMeta.Namespace))

Review Comment:
   Is this related to the jira? or some other general cleanup?



##########
test/e2e/predicates/predicates_test.go:
##########
@@ -410,31 +396,25 @@ var _ = Describe("Predicates", func() {
                        NodeSelector: map[string]string{labelKey: labelValue},
                }
 
-               var success bool
                initPod, podErr := k8s.InitTestPod(conf)
                Ω(podErr).NotTo(HaveOccurred())
-               success, err = 
kClient.WaitForSchedulerAfterAction(kClient.CreateTestPodAction(initPod, ns), 
ns, podNameNoTolerations, false)
+               _, err := kClient.CreatePod(initPod, ns)
                Ω(err).NotTo(HaveOccurred())
-               Ω(success).Should(BeTrue())
 
                By(fmt.Sprintf("Verify pod:%s is in pending state", 
podNameNoTolerations))
                err = kClient.WaitForPodPending(ns, podNameNoTolerations, 
time.Duration(60)*time.Second)
                Ω(err).NotTo(HaveOccurred())
 
-               By("Verify the Yunikorn events: failed scheduling")
-               var events *v1.EventList
-               events, err = kClient.GetEvents(ns)
+               By("Verify the YuniKorn request failed scheduling")
+
+               err = restClient.WaitForAllocationLog("default", "root."+ns, 
initPod.ObjectMeta.Labels["applicationId"], podNameNoTolerations, 60)
                Ω(err).NotTo(HaveOccurred())
-               Ω(len(events.Items)).NotTo(BeZero(), "Events cant be empty")
-               for _, event := range events.Items {
-                       framework.Logf("Event source is : %s", 
event.Source.Component)
-                       if event.Source.Component == 
configmanager.SchedulerName && event.Type == WARNING && 
!strings.Contains(event.Message, "node affinity") {
-                               framework.Logf("Yunikorn Event Reason: %s", 
event.Reason)
-                               
Ω(event.Reason).Should(Equal("FailedScheduling"), "Event reason mismatch")
-                               framework.Logf("Yunikorn Event Message: %s", 
event.Message)
-                               Ω(event.Message).Should(MatchRegexp("predicate 
is not satisfied.*taint.*"), "Event message mismatch")
-                       }
-               }
+               log, err := restClient.GetAllocationLog("default", "root."+ns, 
initPod.ObjectMeta.Labels["applicationId"], podNameNoTolerations)
+               Ω(err).NotTo(HaveOccurred())
+               Ω(len(log)).NotTo(BeZero(), "Log can't be empty")
+
+               Ω(log).Should(ContainElement(HaveKeyWithValue("message", 
MatchRegexp(".*taint.*"))),

Review Comment:
   Please see my earlier comment. Just depending only on ".*taint.*" may 
mislead us sometimes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to