yangwwei commented on a change in pull request #190:
URL:
https://github.com/apache/incubator-yunikorn-k8shim/pull/190#discussion_r487263705
##########
File path: pkg/cache/node_coordinator_test.go
##########
@@ -248,3 +248,45 @@ func TestDeleteTerminatedPod(t *testing.T) {
coordinator.deletePod(pod2)
assert.Equal(t, executed, false)
}
+
+func TestUpdatePodPendingRunningAlternatively(t *testing.T) {
+ mockedSchedulerAPI := newMockSchedulerAPI()
+ nodes := newSchedulerNodes(mockedSchedulerAPI, NewTestSchedulerCache())
+ host1 := utils.NodeForTest("HOST1", "10G", "10")
+ nodes.addNode(host1)
+ coordinator := newNodeResourceCoordinator(nodes)
+
+ // init pod (pod1) and changed pod (pod2)
+ pod1 := utils.PodForTest("pod1", "1G", "500m")
+ pod1.SetUID("UID-01")
+ pod2 := utils.PodForTest("pod1", "1G", "500m")
+ pod2.SetUID("UID-01")
+
+ // pod state changed from pending to running, trigger an update
+ pod1.Status.Phase = v1.PodPending
+ pod2.Status.Phase = v1.PodRunning
+ pod1.Spec.NodeName = "HOST1"
+ pod2.Spec.NodeName = "HOST1"
+ coordinator.updatePod(pod1, pod2)
+ node1 := coordinator.nodes.nodesMap["HOST1"]
+ assert.Equal(t, node1.occupied.Resources[constants.Memory].Value,
int64(1000))
+ assert.Equal(t, node1.occupied.Resources[constants.CPU].Value,
int64(500))
+
+ // pod state changed from running to pending,
Review comment:
Can pod state change from `Running` to `Pending`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]