AmatyaAvadhanula commented on code in PR #12404:
URL: https://github.com/apache/druid/pull/12404#discussion_r859638814


##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataStorageActionHandlerTest.java:
##########
@@ -450,4 +465,149 @@ public void testRemoveTasksOlderThan() throws Exception
     Assert.assertEquals(1, handler.getLogs(entryId2).size());
     Assert.assertEquals(1, handler.getLogs(entryId3).size());
   }
+
+  @Test
+  public void testGetTaskStatusPlusList()
+  {
+    // SETUP
+    TaskInfo<Map<String, Object>, Map<String, Object>> activeUnaltered = 
getRandomTaskInfo(true);
+    insertTaskInfo(activeUnaltered, false);
+
+    TaskInfo<Map<String, Object>, Map<String, Object>> completedUnaltered = 
getRandomTaskInfo(false);
+    insertTaskInfo(completedUnaltered, false);
+
+    TaskInfo<Map<String, Object>, Map<String, Object>> activeAltered = 
getRandomTaskInfo(true);
+    insertTaskInfo(activeAltered, true);
+
+    TaskInfo<Map<String, Object>, Map<String, Object>> completedAltered = 
getRandomTaskInfo(false);
+    insertTaskInfo(completedAltered, true);
+
+    Map<TaskLookup.TaskLookupType, TaskLookup> taskLookups = new HashMap<>();
+    taskLookups.put(TaskLookup.TaskLookupType.ACTIVE, 
ActiveTaskLookup.getInstance());
+    taskLookups.put(TaskLookup.TaskLookupType.COMPLETE, 
CompleteTaskLookup.of(null, Duration.millis(86400000)));
+
+    List<TaskStatusPlus> taskStatusPlusList;
+
+    // BEFORE MIGRATION
+
+    // Payload based fetch. task type and groupid will be populated
+    taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null, 
true);
+    Assert.assertEquals(4, taskStatusPlusList.size());
+    verify(completedUnaltered, taskStatusPlusList, false, false, true);
+    verify(completedAltered, taskStatusPlusList, false, true, false);
+    verify(activeUnaltered, taskStatusPlusList, true, false, false);
+    verify(activeAltered, taskStatusPlusList, true, true, false);
+
+    // New columns based fetch before migration is complete. type and payload 
are null when altered = false
+    taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null, 
false);
+    Assert.assertEquals(4, taskStatusPlusList.size());
+    verify(completedUnaltered, taskStatusPlusList, false, false, true);
+    verify(completedAltered, taskStatusPlusList, false, true, true);
+    verify(activeUnaltered, taskStatusPlusList, true, false, true);
+    verify(activeAltered, taskStatusPlusList, true, true, true);
+
+    // MIGRATION
+    derbyConnectorRule.getConnector().migrateTaskTable(entryTable);
+
+    // Payload based fetch. task type and groupid will still be populated
+    taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null, 
true);
+    Assert.assertEquals(4, taskStatusPlusList.size());
+    verify(completedUnaltered, taskStatusPlusList, false, false, false);
+    verify(completedAltered, taskStatusPlusList, false, true, false);
+    verify(activeUnaltered, taskStatusPlusList, true, false, false);
+    verify(activeAltered, taskStatusPlusList, true, true, false);
+
+    // New columns based fetch before migration is complete.
+    // type and payload are not null for completed task but are still null for 
active ones since they aren't migrated
+    // An active task will be eventually updated on its own due to insertion

Review Comment:
   The webconsole will show empty values now. Possible solutions:
   1) I think a simple check could be to just use the query requiring payload 
for both cases. Inefficient
   2) The class holds a boolean state indicating which active query to use. 
   It checks if there is at least one active query with null type / groupId, in 
which case it fetches payload
   If not, update the boolean state and only use the new query for active tasks



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to