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<String, Map<String, String>> configurations,
+ Map<String, Map<String, String>> 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<String, DesiredConfig> 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<String, String> props = new HashMap<String,
String>(config.getProperties());
+ Map<String, String> tags = new HashMap<String, String>();
+ 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<Stage> doStageCreation(Cluster cluster,
Map<State, List<Service>> changedServices,
Map<State, List<ServiceComponent>> changedComps,
@@ -2070,48 +2118,8 @@ public class AmbariManagementControllerI
Map<String, Map<String, String>> configurations = new
TreeMap<String, Map<String,String>>();
Map<String, Map<String, String>> configTags = new HashMap<String,
Map<String,String>>();
- // 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<String, DesiredConfig> 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<String, String> props = new HashMap<String,
String>(config.getProperties());
- Map<String, String> tags = new HashMap<String, String>();
- 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<String, Map<String, String>> configurations =
- new TreeMap<String, Map<String, String>>();
- Map<String, Config> allConfigs =
cluster.getService(serviceName).getDesiredConfigs();
- if (allConfigs != null) {
- for (Map.Entry<String, Config> entry: allConfigs.entrySet()) {
- configurations.put(entry.getValue().getType(),
entry.getValue().getProperties());
- }
- }
+ // [ type -> [ key, value ] ]
+ Map<String, Map<String, String>> configurations = new TreeMap<String,
Map<String,String>>();
+ Map<String, Map<String, String>> configTags = new HashMap<String,
Map<String,String>>();
+
+ 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<String, Map<String, String>> configurations = new TreeMap<String,
Map<String,String>>();
+ Map<String, Map<String, String>> configTags = new TreeMap<String,
+ Map<String, String>>();
- // 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<String, DesiredConfig> 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<String, String> props = new HashMap<String,
String>(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<String, String> mapRequestProps = new HashMap<String, String>();
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<String, String> mapRequestProps = new HashMap<String, String>();
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<String, String> mapRequestProps = new HashMap<String, String>();
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<Stage> 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<String, String> mapRequestProps = new HashMap<String, String>();
+ 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<String, String> configs = new HashMap<String, String>();
+ 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<Stage> 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);