pbacsko commented on code in PR #277:
URL: https://github.com/apache/yunikorn-k8shim/pull/277#discussion_r875985518


##########
pkg/cache/application_test.go:
##########
@@ -1132,3 +1133,125 @@ func TestGetPlaceholderTasks(t *testing.T) {
        assert.Assert(t, phTasksMap["task0001"])
        assert.Assert(t, phTasksMap["task0002"])
 }
+
+func TestPlaceholderTimeoutEvents(t *testing.T) {
+       context := initContextForTest()
+       recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
+       if !ok {
+               t.Fatal("the EventRecorder is expected to be of type 
FakeRecorder")
+       }
+
+       amprotocol := NewMockedAMProtocol()
+       am := general.NewManager(amprotocol, context.apiProvider)
+       pod1 := v1.Pod{
+               TypeMeta: apis.TypeMeta{
+                       Kind:       "Pod",
+                       APIVersion: "v1",
+               },
+               ObjectMeta: apis.ObjectMeta{
+                       Name:      "pod00001",
+                       Namespace: "default",
+                       UID:       "UID-POD-00001",
+                       Labels: map[string]string{
+                               "queue":         "root.a",
+                               "applicationId": "app00001",
+                       },
+               },
+               Spec: v1.PodSpec{SchedulerName: constants.SchedulerName},
+               Status: v1.PodStatus{
+                       Phase: v1.PodPending,
+               },
+       }
+
+       // add a pending pod through the AM service
+       am.AddPod(&pod1)
+
+       pod := &v1.Pod{
+               TypeMeta: apis.TypeMeta{
+                       Kind:       "Pod",
+                       APIVersion: "v1",
+               },
+               ObjectMeta: apis.ObjectMeta{
+                       Name:      "pod00002",
+                       Namespace: "default",
+                       UID:       "UID-POD-00002",
+                       Labels: map[string]string{
+                               "queue":         "root.a",
+                               "applicationId": "app00001",
+                       },
+               },
+               Spec: v1.PodSpec{SchedulerName: constants.SchedulerName},
+               Status: v1.PodStatus{
+                       Phase: v1.PodPending,
+               },
+       }
+       managedApp := amprotocol.GetApplication("app00001")
+       assert.Assert(t, managedApp != nil)
+       app, valid := managedApp.(*Application)
+       if !valid {
+               t.Fatal("application is expected to be of type Application")
+       }
+       assert.Equal(t, valid, true)
+       assert.Equal(t, app.GetApplicationID(), "app00001")
+       assert.Equal(t, app.GetApplicationState(), 
events.States().Application.New)
+       assert.Equal(t, app.GetQueue(), "root.a")
+       assert.Equal(t, len(app.GetNewTasks()), 1)
+
+       appID := "app00001"
+       UUID := "UID-POD-00002"
+
+       context.applications[appID] = app
+       task1 := context.AddTask(&interfaces.AddTaskRequest{
+               Metadata: interfaces.TaskMetadata{
+                       ApplicationID: "app00001",
+                       TaskID:        "task02",
+                       Pod:           pod,
+                       Placeholder:   true,
+               },
+       })
+       assert.Assert(t, task1 != nil)
+       assert.Equal(t, task1.GetTaskID(), "task02")
+
+       _, taskErr := app.GetTask("task02")
+       if taskErr != nil {

Review Comment:
   Simplify: `assert.NilError()`



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