wilfred-s commented on code in PR #1050:
URL: https://github.com/apache/yunikorn-k8shim/pull/1050#discussion_r3580369858


##########
pkg/cache/context_test.go:
##########
@@ -717,92 +744,75 @@ func TestAddUpdatePodForeign(t *testing.T) {
        // pod is not assigned to any node
        pod1 := foreignPod(podName1, "1G", "500m")
        pod1.Status.Phase = v1.PodPending
-       pod1.Spec.NodeName = ""
-
-       // validate add (pending, no node assigned)
-       allocRequest = nil
-       context.AddPod(pod1)
-       assert.Assert(t, allocRequest == nil, "unexpected update")
-       pod := context.schedulerCache.GetPod(string(pod1.UID))
-       assert.Assert(t, pod == nil, "unassigned pod found in cache")
-
-       // validate update (no change)
-       allocRequest = nil
-       pod1Upd := pod1.DeepCopy()
-       context.UpdatePod(pod1, pod1Upd)
-       assert.Assert(t, allocRequest == nil, "unexpected update")
-       pod = context.schedulerCache.GetPod(string(pod1.UID))
-       assert.Assert(t, pod == nil, "unassigned pod found in cache")
 
-       // pod is assigned to a node but still in pending state, should update
        pod2 := foreignPod(podName2, "1G", "500m")
-       pod2.Status.Phase = v1.PodPending
        pod2.Spec.NodeName = Host1
+       pod2.Status.Phase = v1.PodRunning
 
-       // validate add
-       context.AddPod(pod2)
-       assert.Assert(t, allocRequest != nil, "update expected")
-       assertAddForeignPod(t, podName2, Host1, allocRequest)
-       pod = context.schedulerCache.GetPod(string(pod2.UID))
-       assert.Assert(t, pod != nil, "pod not found in cache")
-
-       // validate update (no change)
-       allocRequest = nil
-       pod2Upd := pod2.DeepCopy()
-       context.UpdatePod(pod2, pod2Upd)
-       assert.Assert(t, allocRequest == nil, "unexpected update")
-       pod = context.schedulerCache.GetPod(string(pod2.UID))
-       assert.Assert(t, pod != nil, "pod not found in cache")

Review Comment:
   Added 2 extra test cases and streamlined the earlier updates for 3 others



-- 
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