Explorar o código

AMBARI-4509. Schema version is not determined correctly under some conditions (dlysnichenko)

Lisnichenko Dmitro %!s(int64=11) %!d(string=hai) anos
pai
achega
3289ea060e

+ 1 - 0
ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java

@@ -122,6 +122,7 @@ public class StackExtensionHelper {
   private ServiceInfo mergeServices(ServiceInfo parentService,
                                     ServiceInfo childService) {
     ServiceInfo mergedServiceInfo = new ServiceInfo();
+    mergedServiceInfo.setSchemaVersion(childService.getSchemaVersion());
     mergedServiceInfo.setName(childService.getName());
     mergedServiceInfo.setComment(childService.getComment());
     mergedServiceInfo.setUser(childService.getUser());

+ 10 - 0
ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java

@@ -1228,6 +1228,16 @@ public class AmbariMetaInfoTest {
             service.getOsSpecifics().get("any").getPackages().get(0).getName());
   }
 
+  @Test
+  public void testServiceSchemaVersionInheritance() throws Exception {
+    // Check parent
+    ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "SQOOP");
+    Assert.assertEquals("2.0", service.getSchemaVersion());
+    // Test child service metainfo after merge
+    service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "SQOOP");
+    Assert.assertEquals("2.0", service.getSchemaVersion());
+  }
+
 
   private CustomCommandDefinition findCustomCommand(String ccName,
                                                     ServiceInfo service) {

+ 3 - 2
ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java

@@ -51,7 +51,7 @@ public class StackExtensionHelperTest {
     StackExtensionHelper helper = new StackExtensionHelper(stackRoot);
     helper.populateServicesForStack(stackInfo);
     List<ServiceInfo> services =  stackInfo.getServices();
-    assertEquals(5, services.size());
+    assertEquals(6, services.size());
     for (ServiceInfo serviceInfo : services) {
       if (serviceInfo.getName().equals("HIVE")) {
         // Check old-style service
@@ -177,7 +177,8 @@ public class StackExtensionHelperTest {
       } else {
         if (!serviceInfo.getName().equals("YARN") &&
             !serviceInfo.getName().equals("HDFS") &&
-            !serviceInfo.getName().equals("MAPREDUCE2")) {
+            !serviceInfo.getName().equals("MAPREDUCE2") &&
+            !serviceInfo.getName().equals("SQOOP")) {
           fail("Unknown service");
         }
       }

+ 39 - 0
ambari-server/src/test/resources/stacks/HDP/2.0.7/services/SQOOP/metainfo.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<metainfo>
+  <schemaVersion>2.0</schemaVersion>
+  <services>
+    <service>
+      <name>SQOOP</name>
+      <comment>Tool for transferring bulk data between Apache Hadoop and structured data stores such as relational databases</comment>
+      <version>1.23</version>
+      <components>
+        <component>
+          <name>SQOOP</name>
+          <category>CLIENT</category>
+          <commandScript>
+            <script>scripts/resourcemanager.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>600</timeout>
+          </commandScript>
+        </component>
+      </components>
+    </service>
+  </services>
+
+</metainfo>

+ 39 - 0
ambari-server/src/test/resources/stacks/HDP/2.0.8/services/SQOOP/metainfo.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<metainfo>
+  <schemaVersion>2.0</schemaVersion>
+  <services>
+    <service>
+      <name>SQOOP</name>
+      <comment>Tool for transferring bulk data between Apache Hadoop and structured data stores such as relational databases</comment>
+      <version>1.23</version>
+      <components>
+        <component>
+          <name>SQOOP</name>
+          <category>CLIENT</category>
+          <commandScript>
+            <script>scripts/resourcemanager.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>600</timeout>
+          </commandScript>
+        </component>
+      </components>
+    </service>
+  </services>
+
+</metainfo>