Return-Path: X-Original-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5DAD510AFA for ; Tue, 16 Apr 2013 05:09:52 +0000 (UTC) Received: (qmail 89604 invoked by uid 500); 16 Apr 2013 05:09:52 -0000 Delivered-To: apmail-incubator-ambari-commits-archive@incubator.apache.org Received: (qmail 89432 invoked by uid 500); 16 Apr 2013 05:09:47 -0000 Mailing-List: contact ambari-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@incubator.apache.org Delivered-To: mailing list ambari-commits@incubator.apache.org Received: (qmail 89306 invoked by uid 99); 16 Apr 2013 05:09:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Apr 2013 05:09:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Apr 2013 05:09:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 17ED623888CD; Tue, 16 Apr 2013 05:09:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1468303 - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/controller/ ambari-server/src/test/java/org/apache/ambari/server/controller/ Date: Tue, 16 Apr 2013 05:09:16 -0000 To: ambari-commits@incubator.apache.org From: swagle@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130416050917.17ED623888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: swagle Date: Tue Apr 16 05:09:16 2013 New Revision: 1468303 URL: http://svn.apache.org/r1468303 Log: AMBARI-1944. All Service Smoke tests fail when run with service start. (swagle) Modified: incubator/ambari/trunk/CHANGES.txt incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java Modified: incubator/ambari/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1468303&r1=1468302&r2=1468303&view=diff ============================================================================== --- incubator/ambari/trunk/CHANGES.txt (original) +++ incubator/ambari/trunk/CHANGES.txt Tue Apr 16 05:09:16 2013 @@ -745,6 +745,8 @@ Trunk (unreleased changes): BUG FIXES + AMBARI-1944. All Service Smoke tests fail when run with service start. (swagle) + AMBARI-1939. Make service restart feedback based on supports functionality. (srimanth) Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1468303&r1=1468302&r2=1468303&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original) +++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Tue Apr 16 05:09:16 2013 @@ -1906,6 +1906,54 @@ public class AmbariManagementControllerI } } + private void findConfigurationPropertiesWithOverrides( + Map> configurations, + Map> configTags, + Cluster cluster, String serviceName, String hostName) throws AmbariException { + // Do not use host component config mappings. Instead, the rules are: + // 1) Use the cluster desired config + // 2) override (1) with service-specific overrides + // 3) override (2) with host-specific overrides + + // since we are dealing with host components in this loop, get the + // config mappings for the service this host component applies to + + for (Entry entry : cluster.getDesiredConfigs().entrySet()) { + String type = entry.getKey(); + String tag = entry.getValue().getVersion(); + // 1) start with cluster config + Config config = cluster.getConfig(type, tag); + + if (null == config) + continue; + + Map props = new HashMap(config.getProperties()); + Map tags = new HashMap(); + tags.put("tag", config.getVersionTag()); + + // 2) apply the service overrides, if any are defined with different tags + Service service = cluster.getService(serviceName); + Config svcConfig = service.getDesiredConfigs().get(type); + if (null != svcConfig && !svcConfig.getVersionTag().equals(tag)) { + props.putAll(svcConfig.getProperties()); + } + + // 3) apply the host overrides, if any + Host host = clusters.getHost(hostName); + DesiredConfig dc = host.getDesiredConfigs(cluster.getClusterId()).get(type); + if (null != dc) { + Config hostConfig = cluster.getConfig(type, dc.getVersion()); + if (null != hostConfig) { + props.putAll(hostConfig.getProperties()); + tags.put("host_override_tag", hostConfig.getVersionTag()); + } + } + + configurations.put(type, props); + configTags.put(type, tags); + } + } + private List doStageCreation(Cluster cluster, Map> changedServices, Map> changedComps, @@ -2070,48 +2118,8 @@ public class AmbariManagementControllerI Map> configurations = new TreeMap>(); Map> configTags = new HashMap>(); - // Do not use host component config mappings. Instead, the rules are: - // 1) Use the cluster desired config - // 2) override (1) with service-specific overrides - // 3) override (2) with host-specific overrides - - // since we are dealing with host components in this loop, get the - // config mappings for the service this host component applies to - - for (Entry entry : cluster.getDesiredConfigs().entrySet()) { - String type = entry.getKey(); - String tag = entry.getValue().getVersion(); - // 1) start with cluster config - Config config = cluster.getConfig(type, tag); - - if (null == config) - continue; - - Map props = new HashMap(config.getProperties()); - Map tags = new HashMap(); - tags.put("tag", config.getVersionTag()); - - // 2) apply the service overrides, if any are defined with different tags - Service service = cluster.getService(scHost.getServiceName()); - Config svcConfig = service.getDesiredConfigs().get(type); - if (null != svcConfig && !svcConfig.getVersionTag().equals(tag)) { - props.putAll(svcConfig.getProperties()); - } - - // 3) apply the host overrides, if any - Host host = clusters.getHost(scHost.getHostName()); - DesiredConfig dc = host.getDesiredConfigs(scHost.getClusterId()).get(type); - if (null != dc) { - Config hostConfig = cluster.getConfig(type, dc.getVersion()); - if (null != hostConfig) { - props.putAll(hostConfig.getProperties()); - tags.put("host_override_tag", hostConfig.getVersionTag()); - } - } - - configurations.put(type, props); - configTags.put(type, tags); - } + findConfigurationPropertiesWithOverrides(configurations, configTags, + cluster, scHost.getServiceName(), scHost.getHostName()); // HACK HACK HACK if ((!scHost.getHostName().equals(jobtrackerHost)) @@ -2153,19 +2161,21 @@ public class AmbariManagementControllerI new ServiceComponentHostOpInProgressEvent(null, clientHost, nowTimestamp), cluster.getClusterName(), serviceName); - Map> configurations = - new TreeMap>(); - Map allConfigs = cluster.getService(serviceName).getDesiredConfigs(); - if (allConfigs != null) { - for (Map.Entry entry: allConfigs.entrySet()) { - configurations.put(entry.getValue().getType(), entry.getValue().getProperties()); - } - } + // [ type -> [ key, value ] ] + Map> configurations = new TreeMap>(); + Map> configTags = new HashMap>(); + + findConfigurationPropertiesWithOverrides(configurations, configTags, + cluster, serviceName, clientHost); stage.getExecutionCommandWrapper(clientHost, smokeTestRole).getExecutionCommand() .setConfigurations(configurations); + stage.getExecutionCommandWrapper(clientHost, + smokeTestRole).getExecutionCommand() + .setConfigurationTags(configTags); + // Generate cluster host info stage.getExecutionCommandWrapper(clientHost, smokeTestRole) .getExecutionCommand() @@ -3971,44 +3981,11 @@ public class AmbariManagementControllerI // [ type -> [ key, value ] ] Map> configurations = new TreeMap>(); + Map> configTags = new TreeMap>(); - // Do not use service config mappings. Instead, the rules are: - // 1) Use the cluster desired config - // 2) override (1) with service-specific overrides - // 3) override (2) with host-specific overrides - // Yes, we may be sending more configs than are actually used, but that is - // because of the new design - - for (Entry entry : cluster.getDesiredConfigs().entrySet()) { - String type = entry.getKey(); - String tag = entry.getValue().getVersion(); - // 1) start with cluster config - Config config = cluster.getConfig(type, tag); - - if (null == config) - continue; - - Map props = new HashMap(config.getProperties()); - - // 2) apply the service overrides, if any are defined with different tags - Service service = cluster.getService(actionRequest.getServiceName()); - Config svcConfig = service.getDesiredConfigs().get(type); - if (null != svcConfig && !svcConfig.getVersionTag().equals(tag)) { - props.putAll(svcConfig.getProperties()); - } - - // 3) apply the host overrides, if any - Host host = clusters.getHost(hostName); - DesiredConfig dc = host.getDesiredConfigs(cluster.getClusterId()).get(type); - if (null != dc) { - Config hostConfig = cluster.getConfig(type, dc.getVersion()); - if (null != hostConfig) { - props.putAll(hostConfig.getProperties()); - } - } - - configurations.put(type, props); - } + findConfigurationPropertiesWithOverrides(configurations, configTags, + cluster, actionRequest.getServiceName(), hostName); ExecutionCommand execCmd = stage.getExecutionCommandWrapper(hostName, actionRequest.getActionName()).getExecutionCommand(); Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1468303&r1=1468302&r2=1468303&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java (original) +++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java Tue Apr 16 05:09:16 2013 @@ -190,7 +190,7 @@ public class AmbariManagementControllerT } private long stopService(String clusterName, String serviceName, - boolean reconfigureClients) throws + boolean runSmokeTests, boolean reconfigureClients) throws AmbariException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, State.INSTALLED.toString()); @@ -199,7 +199,7 @@ public class AmbariManagementControllerT Map mapRequestProps = new HashMap(); mapRequestProps.put("context", "Called from a test"); RequestStatusResponse resp = controller.updateServices(requests, - mapRequestProps, true, reconfigureClients); + mapRequestProps, runSmokeTests, reconfigureClients); Assert.assertEquals(State.INSTALLED, clusters.getCluster(clusterName).getService(serviceName) @@ -218,7 +218,7 @@ public class AmbariManagementControllerT } private long startService(String clusterName, String serviceName, - boolean reconfigureClients) throws + boolean runSmokeTests, boolean reconfigureClients) throws AmbariException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, State.STARTED.toString()); @@ -227,7 +227,7 @@ public class AmbariManagementControllerT Map mapRequestProps = new HashMap(); mapRequestProps.put("context", "Called from a test"); RequestStatusResponse resp = controller.updateServices(requests, - mapRequestProps, true, reconfigureClients); + mapRequestProps, runSmokeTests, reconfigureClients); Assert.assertEquals(State.STARTED, clusters.getCluster(clusterName).getService(serviceName) @@ -246,7 +246,7 @@ public class AmbariManagementControllerT } private long installService(String clusterName, String serviceName, - boolean reconfigureClients) throws + boolean runSmokeTests, boolean reconfigureClients) throws AmbariException { ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, State.INSTALLED.toString()); @@ -255,7 +255,7 @@ public class AmbariManagementControllerT Map mapRequestProps = new HashMap(); mapRequestProps.put("context", "Called from a test"); RequestStatusResponse resp = controller.updateServices(requests, - mapRequestProps, true, reconfigureClients); + mapRequestProps, runSmokeTests, reconfigureClients); Assert.assertEquals(State.INSTALLED, clusters.getCluster(clusterName).getService(serviceName) @@ -4458,18 +4458,18 @@ public class AmbariManagementControllerT controller.updateCluster(crReq, null); // Install - long requestId1 = installService(clusterName, serviceName1, false); + long requestId1 = installService(clusterName, serviceName1, true, false); List stages = actionDB.getAllStages(requestId1); Assert.assertEquals(2, stages.get(0).getOrderedHostRoleCommands().get(0) .getExecutionCommandWrapper().getExecutionCommand() .getConfigurationTags().size()); - installService(clusterName, serviceName2, false); + installService(clusterName, serviceName2, false, false); // Start - startService(clusterName, serviceName1, false); - startService(clusterName, serviceName2, false); + startService(clusterName, serviceName1, true, false); + startService(clusterName, serviceName2, true, false); // Reconfigure configs.clear(); @@ -4481,12 +4481,12 @@ public class AmbariManagementControllerT controller.updateCluster(crReq, null); // Stop HDFS & MAPREDUCE - stopService(clusterName, serviceName1, false); - stopService(clusterName, serviceName2, false); + stopService(clusterName, serviceName1, false, false); + stopService(clusterName, serviceName2, false, false); // Start - long requestId2 = startService(clusterName, serviceName1, true); - long requestId3 = startService(clusterName, serviceName2, true); + long requestId2 = startService(clusterName, serviceName1, true, true); + long requestId3 = startService(clusterName, serviceName2, true, true); stages = actionDB.getAllStages(requestId2); stages.addAll(actionDB.getAllStages(requestId3)); @@ -4616,6 +4616,89 @@ public class AmbariManagementControllerT } @Test + public void testConfigsAttachedToServiceChecks() throws AmbariException { + String clusterName = "foo1"; + createCluster(clusterName); + clusters.getCluster(clusterName) + .setDesiredStackVersion(new StackId("HDP-0.1")); + String serviceName = "HDFS"; + createService(clusterName, serviceName, null); + String componentName1 = "NAMENODE"; + String componentName2 = "DATANODE"; + String componentName3 = "HDFS_CLIENT"; + + Map mapRequestProps = new HashMap(); + mapRequestProps.put("context", "Called from a test"); + + createServiceComponent(clusterName, serviceName, componentName1, + State.INIT); + createServiceComponent(clusterName, serviceName, componentName2, + State.INIT); + createServiceComponent(clusterName, serviceName, componentName3, + State.INIT); + + String host1 = "h1"; + clusters.addHost(host1); + clusters.getHost("h1").setOsType("centos5"); + clusters.getHost("h1").persist(); + String host2 = "h2"; + clusters.addHost(host2); + clusters.getHost("h2").setOsType("centos6"); + clusters.getHost("h2").persist(); + + clusters.mapHostToCluster(host1, clusterName); + clusters.mapHostToCluster(host2, clusterName); + + + // null service should work + createServiceComponentHost(clusterName, null, componentName1, + host1, null); + createServiceComponentHost(clusterName, serviceName, componentName2, + host1, null); + createServiceComponentHost(clusterName, serviceName, componentName2, + host2, null); + createServiceComponentHost(clusterName, serviceName, componentName3, + host1, null); + createServiceComponentHost(clusterName, serviceName, componentName3, + host2, null); + + // Create and attach config + Map configs = new HashMap(); + configs.put("a", "b"); + + ConfigurationRequest cr1,cr2; + cr1 = new ConfigurationRequest(clusterName, "core-site","version1", + configs); + cr2 = new ConfigurationRequest(clusterName, "hdfs-site","version1", + configs); + + ClusterRequest crReq = new ClusterRequest(null, clusterName, null, null); + crReq.setDesiredConfig(cr1); + controller.updateCluster(crReq, null); + crReq = new ClusterRequest(null, clusterName, null, null); + crReq.setDesiredConfig(cr2); + controller.updateCluster(crReq, null); + + // Install + installService(clusterName, serviceName, false, false); + // Start + long requestId = startService(clusterName, serviceName, true, false); + + List stages = actionDB.getAllStages(requestId); + boolean serviceCheckFound = false; + for (Stage stage : stages) { + for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) { + if (hrc.getRole().equals(Role.HDFS_SERVICE_CHECK)) { + serviceCheckFound = true; + Assert.assertEquals(2, hrc.getExecutionCommandWrapper() + .getExecutionCommand().getConfigurationTags().size()); + } + } + } + Assert.assertEquals(true, serviceCheckFound); + } + + @Test public void testStackVersionAsHostLevelParams() throws AmbariException { String clusterName = "foo1"; createCluster(clusterName);