Ver Fonte

AMBARI-6262 Return field host_components fully when hosts filtered (Hosts table's filtering by Host Components won't work without this) (dsen)

Dmytro Sen há 11 anos atrás
pai
commit
1785225b04

+ 0 - 7
ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java

@@ -826,13 +826,6 @@ public class QueryImpl implements Query, ResourceInstance {
     // record the sub-resource properties on this query
     subResourcePredicateProperties.addAll(visitor.getSubResourceProperties());
 
-    if (hasSubResourcePredicate()) {
-      for (Map.Entry<String, QueryImpl> entry : requestedSubResources.entrySet()) {
-        subResourcePredicate = getSubResourcePredicate(predicate, entry.getKey());
-        entry.getValue().processUserPredicate(subResourcePredicate);
-      }
-    }
-
     processedPredicate = visitor.getProcessedPredicate();
     return processedPredicate;
   }

+ 14 - 2
ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java

@@ -201,6 +201,7 @@ public class QueryImplTest {
 
     //test
     QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
+    instance.addProperty("versions/operatingSystems/OperatingSystems/os_type/*", null);
 
     PredicateBuilder pb = new PredicateBuilder();
     Predicate predicate = pb.property("versions/operatingSystems/OperatingSystems/os_type").equals("centos5").toPredicate();
@@ -225,14 +226,25 @@ public class QueryImplTest {
 
     Assert.assertEquals(1, versionNode.getChildren().size());
     TreeNode<Resource> opSystemsNode = versionNode.getChild("operatingSystems");
-    Assert.assertEquals(1, opSystemsNode.getChildren().size());
+    Assert.assertEquals(3, opSystemsNode.getChildren().size());
 
     TreeNode<Resource> opSystemNode = opSystemsNode.getChild("OperatingSystem:1");
     Assert.assertEquals("OperatingSystem:1", opSystemNode.getName());
     Resource osResource = opSystemNode.getObject();
     Assert.assertEquals(Resource.Type.OperatingSystem, opSystemNode.getObject().getType());
-
     Assert.assertEquals("centos5", osResource.getPropertyValue("OperatingSystems/os_type"));
+
+    opSystemNode = opSystemsNode.getChild("OperatingSystem:2");
+    Assert.assertEquals("OperatingSystem:2", opSystemNode.getName());
+    osResource = opSystemNode.getObject();
+    Assert.assertEquals(Resource.Type.OperatingSystem, opSystemNode.getObject().getType());
+    Assert.assertEquals("centos6", osResource.getPropertyValue("OperatingSystems/os_type"));
+
+    opSystemNode = opSystemsNode.getChild("OperatingSystem:3");
+    Assert.assertEquals("OperatingSystem:3", opSystemNode.getName());
+    osResource = opSystemNode.getObject();
+    Assert.assertEquals(Resource.Type.OperatingSystem, opSystemNode.getObject().getType());
+    Assert.assertEquals("oraclelinux5", osResource.getPropertyValue("OperatingSystems/os_type"));
   }
 
   @Test