Repository: ambari Updated Branches: refs/heads/trunk 365c91e92 -> 18c4af48c
http://git-wip-us.apache.org/repos/asf/ambari/blob/18c4af48/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java index d95dcef..f8b6709 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java @@ -52,7 +52,6 @@ import java.util.UUID; import javax.persistence.EntityManager; -import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.ClusterNotFoundException; import org.apache.ambari.server.DuplicateResourceException; import org.apache.ambari.server.H2DatabaseCleaner; @@ -332,11 +331,11 @@ public class AmbariManagementControllerTest { host.setHostAttributes(hostAttributes); } - private void addHost(String hostname) throws AmbariException { + private void addHost(String hostname) throws Exception { addHostToCluster(hostname, null); } - private void addHostToCluster(String hostname, String clusterName) throws AmbariException { + private void addHostToCluster(String hostname, String clusterName) throws Exception { if (!clusters.hostExists(hostname)) { clusters.addHost(hostname); @@ -349,27 +348,30 @@ public class AmbariManagementControllerTest { } } - private void deleteHost(String hostname) throws AmbariException { + private void deleteHost(String hostname) throws Exception { clusters.deleteHost(hostname); } + + /** * Creates a Cluster object, along with its corresponding ClusterVersion based on the stack. * @param clusterName Cluster name - * @throws AmbariException + * @throws Exception */ - private void createCluster(String clusterName) throws AmbariException, AuthorizationException { + private void createCluster(String clusterName) throws Exception{ + RepositoryVersionDAO repoDAO = injector.getInstance(RepositoryVersionDAO.class); ClusterRequest r = new ClusterRequest(null, clusterName, State.INSTALLED.name(), SecurityType.NONE, "HDP-0.1", null); controller.createCluster(r); } - private void createService(String clusterName, String serviceName, State desiredState) throws AmbariException, AuthorizationException { + private void createService(String clusterName, String serviceName, State desiredState) throws Exception, AuthorizationException { createService(clusterName, serviceName, repositoryVersion02, desiredState); } private void createService(String clusterName, String serviceName, RepositoryVersionEntity repositoryVersion, State desiredState) - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { String dStateStr = null; if (desiredState != null) { dStateStr = desiredState.toString(); @@ -387,7 +389,7 @@ public class AmbariManagementControllerTest { private void createServiceComponent(String clusterName, String serviceName, String componentName, State desiredState) - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { String dStateStr = null; if (desiredState != null) { dStateStr = desiredState.toString(); @@ -402,7 +404,7 @@ public class AmbariManagementControllerTest { private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, - State desiredState) throws AmbariException, AuthorizationException { + State desiredState) throws Exception, AuthorizationException { String dStateStr = null; if (desiredState != null) { dStateStr = desiredState.toString(); @@ -417,7 +419,7 @@ public class AmbariManagementControllerTest { private void deleteServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, - State desiredState) throws AmbariException, AuthorizationException { + State desiredState) throws Exception, AuthorizationException { String dStateStr = null; if (desiredState != null) { dStateStr = desiredState.toString(); @@ -432,7 +434,7 @@ public class AmbariManagementControllerTest { private Long createConfigGroup(Cluster cluster, String serviceName, String name, String tag, List<String> hosts, List<Config> configs) - throws AmbariException { + throws Exception { Map<Long, Host> hostMap = new HashMap<>(); Map<String, Config> configMap = new HashMap<>(); @@ -459,7 +461,7 @@ public class AmbariManagementControllerTest { private long stopService(String clusterName, String serviceName, boolean runSmokeTests, boolean reconfigureClients) throws - AmbariException, AuthorizationException { + Exception, AuthorizationException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, State.INSTALLED.toString(), null); Set<ServiceRequest> requests = new HashSet<>(); requests.add(r); @@ -516,7 +518,7 @@ public class AmbariManagementControllerTest { private long startService(String clusterName, String serviceName, boolean runSmokeTests, boolean reconfigureClients) throws - AmbariException, AuthorizationException { + Exception, AuthorizationException { return startService(clusterName, serviceName, runSmokeTests, reconfigureClients, null); } @@ -524,7 +526,7 @@ public class AmbariManagementControllerTest { private long startService(String clusterName, String serviceName, boolean runSmokeTests, boolean reconfigureClients, MaintenanceStateHelper maintenanceStateHelper) throws - AmbariException, AuthorizationException { + Exception, AuthorizationException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, repositoryVersion02.getId(), State.STARTED.toString(), null); Set<ServiceRequest> requests = new HashSet<>(); @@ -565,7 +567,7 @@ public class AmbariManagementControllerTest { private long installService(String clusterName, String serviceName, boolean runSmokeTests, boolean reconfigureClients) - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { return installService(clusterName, serviceName, runSmokeTests, reconfigureClients, null, null); } @@ -578,7 +580,7 @@ public class AmbariManagementControllerTest { boolean runSmokeTests, boolean reconfigureClients, MaintenanceStateHelper maintenanceStateHelper, Map<String, String> mapRequestPropsInput) - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, repositoryVersion02.getId(), State.INSTALLED.toString(), null); @@ -618,7 +620,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateClusterSimple() throws AmbariException, AuthorizationException { + public void testCreateClusterSimple() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Set<ClusterResponse> r = @@ -631,13 +633,13 @@ public class AmbariManagementControllerTest { try { createCluster(cluster1); fail("Duplicate cluster creation should fail"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected } } @Test - public void testCreateClusterWithHostMapping() throws AmbariException, AuthorizationException { + public void testCreateClusterWithHostMapping() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); String host1 = getUniqueName(); @@ -697,7 +699,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServicesSimple() throws AmbariException, AuthorizationException { + public void testCreateServicesSimple() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "HDFS"; @@ -722,7 +724,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServicesWithInvalidRequest() throws AmbariException, AuthorizationException { + public void testCreateServicesWithInvalidRequest() throws Exception, AuthorizationException { // invalid request // dups in requests // multi cluster updates @@ -755,7 +757,7 @@ public class AmbariManagementControllerTest { set1.add(rInvalid); ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1); fail("Expected failure for invalid cluster"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected Assert.assertTrue(checkExceptionType(e, ClusterNotFoundException.class)); } @@ -827,7 +829,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServiceWithInvalidInfo() throws AmbariException, AuthorizationException { + public void testCreateServiceWithInvalidInfo() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "HDFS"; @@ -868,7 +870,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServicesMultiple() throws AmbariException, AuthorizationException { + public void testCreateServicesMultiple() throws Exception, AuthorizationException { Set<ServiceRequest> set1 = new HashSet<>(); String cluster1 = getUniqueName(); @@ -888,7 +890,7 @@ public class AmbariManagementControllerTest { set1.add(valid2); ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1); fail("Expected failure for invalid services"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected Assert.assertTrue(checkExceptionType(e, DuplicateResourceException.class)); } @@ -900,7 +902,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServiceComponentSimple() throws AmbariException, AuthorizationException { + public void testCreateServiceComponentSimple() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "HDFS"; @@ -941,7 +943,7 @@ public class AmbariManagementControllerTest { @Test public void testCreateServiceComponentWithInvalidRequest() - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { // multiple clusters // dup objects // existing components @@ -1319,8 +1321,6 @@ public class AmbariManagementControllerTest { RoleCommand.START); assertEquals(cluster1, ec.getClusterName()); assertNotNull(ec.getCommandParams()); - assertTrue(ec.getCommandParams().containsKey("custom_folder")); - assertEquals("dashboards", ec.getCommandParams().get("custom_folder")); assertNotNull(ec.getHostLevelParams()); assertTrue(ec.getHostLevelParams().containsKey(ExecutionCommand.KeyNames.USER_LIST)); assertEquals("[\"myhdfsuser\"]", ec.getHostLevelParams().get(ExecutionCommand.KeyNames.USER_LIST)); @@ -1331,7 +1331,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateServiceComponentMultiple() throws AmbariException, AuthorizationException { + public void testCreateServiceComponentMultiple() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); String cluster2 = getUniqueName(); @@ -1379,7 +1379,7 @@ public class AmbariManagementControllerTest { } private void createServiceComponentHostSimple(String clusterName, String host1, - String host2) throws AmbariException, AuthorizationException { + String host2) throws Exception, AuthorizationException { createCluster(clusterName); clusters.getCluster(clusterName) @@ -1478,7 +1478,7 @@ public class AmbariManagementControllerTest { @Test public void testCreateServiceComponentHostMultiple() - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "HDFS"; @@ -1536,7 +1536,7 @@ public class AmbariManagementControllerTest { @Test public void testCreateServiceComponentHostWithInvalidRequest() - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { // multiple clusters // dup objects // existing components @@ -1663,7 +1663,7 @@ public class AmbariManagementControllerTest { set1.add(rInvalid); controller.createHostComponents(set1); fail("Expected failure for invalid service"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected } @@ -1682,7 +1682,7 @@ public class AmbariManagementControllerTest { set1.add(rInvalid); controller.createHostComponents(set1); fail("Expected failure for invalid host"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected } @@ -1709,7 +1709,7 @@ public class AmbariManagementControllerTest { set1.add(rInvalid); controller.createHostComponents(set1); fail("Expected failure for invalid host cluster mapping"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected } @@ -1798,7 +1798,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateHostSimple() throws AmbariException, AuthorizationException { + public void testCreateHostSimple() throws Exception { String cluster1 = getUniqueName(); String host1 = getUniqueName(); String host2 = getUniqueName(); @@ -1827,7 +1827,7 @@ public class AmbariManagementControllerTest { try { HostResourceProviderTest.createHosts(controller, requests); fail("Create host should fail for invalid clusters"); - } catch (AmbariException e) { + } catch (Exception e) { // Expected } @@ -1851,7 +1851,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateHostMultiple() throws AmbariException, AuthorizationException { + public void testCreateHostMultiple() throws Exception { String host1 = getUniqueName(); String host2 = getUniqueName(); String host3 = getUniqueName(); @@ -1887,7 +1887,7 @@ public class AmbariManagementControllerTest { } @Test - public void testCreateHostWithInvalidRequests() throws AmbariException { + public void testCreateHostWithInvalidRequests() throws Exception { // unknown host // invalid clusters // duplicate host @@ -2198,7 +2198,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetClusters() throws AmbariException, AuthorizationException { + public void testGetClusters() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); clusters.addCluster(cluster1, new StackId("HDP-0.1")); @@ -2229,7 +2229,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetClustersWithFilters() throws AmbariException, AuthorizationException { + public void testGetClustersWithFilters() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); String cluster2 = getUniqueName(); String cluster3 = getUniqueName(); @@ -2260,7 +2260,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetServices() throws AmbariException { + public void testGetServices() throws Exception { String cluster1 = getUniqueName(); StackId stackId = new StackId("HDP-0.1"); @@ -2289,7 +2289,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetServicesWithFilters() throws AmbariException { + public void testGetServicesWithFilters() throws Exception { String cluster1 = getUniqueName(); String cluster2 = getUniqueName(); @@ -2369,7 +2369,7 @@ public class AmbariManagementControllerTest { @Test - public void testGetServiceComponents() throws AmbariException { + public void testGetServiceComponents() throws Exception { String cluster1 = getUniqueName(); StackId stackId = new StackId("HDP-0.2"); @@ -2406,7 +2406,7 @@ public class AmbariManagementControllerTest { @Test - public void testGetServiceComponentsWithFilters() throws AmbariException { + public void testGetServiceComponentsWithFilters() throws Exception { String cluster1 = getUniqueName(); String cluster2 = getUniqueName(); @@ -2527,7 +2527,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetServiceComponentHosts() throws AmbariException, AuthorizationException { + public void testGetServiceComponentHosts() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); String host1 = getUniqueName(); @@ -2573,7 +2573,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetServiceComponentHostsWithStaleConfigFilter() throws AmbariException, AuthorizationException { + public void testGetServiceComponentHostsWithStaleConfigFilter() throws Exception, AuthorizationException { final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -2761,7 +2761,7 @@ public class AmbariManagementControllerTest { } @Test - public void testHbaseDecommission() throws AmbariException, AuthorizationException { + public void testHbaseDecommission() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1).setDesiredStackVersion(new StackId("HDP-2.0.7")); @@ -2903,7 +2903,7 @@ public class AmbariManagementControllerTest { } private Cluster setupClusterWithHosts(String clusterName, String stackId, List<String> hosts, - String osType) throws AmbariException, AuthorizationException { + String osType) throws Exception, AuthorizationException { ClusterRequest r = new ClusterRequest(null, clusterName, stackId, null); controller.createCluster(r); Cluster c1 = clusters.getCluster(clusterName); @@ -2914,7 +2914,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetServiceComponentHostsWithFilters() throws AmbariException, AuthorizationException { + public void testGetServiceComponentHostsWithFilters() throws Exception, AuthorizationException { final String cluster1 = getUniqueName(); final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -3063,7 +3063,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetHosts() throws AmbariException, AuthorizationException { + public void testGetHosts() throws Exception, AuthorizationException { final String cluster1 = getUniqueName(); final String cluster2 = getUniqueName(); final String host1 = getUniqueName(); @@ -3137,7 +3137,7 @@ public class AmbariManagementControllerTest { } @Test - public void testServiceUpdateBasic() throws AmbariException, AuthorizationException { + public void testServiceUpdateBasic() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "HDFS"; @@ -3180,7 +3180,7 @@ public class AmbariManagementControllerTest { } @Test - public void testServiceUpdateInvalidRequest() throws AmbariException, AuthorizationException { + public void testServiceUpdateInvalidRequest() throws Exception, AuthorizationException { // multiple clusters // dup services // multiple diff end states @@ -3262,7 +3262,7 @@ public class AmbariManagementControllerTest { } @Ignore("Something fishy with the stacks here that's causing the RCO to be loaded incorrectly") - public void testServiceUpdateRecursive() throws AmbariException, AuthorizationException { + public void testServiceUpdateRecursive() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); @@ -3517,7 +3517,7 @@ public class AmbariManagementControllerTest { } @Test - public void testServiceComponentUpdateRecursive() throws AmbariException, AuthorizationException { + public void testServiceComponentUpdateRecursive() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); @@ -4055,7 +4055,7 @@ public class AmbariManagementControllerTest { } @Test - public void testComponentCategorySentWithRestart() throws AmbariException, AuthorizationException { + public void testComponentCategorySentWithRestart() throws Exception, AuthorizationException { final String cluster1 = getUniqueName(); final String host1 = getUniqueName(); @@ -4421,7 +4421,7 @@ public class AmbariManagementControllerTest { try { RequestStatusResponse response = controller.createAction(actionRequest, requestProperties); Assert.fail("createAction should fail"); - } catch (AmbariException ex) { + } catch (Exception ex) { LOG.info(ex.getMessage()); if (!ex.getMessage().contains(message)) { fail(String.format("Expected '%s' to contain '%s'", ex.getMessage(), message)); @@ -5119,7 +5119,7 @@ public class AmbariManagementControllerTest { } @Test - public void testReConfigureServiceClient() throws AmbariException, AuthorizationException { + public void testReConfigureServiceClient() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Cluster cluster = clusters.getCluster(cluster1); @@ -5401,7 +5401,7 @@ public class AmbariManagementControllerTest { } @Test - public void testClientServiceSmokeTests() throws AmbariException, AuthorizationException { + public void testClientServiceSmokeTests() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "PIG"; @@ -5495,7 +5495,7 @@ public class AmbariManagementControllerTest { } @Test - public void testSkipTaskOnUnhealthyHosts() throws AmbariException, AuthorizationException { + public void testSkipTaskOnUnhealthyHosts() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1) @@ -5630,7 +5630,7 @@ public class AmbariManagementControllerTest { } @Test - public void testServiceCheckWhenHostIsUnhealthy() throws AmbariException, AuthorizationException { + public void testServiceCheckWhenHostIsUnhealthy() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1).setDesiredStackVersion(new StackId("HDP-0.1")); @@ -5722,13 +5722,13 @@ public class AmbariManagementControllerTest { try { response = controller.createAction(actionRequest, requestProperties); assertTrue("Exception should have been raised.", false); - } catch (AmbariException e) { + } catch (Exception e) { assertTrue(e.getMessage().contains("there were no healthy eligible hosts")); } } @Test - public void testReInstallForInstallFailedClient() throws AmbariException, AuthorizationException { + public void testReInstallForInstallFailedClient() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1) @@ -5857,7 +5857,7 @@ public class AmbariManagementControllerTest { } @Test - public void testReInstallClientComponentFromServiceChange() throws AmbariException, AuthorizationException { + public void testReInstallClientComponentFromServiceChange() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1) @@ -6094,7 +6094,7 @@ public class AmbariManagementControllerTest { } @Test - public void testResourceFiltersWithCustomActions() throws AmbariException, AuthorizationException { + public void testResourceFiltersWithCustomActions() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -6166,7 +6166,7 @@ public class AmbariManagementControllerTest { RequestStatusResponse response = null; try { response = controller.createAction(actionRequest, requestProperties); - } catch (AmbariException ae) { + } catch (Exception ae) { LOG.info("Expected exception.", ae); Assert.assertTrue(ae.getMessage().contains("Custom action definition only " + "allows one resource filter to be specified")); @@ -6197,7 +6197,7 @@ public class AmbariManagementControllerTest { } @Test - public void testResourceFiltersWithCustomCommands() throws AmbariException, AuthorizationException { + public void testResourceFiltersWithCustomCommands() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -6351,7 +6351,7 @@ public class AmbariManagementControllerTest { @Test - public void testConfigsAttachedToServiceChecks() throws AmbariException, AuthorizationException { + public void testConfigsAttachedToServiceChecks() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Cluster cluster = clusters.getCluster(cluster1); @@ -6433,7 +6433,7 @@ public class AmbariManagementControllerTest { @Test @Ignore("Unsuported feature !") - public void testConfigsAttachedToServiceNotCluster() throws AmbariException, AuthorizationException { + public void testConfigsAttachedToServiceNotCluster() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); clusters.getCluster(cluster1).setDesiredStackVersion(new StackId("HDP-0.1")); @@ -6513,7 +6513,7 @@ public class AmbariManagementControllerTest { } @Test - public void testHostLevelParamsSentWithCommands() throws AmbariException, AuthorizationException { + public void testHostLevelParamsSentWithCommands() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); String serviceName = "PIG"; @@ -6570,7 +6570,7 @@ public class AmbariManagementControllerTest { } @Test - public void testConfigGroupOverridesWithHostActions() throws AmbariException, AuthorizationException { + public void testConfigGroupOverridesWithHostActions() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Cluster cluster = clusters.getCluster(cluster1); @@ -6727,7 +6727,7 @@ public class AmbariManagementControllerTest { } @Test - public void testConfigGroupOverridesWithDecommissionDatanode() throws AmbariException, AuthorizationException { + public void testConfigGroupOverridesWithDecommissionDatanode() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Cluster cluster = clusters.getCluster(cluster1); @@ -6832,7 +6832,7 @@ public class AmbariManagementControllerTest { } @Test - public void testConfigGroupOverridesWithServiceCheckActions() throws AmbariException, AuthorizationException { + public void testConfigGroupOverridesWithServiceCheckActions() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); createCluster(cluster1); Cluster cluster = clusters.getCluster(cluster1); @@ -7321,7 +7321,7 @@ public class AmbariManagementControllerTest { } @Test - public void testUpdateClusterUpgradabilityCheck() throws AmbariException, AuthorizationException { + public void testUpdateClusterUpgradabilityCheck() throws Exception, AuthorizationException { String cluster1 = getUniqueName(); StackId currentStackId = new StackId("HDP-0.2"); @@ -7334,7 +7334,7 @@ public class AmbariManagementControllerTest { ClusterRequest r = new ClusterRequest(c.getClusterId(), cluster1, "HDP-0.3", null); try { controller.updateClusters(Collections.singleton(r), mapRequestProps); - } catch (AmbariException e) { + } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Illegal request to upgrade to")); } @@ -7345,7 +7345,7 @@ public class AmbariManagementControllerTest { r = new ClusterRequest(c.getClusterId(), cluster1, "HDP-0.2", null); try { controller.updateClusters(Collections.singleton(r), mapRequestProps); - } catch (AmbariException e) { + } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Upgrade is not allowed from")); } } @@ -7613,7 +7613,7 @@ public class AmbariManagementControllerTest { } @Test - public void testGetTasksByRequestId() throws AmbariException { + public void testGetTasksByRequestId() throws Exception { ActionManager am = injector.getInstance(ActionManager.class); final long requestId1 = am.getNextRequestId(); @@ -8357,7 +8357,7 @@ public class AmbariManagementControllerTest { } @Test - public void testExecutionCommandConfiguration() throws AmbariException { + public void testExecutionCommandConfiguration() throws Exception { Map<String, Map<String, String>> config = new HashMap<>(); config.put("type1", new HashMap<>()); config.put("type3", new HashMap<>()); @@ -8400,7 +8400,7 @@ public class AmbariManagementControllerTest { String tag = "version1"; String type = "core-site"; - AmbariException exception = null; + Exception exception = null; try { AmbariManagementController amc = injector.getInstance(AmbariManagementController.class); Clusters clusters = injector.getInstance(Clusters.class); @@ -8432,7 +8432,7 @@ public class AmbariManagementControllerTest { amc.createConfiguration(configurationRequest); amc.createConfiguration(configurationRequest); - } catch (AmbariException e) { + } catch (Exception e) { exception = e; } @@ -9090,7 +9090,7 @@ public class AmbariManagementControllerTest { private void testRunSmokeTestFlag(Map<String, String> mapRequestProps, AmbariManagementController amc, Set<ServiceRequest> serviceRequests) - throws AmbariException, AuthorizationException { + throws Exception, AuthorizationException { RequestStatusResponse response;//Starting HDFS service. No run_smoke_test flag is set, smoke String cluster1 = getUniqueName(); @@ -9914,7 +9914,7 @@ public class AmbariManagementControllerTest { try { controller.updateClusters(Collections.singleton(cr), new HashMap<>()); Assert.fail("Expect failure when creating a config that exists"); - } catch (AmbariException e) { + } catch (Exception e) { // expected } } @@ -10018,7 +10018,7 @@ public class AmbariManagementControllerTest { } @Test - public void testConfigAttributesStaleConfigFilter() throws AmbariException, AuthorizationException { + public void testConfigAttributesStaleConfigFilter() throws Exception, AuthorizationException { final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -10119,7 +10119,7 @@ public class AmbariManagementControllerTest { } @Test - public void testSecretReferences() throws AmbariException, AuthorizationException { + public void testSecretReferences() throws Exception, AuthorizationException { final String host1 = getUniqueName(); final String host2 = getUniqueName(); @@ -10208,7 +10208,7 @@ public class AmbariManagementControllerTest { try { controller.updateClusters(Collections.singleton(crReq), null); fail("Request need to be failed with wrong secret reference"); - } catch (AmbariException e){ + } catch (Exception e){ } // reference to config which does not contain requested property @@ -10237,7 +10237,7 @@ public class AmbariManagementControllerTest { try { controller.updateClusters(Collections.singleton(crReq), null); fail("Request need to be failed with wrong secret reference"); - } catch (AmbariException e) { + } catch (Exception e) { assertEquals("Error when parsing secret reference. Cluster: " + cluster1 + " ConfigType: hdfs-site ConfigVersion: 4 does not contain property 'test.password'", e.getMessage()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/18c4af48/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java index f45ff75..a6fc919 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java @@ -1913,8 +1913,53 @@ public class ClusterStackVersionResourceProviderTest { stackEntity.setStackName("HDP"); stackEntity.setStackVersion("2.1.1"); - File f = new File("src/test/resources/hbase_version_test.xml"); - String xmlString = IOUtils.toString(new FileInputStream(f)); + String hbaseVersionTestXML = "\n" + + "<repository-version xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + + " xsi:noNamespaceSchemaLocation=\"version_definition.xsd\">\n" + + " \n" + + " <release>\n" + + " <type>PATCH</type>\n" + + " <stack-id>HDP-2.3</stack-id>\n" + + " <version>2.3.4.0</version>\n" + + " <build>3396</build>\n" + + " <compatible-with>2.3.2.[0-9]</compatible-with>\n" + + " <release-notes>http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.4/</release-notes>\n" + + " </release>\n" + + " \n" + + " <manifest>\n" + + " <service id=\"HBASE-112\" name=\"HBASE\" version=\"1.1.2\" version-id=\"2_3_4_0-3396\" />\n" + + " </manifest>\n" + + " \n" + + " <available-services>\n" + + " <service idref=\"HBASE-112\" />\n" + + " </available-services>\n" + + " \n" + + " <repository-info>\n" + + " <os family=\"redhat6\">\n" + + " <package-version>2_3_4_0_3396</package-version>\n" + + " <repo>\n" + + " <baseurl>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.4.0</baseurl>\n" + + " <repoid>HDP-2.3</repoid>\n" + + " <reponame>HDP</reponame>\n" + + " <unique>true</unique>\n" + + " </repo>\n" + + " <repo>\n" + + " <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6</baseurl>\n" + + " <repoid>HDP-UTILS-1.1.0.20</repoid>\n" + + " <reponame>HDP-UTILS</reponame>\n" + + " <unique>false</unique>\n" + + " </repo>\n" + + " </os>\n" + + " </repository-info>\n" + + " \n" + + " <upgrade>\n" + + " <configuration type=\"hdfs-site\">\n" + + " <set key=\"foo\" value=\"bar\" />\n" + + " </configuration>\n" + + " </upgrade>\n" + + "</repository-version>"; + + String xmlString = hbaseVersionTestXML; // hack to remove ZK xmlString = xmlString.replace("<service idref=\"ZOOKEEPER-346\" />", ""); @@ -2013,7 +2058,7 @@ public class ClusterStackVersionResourceProviderTest { expect(managementController.findConfigurationTagsWithOverrides(anyObject(Cluster.class), EasyMock.anyString())) .andReturn(new HashMap<String, Map<String, String>>()).anyTimes(); - expect(clusters.getCluster(anyObject(String.class))).andReturn(cluster); + expect(clusters.getCluster(anyObject(String.class))).andReturn(cluster).anyTimes(); expect(clusters.getHostsForCluster(anyObject(String.class))).andReturn( hostsForCluster).anyTimes(); http://git-wip-us.apache.org/repos/asf/ambari/blob/18c4af48/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java index 64d416f..ec240df 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java @@ -214,23 +214,25 @@ public class UpgradeResourceProviderTest extends EasyMockSupport { StackEntity stackEntity220 = stackDAO.find("HDP", "2.2.0"); StackId stack211 = new StackId(stackEntity211); + String operatingSystems = "[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]"; + repoVersionEntity2110 = new RepositoryVersionEntity(); repoVersionEntity2110.setDisplayName("My New Version 1"); - repoVersionEntity2110.setOperatingSystems(""); + repoVersionEntity2110.setOperatingSystems(operatingSystems); repoVersionEntity2110.setStack(stackEntity211); repoVersionEntity2110.setVersion("2.1.1.0"); repoVersionDao.create(repoVersionEntity2110); repoVersionEntity2111 = new RepositoryVersionEntity(); repoVersionEntity2111.setDisplayName("My New Version 2 for minor upgrade"); - repoVersionEntity2111.setOperatingSystems(""); + repoVersionEntity2111.setOperatingSystems(operatingSystems); repoVersionEntity2111.setStack(stackEntity211); repoVersionEntity2111.setVersion("2.1.1.1"); repoVersionDao.create(repoVersionEntity2111); repoVersionEntity2112 = new RepositoryVersionEntity(); repoVersionEntity2112.setDisplayName("My New Version 3 for patch upgrade"); - repoVersionEntity2112.setOperatingSystems(""); + repoVersionEntity2112.setOperatingSystems(operatingSystems); repoVersionEntity2112.setStack(stackEntity211); repoVersionEntity2112.setVersion("2.1.1.2"); repoVersionEntity2112.setType(RepositoryType.PATCH); @@ -239,7 +241,7 @@ public class UpgradeResourceProviderTest extends EasyMockSupport { repoVersionEntity2200 = new RepositoryVersionEntity(); repoVersionEntity2200.setDisplayName("My New Version 4 for major upgrade"); - repoVersionEntity2200.setOperatingSystems(""); + repoVersionEntity2200.setOperatingSystems(operatingSystems); repoVersionEntity2200.setStack(stackEntity220); repoVersionEntity2200.setVersion("2.2.0.0"); repoVersionDao.create(repoVersionEntity2200); @@ -1931,7 +1933,7 @@ public class UpgradeResourceProviderTest extends EasyMockSupport { StackEntity stackEntity = stackDAO.find("HDP", "2.1.1"); RepositoryVersionEntity repoVersionEntity = new RepositoryVersionEntity(); repoVersionEntity.setDisplayName("My New Version 3"); - repoVersionEntity.setOperatingSystems(""); + repoVersionEntity.setOperatingSystems("[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]"); repoVersionEntity.setStack(stackEntity); repoVersionEntity.setVersion("2.2.2.3"); repoVersionDao.create(repoVersionEntity); http://git-wip-us.apache.org/repos/asf/ambari/blob/18c4af48/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java index bd8be3b..9da66f2 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java @@ -670,8 +670,10 @@ public class OrmTestHelper { if (repositoryVersion == null) { try { + String operatingSystems = "[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]"; + repositoryVersion = repositoryVersionDAO.create(stackEntity, version, - String.valueOf(System.currentTimeMillis()) + uniqueCounter.incrementAndGet(), ""); + String.valueOf(System.currentTimeMillis()) + uniqueCounter.incrementAndGet(), operatingSystems); } catch (Exception ex) { LOG.error("Caught exception", ex);
