ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] ambari git commit: AMBARI-15739. Failed to install oozie client (aonishuk)
Date Wed, 06 Apr 2016 18:41:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 4bc6a52a4 -> 6cd6fe5c2
  refs/heads/trunk 97c11244b -> 1cb8b0c10


AMBARI-15739. Failed to install oozie client (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1cb8b0c1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1cb8b0c1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1cb8b0c1

Branch: refs/heads/trunk
Commit: 1cb8b0c103d55329bb533a6f4e341791d4eaf237
Parents: 97c1124
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Wed Apr 6 21:41:03 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Wed Apr 6 21:41:03 2016 +0300

----------------------------------------------------------------------
 .../server/controller/internal/Stack.java       |  5 +-
 .../server/controller/internal/StackTest.java   | 63 ++++++++++++++++++++
 2 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1cb8b0c1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
index 986dce9..ad8d4f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
@@ -477,8 +477,9 @@ public class Stack {
   public String getServiceForConfigType(String config) {
     for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry
: serviceConfigurations.entrySet()) {
       Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
-      if (typeMap.containsKey(config)) {
-        return entry.getKey();
+      String serviceName = entry.getKey();
+      if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config))
{
+        return serviceName;
       }
     }
     throw new IllegalArgumentException(

http://git-wip-us.apache.org/repos/asf/ambari/blob/1cb8b0c1/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackTest.java
index 79f111e..e70af3e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackTest.java
@@ -57,6 +57,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.powermock.api.easymock.PowerMock.createNiceMock;
 import static org.powermock.api.easymock.PowerMock.replay;
 import static org.powermock.api.easymock.PowerMock.verifyAll;
@@ -316,4 +317,66 @@ public class StackTest {
     verifyAll();
   }
 
+  // Test that getServiceForConfigType skips excluded config types.
+  @Test
+  public void testGetServiceForConfigTypeWithExcludedConfigs() throws Exception {
+    // Given
+    AmbariManagementController controller = createNiceMock(AmbariManagementController.class);
+    AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
+    StackServiceResponse stackServiceResponse = createNiceMock(StackServiceResponse.class);
+    StackServiceComponentResponse stackComponentResponse = createNiceMock(StackServiceComponentResponse.class);
+    StackConfigurationResponse stackConfigurationResponse1 = createNiceMock(StackConfigurationResponse.class);
+
+    String testServiceName = "service1";
+    String testEmptyConfigType = "test-empty-config-type";
+    String testSiteConfigFile = "test-site.xml";
+    String testSiteConfigType = "test-site";
+
+    expect(controller.getAmbariMetaInfo()).andReturn(metaInfo).anyTimes();
+
+    expect(controller.getStackServices(anyObject(Set.class))).andReturn(Collections.singleton(stackServiceResponse)).anyTimes();
+    expect(stackServiceResponse.getServiceName()).andReturn(testServiceName).anyTimes();
+
+    // Config type test-site is excluded for the service service1
+    expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>singleton(testSiteConfigType));
+
+    // stack components
+    expect(stackComponentResponse.getComponentName()).andReturn("component1").anyTimes();
+    expect(stackComponentResponse.getComponentCategory()).andReturn(testSiteConfigFile).anyTimes();
+    expect(controller.getStackComponents(anyObject(Set.class))).andReturn(Collections.singleton(stackComponentResponse)).anyTimes();
+
+    expect(stackConfigurationResponse1.getPropertyName()).andReturn("prop1").anyTimes();
+    expect(stackConfigurationResponse1.getPropertyValue()).andReturn(null).anyTimes();
+    expect(stackConfigurationResponse1.getType()).andReturn(testSiteConfigFile).anyTimes();
+    expect(stackConfigurationResponse1.getPropertyType()).andReturn(Collections.singleton(PropertyInfo.PropertyType.TEXT)).anyTimes();
+    expect(stackConfigurationResponse1.getPropertyAttributes()).andReturn(Collections.<String,
String>emptyMap()).anyTimes();
+    expect(stackConfigurationResponse1.isRequired()).andReturn(true).anyTimes();
+
+    expect(controller.getStackConfigurations(anyObject(Set.class))).andReturn(Collections.singleton(stackConfigurationResponse1)).anyTimes();
+
+    // empty stack service config type
+    expect(stackServiceResponse.getConfigTypes()).andReturn(Collections.singletonMap(testEmptyConfigType,
Collections.<String, Map<String, String>>emptyMap()));
+
+    // no stack level configs for this test
+    expect(controller.getStackLevelConfigurations(anyObject(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet()).anyTimes();
+    expect(metaInfo.getComponentDependencies("test", "1.0", "service1", "component1")).andReturn(Collections.<DependencyInfo>emptyList()).anyTimes();
+
+    replay(controller, stackServiceResponse, stackComponentResponse, stackConfigurationResponse1,
metaInfo);
+
+    Stack stack = new Stack("test", "1.0", controller);
+
+    // When
+    try {
+      stack.getServiceForConfigType(testSiteConfigType);
+      fail("Exception not thrown");
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+
+    // Not excluded config type
+    assertEquals(testServiceName, stack.getServiceForConfigType(testEmptyConfigType));
+
+    verifyAll();
+  }
+
 }


Mime
View raw message