suneet-s commented on code in PR #17400:
URL: https://github.com/apache/druid/pull/17400#discussion_r1820064120


##########
extensions-contrib/kubernetes-overlord-extensions/src/test/java/org/apache/druid/k8s/overlord/execution/SelectorTest.java:
##########
@@ -30,11 +30,68 @@
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 public class SelectorTest
 {
+  @Test
+  public void shouldReturnTrueWhenMatchTasksTagsAndEmptyDataSource()
+  {
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+    cxtTagsConditions.put("tag1", Sets.newHashSet("tag1Value"));
+
+    Task task = NoopTask.create();
+    task.addToContext(DruidMetrics.TAGS, ImmutableMap.of("tag1", "tag1Value"));
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,
+        Sets.newHashSet(NoopTask.TYPE),
+        new HashSet<>()

Review Comment:
   Please add another test for passing in null for the datasource selector



##########
extensions-contrib/kubernetes-overlord-extensions/src/test/java/org/apache/druid/k8s/overlord/execution/SelectorTest.java:
##########
@@ -30,11 +30,68 @@
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 public class SelectorTest
 {
+  @Test
+  public void shouldReturnTrueWhenMatchTasksTagsAndEmptyDataSource()
+  {
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+    cxtTagsConditions.put("tag1", Sets.newHashSet("tag1Value"));
+
+    Task task = NoopTask.create();
+    task.addToContext(DruidMetrics.TAGS, ImmutableMap.of("tag1", "tag1Value"));
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,
+        Sets.newHashSet(NoopTask.TYPE),
+        new HashSet<>()
+    );
+
+    Assert.assertTrue(selector.evaluate(task));
+  }
+
+  @Test
+  public void shouldReturnTrueWhenMatchDataSourceTagsAndEmptyTasks()
+  {
+    String datasource = "table";
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+    cxtTagsConditions.put("tag1", Sets.newHashSet("tag1Value"));
+
+    Task task = NoopTask.forDatasource(datasource);
+    task.addToContext(DruidMetrics.TAGS, ImmutableMap.of("tag1", "tag1Value"));
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,
+        new HashSet<>(),

Review Comment:
   Please add another test for passing in null for the task type selector



##########
extensions-contrib/kubernetes-overlord-extensions/src/test/java/org/apache/druid/k8s/overlord/execution/SelectorTest.java:
##########
@@ -30,11 +30,68 @@
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 public class SelectorTest
 {
+  @Test
+  public void shouldReturnTrueWhenMatchTasksTagsAndEmptyDataSource()
+  {
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+    cxtTagsConditions.put("tag1", Sets.newHashSet("tag1Value"));
+
+    Task task = NoopTask.create();
+    task.addToContext(DruidMetrics.TAGS, ImmutableMap.of("tag1", "tag1Value"));
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,
+        Sets.newHashSet(NoopTask.TYPE),
+        new HashSet<>()
+    );
+
+    Assert.assertTrue(selector.evaluate(task));
+  }
+
+  @Test
+  public void shouldReturnTrueWhenMatchDataSourceTagsAndEmptyTasks()
+  {
+    String datasource = "table";
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+    cxtTagsConditions.put("tag1", Sets.newHashSet("tag1Value"));
+
+    Task task = NoopTask.forDatasource(datasource);
+    task.addToContext(DruidMetrics.TAGS, ImmutableMap.of("tag1", "tag1Value"));
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,
+        new HashSet<>(),
+        Sets.newHashSet(datasource)
+    );
+
+    Assert.assertTrue(selector.evaluate(task));
+  }
+
+  @Test
+  public void shouldReturnTrueWhenMatchDataSourceTasksAndEmptyTags()
+  {
+    String datasource = "table";
+    Map<String, Set<String>> cxtTagsConditions = new HashMap<>();
+
+    Task task = NoopTask.forDatasource(datasource);
+
+    Selector selector = new Selector(
+        "TestSelector",
+        cxtTagsConditions,

Review Comment:
   Please add another test for passing in null for the tags condition



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