You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/07/24 17:28:04 UTC
[2/3] ambari git commit: AMBARI-21450 - Fixing Unit Test Logic From
trunk Merge (jonathanhurley)
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
index 0df6f68..bc78293 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
@@ -21,7 +21,6 @@ package org.apache.ambari.server.orm.entities;
import java.util.List;
import javax.persistence.Basic;
-import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
@@ -47,12 +46,24 @@ import javax.persistence.TableGenerator;
, initialValue = 1
)
@NamedQueries({
- @NamedQuery(name = "ServiceConfigEntity.findAll", query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId ORDER BY serviceConfig.version DESC"),
- @NamedQuery(name = "ServiceConfigEntity.findNextServiceConfigVersion", query = "SELECT COALESCE(MAX(serviceConfig.version), 0) + 1 AS nextVersion FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.serviceName=:serviceName AND serviceConfig.clusterId=:clusterId"),
- @NamedQuery(name = "ServiceConfigEntity.findAllServiceConfigsByStack", query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId AND serviceConfig.stack=:stack"),
- @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByStack", query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId = :clusterId AND serviceConfig.version = (SELECT MAX(serviceConfig2.version) FROM ServiceConfigEntity serviceConfig2 WHERE serviceConfig2.clusterId=:clusterId AND serviceConfig2.stack=:stack AND serviceConfig2.serviceName = serviceConfig.serviceName)"),
- @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByService", query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceName = :serviceName AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceName = :serviceName AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId IS NULL AND scv.groupId IS NULL)))"),
- @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByCluster", query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceConfigId IN (SELECT MAX(scv1.serviceConfigId) FROM ServiceConfigEntity scv1 WHERE (scv1.clusterId = :clusterId) AND (scv1.groupId IS NULL) GROUP BY scv1.serviceName)")})
+ @NamedQuery(
+ name = "ServiceConfigEntity.findAll",
+ query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId ORDER BY serviceConfig.version DESC"),
+ @NamedQuery(
+ name = "ServiceConfigEntity.findNextServiceConfigVersion",
+ query = "SELECT COALESCE(MAX(serviceConfig.version), 0) + 1 AS nextVersion FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.serviceName=:serviceName AND serviceConfig.clusterId=:clusterId"),
+ @NamedQuery(
+ name = "ServiceConfigEntity.findServiceConfigsByStack",
+ query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId AND serviceConfig.stack=:stack AND serviceConfig.serviceName=:serviceName"),
+ @NamedQuery(
+ name = "ServiceConfigEntity.findLatestServiceConfigsByStack",
+ query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId = :clusterId AND (serviceConfig.groupId = null OR serviceConfig.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND serviceConfig.version = (SELECT MAX(serviceConfig2.version) FROM ServiceConfigEntity serviceConfig2 WHERE serviceConfig2.clusterId= :clusterId AND serviceConfig2.stack = :stack AND serviceConfig2.serviceName = serviceConfig.serviceName)"),
+ @NamedQuery(
+ name = "ServiceConfigEntity.findLatestServiceConfigsByService",
+ query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceName = :serviceName AND (scv.groupId = null OR scv.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceName = :serviceName AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId IS NULL AND scv.groupId IS NULL)))"),
+ @NamedQuery(
+ name = "ServiceConfigEntity.findLatestServiceConfigsByCluster",
+ query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceConfigId IN (SELECT MAX(scv1.serviceConfigId) FROM ServiceConfigEntity scv1 WHERE (scv1.clusterId = :clusterId) AND (scv1.groupId IS NULL) GROUP BY scv1.serviceName)") })
public class ServiceConfigEntity {
@Id
@Column(name = "service_config_id")
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java
index 44d2b4d..0d87cd8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckAction.java
@@ -118,4 +118,4 @@ public class ComponentVersionCheckAction extends FinalizeUpgradeAction {
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
index eb432df..5c65911 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -34,7 +34,7 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationRequest;
-import org.apache.ambari.server.serveraction.AbstractServerAction;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
import org.apache.ambari.server.serveraction.ServerAction;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
@@ -45,12 +45,14 @@ import org.apache.ambari.server.state.ConfigMergeHelper.ThreeWayValue;
import org.apache.ambari.server.state.DesiredConfig;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.UpgradeContext;
import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.ConfigurationKeyValue;
import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.Insert;
import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.Masked;
import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.Replace;
import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.Transfer;
import org.apache.ambari.server.state.stack.upgrade.ConfigureTask;
+import org.apache.ambari.server.state.stack.upgrade.Direction;
import org.apache.ambari.server.state.stack.upgrade.PropertyKeyState;
import org.apache.ambari.server.state.stack.upgrade.TransferOperation;
import org.apache.commons.lang.StringUtils;
@@ -82,9 +84,9 @@ import com.google.inject.Provider;
* property value</li>
* </ul>
*/
-public class ConfigureAction extends AbstractServerAction {
+public class ConfigureAction extends AbstractUpgradeServerAction {
- private static Logger LOG = LoggerFactory.getLogger(ConfigureAction.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigureAction.class);
/**
* Used to lookup the cluster.
@@ -182,9 +184,16 @@ public class ConfigureAction extends AbstractServerAction {
String clusterName = commandParameters.get("clusterName");
Cluster cluster = m_clusters.getCluster(clusterName);
+ UpgradeContext upgradeContext = getUpgradeContext(cluster);
// such as hdfs-site or hbase-env
String configType = commandParameters.get(ConfigureTask.PARAMETER_CONFIG_TYPE);
+ String serviceName = cluster.getServiceByConfigType(configType);
+
+ RepositoryVersionEntity sourceRepoVersion = upgradeContext.getSourceRepositoryVersion(serviceName);
+ RepositoryVersionEntity targetRepoVersion = upgradeContext.getTargetRepositoryVersion(serviceName);
+ StackId sourceStackId = sourceRepoVersion.getStackId();
+ StackId targetStackId = targetRepoVersion.getStackId();
// extract setters
List<ConfigurationKeyValue> keyValuePairs = Collections.emptyList();
@@ -252,13 +261,12 @@ public class ConfigureAction extends AbstractServerAction {
if (desiredConfig == null) {
throw new AmbariException("Could not find desired config type with name " + configType);
}
+
Config config = cluster.getConfig(configType, desiredConfig.getTag());
if (config == null) {
throw new AmbariException("Could not find config type with name " + configType);
}
- StackId currentStack = cluster.getCurrentStackVersion();
- StackId targetStack = cluster.getDesiredStackVersion();
StackId configStack = config.getStackId();
// !!! initial reference values
@@ -405,8 +413,8 @@ public class ConfigureAction extends AbstractServerAction {
String oldValue = base.get(key);
// !!! values are not changing, so make this a no-op
- if (null != oldValue && value.equals(oldValue)) {
- if (currentStack.equals(targetStack) && !changedValues) {
+ if (StringUtils.equals(value, oldValue)) {
+ if (sourceStackId.equals(targetStackId) && !changedValues) {
updateBufferWithMessage(outputBuffer,
MessageFormat.format(
"{0}/{1} for cluster {2} would not change, skipping setting", configType, key,
@@ -519,7 +527,7 @@ public class ConfigureAction extends AbstractServerAction {
// !!! check to see if we're going to a new stack and double check the
// configs are for the target. Then simply update the new properties instead
// of creating a whole new history record since it was already done
- if (!targetStack.equals(currentStack) && targetStack.equals(configStack)) {
+ if (!targetStackId.equals(sourceStackId) && targetStackId.equals(configStack)) {
config.setProperties(newValues);
config.save();
@@ -528,7 +536,9 @@ public class ConfigureAction extends AbstractServerAction {
// !!! values are different and within the same stack. create a new
// config and service config version
- String serviceVersionNote = "Stack Upgrade";
+ Direction direction = upgradeContext.getDirection();
+ String serviceVersionNote = String.format("%s %s %s", direction.getText(true),
+ direction.getPreposition(), upgradeContext.getRepositoryVersion().getVersion());
String auditName = getExecutionCommand().getRoleParams().get(ServerAction.ACTION_USER_NAME);
@@ -536,12 +546,10 @@ public class ConfigureAction extends AbstractServerAction {
auditName = m_configuration.getAnonymousAuditName();
}
- m_configHelper.createConfigType(cluster, cluster.getDesiredStackVersion(), m_controller, configType,
+ m_configHelper.createConfigType(cluster, targetStackId, m_controller, configType,
newValues, auditName, serviceVersionNote);
- String message = "Finished updating configuration ''{0}''";
- message = MessageFormat.format(message, configType);
- return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", message, "");
+ return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", outputBuffer.toString(), "");
}
@@ -780,4 +788,4 @@ public class ConfigureAction extends AbstractServerAction {
private void updateBufferWithMessage(StringBuilder buffer, String message) {
buffer.append(message).append(System.lineSeparator());
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 345f598..6332fbf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -65,6 +65,8 @@ import org.apache.ambari.server.controller.spi.ClusterController;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
import org.apache.ambari.server.security.authorization.AuthorizationException;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
@@ -104,6 +106,9 @@ public class AmbariContext {
@Inject
ConfigFactory configFactory;
+ @Inject
+ RepositoryVersionDAO repositoryVersionDAO;
+
/**
* Used for getting configuration property values from stack and services.
*/
@@ -186,18 +191,24 @@ public class AmbariContext {
return getController().getActionManager().getTasks(ids);
}
- public void createAmbariResources(ClusterTopology topology, String clusterName, SecurityType securityType, String repoVersion) {
+ public void createAmbariResources(ClusterTopology topology, String clusterName, SecurityType securityType, String repoVersionString) {
Stack stack = topology.getBlueprint().getStack();
StackId stackId = new StackId(stack.getName(), stack.getVersion());
- createAmbariClusterResource(clusterName, stack.getName(), stack.getVersion(), securityType, repoVersion);
- createAmbariServiceAndComponentResources(topology, clusterName, stackId, repoVersion);
+ RepositoryVersionEntity repoVersion = repositoryVersionDAO.findByStackAndVersion(stackId, repoVersionString);
+
+ if (null == repoVersion) {
+ throw new IllegalArgumentException(String.format("Could not identify repository version with stack %s and version %s for installing services",
+ stackId, repoVersionString));
+ }
+
+ createAmbariClusterResource(clusterName, stack.getName(), stack.getVersion(), securityType);
+ createAmbariServiceAndComponentResources(topology, clusterName, stackId, repoVersion.getId());
}
- public void createAmbariClusterResource(String clusterName, String stackName, String stackVersion, SecurityType securityType, String repoVersion) {
+ public void createAmbariClusterResource(String clusterName, String stackName, String stackVersion, SecurityType securityType) {
String stackInfo = String.format("%s-%s", stackName, stackVersion);
final ClusterRequest clusterRequest = new ClusterRequest(null, clusterName, null, securityType, stackInfo, null);
- clusterRequest.setRepositoryVersion(repoVersion);
try {
RetryHelper.executeWithRetry(new Callable<Object>() {
@@ -219,7 +230,7 @@ public class AmbariContext {
}
public void createAmbariServiceAndComponentResources(ClusterTopology topology, String clusterName,
- StackId stackId, String repositoryVersion) {
+ StackId stackId, Long repositoryVersionId) {
Collection<String> services = topology.getBlueprint().getServices();
try {
@@ -232,8 +243,7 @@ public class AmbariContext {
Set<ServiceComponentRequest> componentRequests = new HashSet<>();
for (String service : services) {
String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service);
- serviceRequests.add(new ServiceRequest(clusterName, service, stackId.getStackId(),
- repositoryVersion, null, credentialStoreEnabled));
+ serviceRequests.add(new ServiceRequest(clusterName, service, repositoryVersionId, null, credentialStoreEnabled));
for (String component : topology.getBlueprint().getComponents(service)) {
String recoveryEnabled = topology.getBlueprint().getRecoveryEnabled(service, component);
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
index 4100f15..e20b7b3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
@@ -294,6 +294,7 @@ public class ExecutionCommandWrapperTest {
StackId stackId = cluster.getDesiredStackVersion();
RepositoryVersionEntity repositoryVersion = ormTestHelper.getOrCreateRepositoryVersion(stackId, "0.1-0000");
+ cluster.addService("HDFS", repositoryVersion);
// first try with an INSTALL command - this should not populate version info
ExecutionCommand executionCommand = new ExecutionCommand();
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
index 5feb3cc..8f0c467 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -35,6 +35,7 @@ import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl;
import org.apache.ambari.server.actionmanager.StageFactory;
import org.apache.ambari.server.agent.rest.AgentResource;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
import org.apache.ambari.server.metadata.CachedRoleCommandOrderProvider;
import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
@@ -74,13 +75,13 @@ import org.apache.ambari.server.state.stack.OsFamily;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
import org.apache.ambari.server.topology.PersistedState;
import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.easymock.EasyMock;
import org.eclipse.jetty.server.SessionManager;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -102,7 +103,7 @@ import junit.framework.Assert;
public class AgentResourceTest extends RandomPortJerseyTest {
static String PACKAGE_NAME = "org.apache.ambari.server.agent.rest";
- private static Log LOG = LogFactory.getLog(AgentResourceTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AgentResourceTest.class);
protected Client client;
HeartBeatHandler handler;
ActionManager actionManager;
@@ -323,6 +324,7 @@ public class AgentResourceTest extends RandomPortJerseyTest {
bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
bind(PersistedState.class).toInstance(createNiceMock(PersistedState.class));
bind(RoleCommandOrderProvider.class).to(CachedRoleCommandOrderProvider.class);
+ bind(AmbariManagementController.class).toInstance(createNiceMock(AmbariManagementController.class));
}
private void installDependencies() {
@@ -358,4 +360,4 @@ public class AgentResourceTest extends RandomPortJerseyTest {
EasyMock.createMock(StackManagerFactory.class));
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index 608c3ae..5ee3c8a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -242,7 +242,7 @@ public class AmbariMetaInfoTest {
assertNotNull(redhat6Repo);
for (RepositoryInfo ri : redhat6Repo) {
if (STACK_NAME_HDP.equals(ri.getRepoName())) {
- assertTrue(ri.getBaseUrl().equals(ri.getDefaultBaseUrl()));
+ assertEquals(ri.getBaseUrl(), ri.getDefaultBaseUrl());
}
}
}
@@ -1702,7 +1702,7 @@ public class AmbariMetaInfoTest {
AlertDefinitionDAO dao = injector.getInstance(AlertDefinitionDAO.class);
List<AlertDefinitionEntity> definitions = dao.findAll(clusterId);
- assertEquals(13, definitions.size());
+ assertEquals(12, definitions.size());
// figure out how many of these alerts were merged into from the
// non-stack alerts.json
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
index ae7ba9d..45cd000 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
@@ -18,8 +18,6 @@
package org.apache.ambari.server.audit.request.creator;
-import junit.framework.Assert;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -38,6 +36,8 @@ import org.apache.ambari.server.controller.internal.HostResourceProvider;
import org.apache.ambari.server.controller.spi.Resource;
import org.junit.Test;
+import junit.framework.Assert;
+
public class HostEventCreatorTest extends AuditEventCreatorTestBase{
@Test
@@ -45,7 +45,7 @@ public class HostEventCreatorTest extends AuditEventCreatorTestBase{
HostEventCreator creator = new HostEventCreator();
Map<String,Object> properties = new HashMap<>();
- properties.put(HostResourceProvider.HOST_NAME_PROPERTY_ID, "ambari1.example.com");
+ properties.put(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID, "ambari1.example.com");
Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.POST, Resource.Type.Host, properties, null);
Result result = AuditEventCreatorTestHelper.createResult(new ResultStatus(ResultStatus.STATUS.OK));
@@ -73,7 +73,7 @@ public class HostEventCreatorTest extends AuditEventCreatorTestBase{
properties.put("host_components", set);
- Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.QUERY_POST, Resource.Type.Host, properties, null, HostResourceProvider.HOST_NAME_PROPERTY_ID + "=ambari1.example.com");
+ Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.QUERY_POST, Resource.Type.Host, properties, null, HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID + "=ambari1.example.com");
Result result = AuditEventCreatorTestHelper.createResult(new ResultStatus(ResultStatus.STATUS.OK));
AuditEvent event = AuditEventCreatorTestHelper.getEvent(creator, request, result);
@@ -106,4 +106,4 @@ public class HostEventCreatorTest extends AuditEventCreatorTestBase{
Assert.assertTrue(actual.contains(userName));
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index 1af8321..a60b696 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -695,7 +695,7 @@ public class AmbariCustomCommandExecutionHelperTest {
RepositoryVersionEntity repositoryVersion) throws AmbariException, AuthorizationException {
ServiceRequest r1 = new ServiceRequest(clusterName, serviceName,
- repositoryVersion.getStackId().getStackId(), repositoryVersion.getVersion(), null, "false");
+ repositoryVersion.getId(), null, "false");
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r1);
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 4024f05..c80620f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -556,19 +556,14 @@ public class AmbariManagementControllerImplTest {
@Test
public void testUpdateClusters() throws Exception {
// member state mocks
- Capture<AmbariManagementController> controllerCapture = EasyMock.newCapture();
+ Capture<AmbariManagementController> controllerCapture = new Capture<>();
Injector injector = createStrictMock(Injector.class);
Cluster cluster = createNiceMock(Cluster.class);
ActionManager actionManager = createNiceMock(ActionManager.class);
ClusterRequest clusterRequest = createNiceMock(ClusterRequest.class);
- ConfigurationRequest configurationRequest = createNiceMock(ConfigurationRequest.class);
// requests
- Set<ClusterRequest> setRequests = new HashSet<ClusterRequest>();
- setRequests.add(clusterRequest);
-
- List<ConfigurationRequest> configRequests = new ArrayList<>();
- configRequests.add(configurationRequest);
+ Set<ClusterRequest> setRequests = Collections.singleton(clusterRequest);
KerberosHelper kerberosHelper = createStrictMock(KerberosHelper.class);
// expectations
@@ -578,22 +573,17 @@ public class AmbariManagementControllerImplTest {
expect(injector.getInstance(KerberosHelper.class)).andReturn(kerberosHelper);
expect(clusterRequest.getClusterName()).andReturn("clusterNew").times(3);
expect(clusterRequest.getClusterId()).andReturn(1L).times(6);
- expect(clusterRequest.getDesiredConfig()).andReturn(configRequests);
- expect(configurationRequest.getVersionTag()).andReturn(null).times(1);
expect(clusters.getClusterById(1L)).andReturn(cluster).times(2);
expect(cluster.getClusterName()).andReturn("clusterOld").times(1);
- cluster.addSessionAttributes(EasyMock.<Map<String, Object>>anyObject());
+ cluster.addSessionAttributes(anyObject(Map.class));
expectLastCall().once();
cluster.setClusterName("clusterNew");
expectLastCall();
- configurationRequest.setVersionTag(EasyMock.anyObject(String.class));
- expectLastCall();
-
// replay mocks
- replay(actionManager, cluster, clusters, injector, clusterRequest, sessionManager, configurationRequest);
+ replay(actionManager, cluster, clusters, injector, clusterRequest, sessionManager);
// test
AmbariManagementController controller = new AmbariManagementControllerImpl(actionManager, clusters, injector);
@@ -601,9 +591,8 @@ public class AmbariManagementControllerImplTest {
// assert and verify
assertSame(controller, controllerCapture.getValue());
- verify(actionManager, cluster, clusters, injector, clusterRequest, sessionManager, configurationRequest);
+ verify(actionManager, cluster, clusters, injector, clusterRequest, sessionManager);
}
-
/**
* Ensure that processing update request does not fail on configuration
* properties with no value specified (no value = null reference value)
@@ -2034,7 +2023,7 @@ public class AmbariManagementControllerImplTest {
expect(injector.getInstance(Gson.class)).andReturn(null);
expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class));
-
+
OsFamily osFamilyMock = createNiceMock(OsFamily.class);
EasyMock.expect(osFamilyMock.isVersionedOsFamilyExtendedByVersionedFamily("testOSFamily", "testOSFamily")).andReturn(true).times(3);
@@ -2229,7 +2218,7 @@ public class AmbariManagementControllerImplTest {
public NestedTestClass(ActionManager actionManager, Clusters clusters, Injector injector, OsFamily osFamilyMock) throws Exception {
super(actionManager, clusters, injector);
- this.osFamily = osFamilyMock;
+ osFamily = osFamilyMock;
}
// public ServiceOsSpecific testPopulateServicePackagesInfo(ServiceInfo serviceInfo, Map<String, String> hostParams,
@@ -2398,7 +2387,6 @@ public class AmbariManagementControllerImplTest {
f.set(controller, configuration);
ClusterRequest cr = new ClusterRequest(null, "c1", "HDP-2.1", null);
- cr.setRepositoryVersion("2.1.1.0-1234");
controller.createCluster(cr);
// verification
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/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 9b03567..e029d85 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
@@ -205,8 +205,6 @@ public class AmbariManagementControllerTest {
private static final String REQUEST_CONTEXT_PROPERTY = "context";
- private static final String CLUSTER_HOST_INFO = "clusterHostInfo";
-
private static AmbariManagementController controller;
private static Clusters clusters;
private ActionDBAccessor actionDB;
@@ -377,7 +375,7 @@ public class AmbariManagementControllerTest {
}
ServiceRequest r1 = new ServiceRequest(clusterName, serviceName,
- repositoryVersion.getStackId().getStackId(), repositoryVersion.getVersion(), dStateStr,
+ repositoryVersion.getId(), dStateStr,
null);
Set<ServiceRequest> requests = new HashSet<>();
@@ -461,7 +459,7 @@ public class AmbariManagementControllerTest {
private long stopService(String clusterName, String serviceName,
boolean runSmokeTests, boolean reconfigureClients) throws
AmbariException, AuthorizationException {
- ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, null, State.INSTALLED.toString(), null);
+ ServiceRequest r = new ServiceRequest(clusterName, serviceName, null, State.INSTALLED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
Map<String, String> mapRequestProps = new HashMap<>();
@@ -526,7 +524,7 @@ public class AmbariManagementControllerTest {
boolean runSmokeTests, boolean reconfigureClients,
MaintenanceStateHelper maintenanceStateHelper) throws
AmbariException, AuthorizationException {
- ServiceRequest r = new ServiceRequest(clusterName, serviceName, "HDP-0.2", "0.2-1234",
+ ServiceRequest r = new ServiceRequest(clusterName, serviceName, repositoryVersion02.getId(),
State.STARTED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -581,7 +579,7 @@ public class AmbariManagementControllerTest {
Map<String, String> mapRequestPropsInput)
throws AmbariException, AuthorizationException {
- ServiceRequest r = new ServiceRequest(clusterName, serviceName, "HDP-0.2", "0.2-1234",
+ ServiceRequest r = new ServiceRequest(clusterName, serviceName, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
@@ -710,7 +708,7 @@ public class AmbariManagementControllerTest {
Assert.assertEquals(serviceName, s.getName());
Assert.assertEquals(cluster1, s.getCluster().getClusterName());
- ServiceRequest req = new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", null, null);
+ ServiceRequest req = new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), null, null);
Set<ServiceResponse> r =
ServiceResourceProviderTest.getServices(controller, Collections.singleton(req));
@@ -732,7 +730,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest rInvalid = new ServiceRequest(null, null, null, null, null, null);
+ ServiceRequest rInvalid = new ServiceRequest(null, null, null, null, null);
set1.add(rInvalid);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
fail("Expected failure for invalid requests");
@@ -742,7 +740,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest rInvalid = new ServiceRequest("foo", null, null, null, null, null);
+ ServiceRequest rInvalid = new ServiceRequest("foo", null, null, null, null);
set1.add(rInvalid);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
fail("Expected failure for invalid requests");
@@ -752,7 +750,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest rInvalid = new ServiceRequest("foo", "bar", null, null, null, null);
+ ServiceRequest rInvalid = new ServiceRequest("foo", "bar", null, null, null);
set1.add(rInvalid);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
fail("Expected failure for invalid cluster");
@@ -770,8 +768,8 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", null, null, null, null);
- ServiceRequest valid2 = new ServiceRequest(cluster1, "HDFS", null, null, null, null);
+ ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", null, null, null);
+ ServiceRequest valid2 = new ServiceRequest(cluster1, "HDFS", null, null, null);
set1.add(valid1);
set1.add(valid2);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
@@ -782,7 +780,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest valid1 = new ServiceRequest(cluster1, "bar", "HDP-0.2", "0.2-1234", State.STARTED.toString(), null);
+ ServiceRequest valid1 = new ServiceRequest(cluster1, "bar", repositoryVersion02.getId(), State.STARTED.toString(), null);
set1.add(valid1);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
fail("Expected failure for invalid service");
@@ -793,8 +791,8 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
- ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", State.STARTED.toString(), null);
- ServiceRequest valid2 = new ServiceRequest(cluster2, "HDFS", "HDP-0.2", "0.2-1234", State.STARTED.toString(), null);
+ ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), State.STARTED.toString(), null);
+ ServiceRequest valid2 = new ServiceRequest(cluster2, "HDFS", repositoryVersion02.getId(), State.STARTED.toString(), null);
set1.add(valid1);
set1.add(valid2);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
@@ -807,14 +805,14 @@ public class AmbariManagementControllerTest {
Assert.assertEquals(0, clusters.getCluster(cluster1).getServices().size());
set1.clear();
- ServiceRequest valid = new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", null, null);
+ ServiceRequest valid = new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), null, null);
set1.add(valid);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
try {
set1.clear();
- ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", State.STARTED.toString(), null);
- ServiceRequest valid2 = new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", State.STARTED.toString(), null);
+ ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), State.STARTED.toString(), null);
+ ServiceRequest valid2 = new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), State.STARTED.toString(), null);
set1.add(valid1);
set1.add(valid2);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
@@ -856,7 +854,7 @@ public class AmbariManagementControllerTest {
String serviceName2 = "MAPREDUCE";
createService(cluster1, serviceName2, State.INIT);
- ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null, null);
+ ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null);
Set<ServiceResponse> response = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
Assert.assertEquals(2, response.size());
@@ -876,15 +874,15 @@ public class AmbariManagementControllerTest {
clusters.addCluster(cluster1, new StackId("HDP-0.1"));
- ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", "HDP-0.1", "0.1-1234", null, null);
- ServiceRequest valid2 = new ServiceRequest(cluster1, "MAPREDUCE", "HDP-0.1", "0.1-1234", null, null);
+ ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", repositoryVersion01.getId(), null, null);
+ ServiceRequest valid2 = new ServiceRequest(cluster1, "MAPREDUCE", repositoryVersion01.getId(), null, null);
set1.add(valid1);
set1.add(valid2);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
try {
- valid1 = new ServiceRequest(cluster1, "PIG", "HDP-0.1", "0.1-1234", null, null);
- valid2 = new ServiceRequest(cluster1, "MAPREDUCE", "HDP-0.1", "0.2-1234", null, null);
+ valid1 = new ServiceRequest(cluster1, "PIG", repositoryVersion01.getId(), null, null);
+ valid2 = new ServiceRequest(cluster1, "MAPREDUCE", 4L, null, null);
set1.add(valid1);
set1.add(valid2);
ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
@@ -1805,8 +1803,6 @@ public class AmbariManagementControllerTest {
String host2 = getUniqueName();
- Map<String, String> hostAttributes = null;
-
HostRequest r1 = new HostRequest(host1, null);
r1.toString();
@@ -1966,7 +1962,7 @@ public class AmbariManagementControllerTest {
Config c1 = configFactory.createNew(cluster, "hdfs-site", "v1", properties, propertiesAttributes);
configs.put(c1.getType(), c1);
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
@@ -1997,7 +1993,6 @@ public class AmbariManagementControllerTest {
String serviceName = "HDFS";
Cluster cluster = clusters.getCluster(cluster1);
- Service s1 = cluster.getService(serviceName);
Map<String, Config> configs = new HashMap<>();
Map<String, String> properties = new HashMap<>();
@@ -2011,7 +2006,7 @@ public class AmbariManagementControllerTest {
properties.put("d", "d1");
Config c2 = configFactory.createNew(cluster, "core-site", "v1", properties, propertiesAttributes);
- Config c3 = configFactory.createNew(cluster, "foo-site", "v1", properties, propertiesAttributes);
+ configFactory.createNew(cluster, "foo-site", "v1", properties, propertiesAttributes);
Map<String, String> mapRequestProps = new HashMap<>();
mapRequestProps.put("context", "Called from a test");
@@ -2019,7 +2014,7 @@ public class AmbariManagementControllerTest {
configs.put(c1.getType(), c1);
configs.put(c2.getType(), c2);
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
@@ -2128,7 +2123,7 @@ public class AmbariManagementControllerTest {
}
}
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234", State.STARTED.toString(),
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(), State.STARTED.toString(),
null);
requests.clear();
requests.add(r);
@@ -2175,7 +2170,7 @@ public class AmbariManagementControllerTest {
}
}
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234", State.INSTALLED.toString(),
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(), State.INSTALLED.toString(),
null);
requests.clear();
requests.add(r);
@@ -2278,7 +2273,7 @@ public class AmbariManagementControllerTest {
c1.addService(s1);
s1.setDesiredState(State.INSTALLED);
- ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null, null);
+ ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null);
Set<ServiceResponse> resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
ServiceResponse resp1 = resp.iterator().next();
@@ -2324,7 +2319,7 @@ public class AmbariManagementControllerTest {
s2.setDesiredState(State.INSTALLED);
s4.setDesiredState(State.INSTALLED);
- ServiceRequest r = new ServiceRequest(null, null, null, null, null, null);
+ ServiceRequest r = new ServiceRequest(null, null, null, null, null);
Set<ServiceResponse> resp;
try {
@@ -2334,35 +2329,35 @@ public class AmbariManagementControllerTest {
// Expected
}
- r = new ServiceRequest(c1.getClusterName(), null, null, null, null, null);
+ r = new ServiceRequest(c1.getClusterName(), null, null, null, null);
resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
Assert.assertEquals(3, resp.size());
- r = new ServiceRequest(c1.getClusterName(), s2.getName(), null, null, null, null);
+ r = new ServiceRequest(c1.getClusterName(), s2.getName(), null, null, null);
resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
Assert.assertEquals(1, resp.size());
Assert.assertEquals(s2.getName(), resp.iterator().next().getServiceName());
try {
- r = new ServiceRequest(c2.getClusterName(), s1.getName(), null, null, null, null);
+ r = new ServiceRequest(c2.getClusterName(), s1.getName(), null, null, null);
ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
fail("Expected failure for invalid service");
} catch (Exception e) {
// Expected
}
- r = new ServiceRequest(c1.getClusterName(), null, null, null, "INSTALLED", null);
+ r = new ServiceRequest(c1.getClusterName(), null, null, "INSTALLED", null);
resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
Assert.assertEquals(2, resp.size());
- r = new ServiceRequest(c2.getClusterName(), null, null, null, "INIT", null);
+ r = new ServiceRequest(c2.getClusterName(), null, null, "INIT", null);
resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
Assert.assertEquals(1, resp.size());
ServiceRequest r1, r2, r3;
- r1 = new ServiceRequest(c1.getClusterName(), null, null, null, "INSTALLED", null);
- r2 = new ServiceRequest(c2.getClusterName(), null, null, null, "INIT", null);
- r3 = new ServiceRequest(c2.getClusterName(), null, null, null, "INIT", null);
+ r1 = new ServiceRequest(c1.getClusterName(), null, null, "INSTALLED", null);
+ r2 = new ServiceRequest(c2.getClusterName(), null, null, "INIT", null);
+ r3 = new ServiceRequest(c2.getClusterName(), null, null, "INIT", null);
Set<ServiceRequest> reqs = new HashSet<>();
reqs.addAll(Arrays.asList(r1, r2, r3));
@@ -3164,7 +3159,7 @@ public class AmbariManagementControllerTest {
ServiceRequest r;
try {
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234",
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(),
State.INSTALLING.toString(), null);
reqs.clear();
reqs.add(r);
@@ -3174,7 +3169,7 @@ public class AmbariManagementControllerTest {
// Expected
}
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.2", "0.2-1234", State.INSTALLED.toString(),
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion02.getId(), State.INSTALLED.toString(),
null);
reqs.clear();
reqs.add(r);
@@ -3220,9 +3215,9 @@ public class AmbariManagementControllerTest {
ServiceRequest req1, req2;
try {
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
- req2 = new ServiceRequest(cluster2, serviceName2, "HDP-0.2", "0.2-1234",
+ req2 = new ServiceRequest(cluster2, serviceName2, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
reqs.add(req1);
reqs.add(req2);
@@ -3234,9 +3229,9 @@ public class AmbariManagementControllerTest {
try {
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
- req2 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req2 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
reqs.add(req1);
reqs.add(req2);
@@ -3251,9 +3246,9 @@ public class AmbariManagementControllerTest {
try {
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.INSTALLED.toString(), null);
- req2 = new ServiceRequest(cluster1, serviceName2, "HDP-0.2", "0.2-1234",
+ req2 = new ServiceRequest(cluster1, serviceName2, repositoryVersion02.getId(),
State.STARTED.toString(), null);
reqs.add(req1);
reqs.add(req2);
@@ -3365,7 +3360,7 @@ public class AmbariManagementControllerTest {
ServiceRequest req1, req2;
try {
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.STARTED.toString(), null);
reqs.add(req1);
ServiceResourceProviderTest.updateServices(controller, reqs, mapRequestProps, true, false);
@@ -3392,7 +3387,7 @@ public class AmbariManagementControllerTest {
try {
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.STARTED.toString(), null);
reqs.add(req1);
ServiceResourceProviderTest.updateServices(controller, reqs, mapRequestProps, true, false);
@@ -3420,9 +3415,9 @@ public class AmbariManagementControllerTest {
sch5.setState(State.INSTALLED);
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.STARTED.toString(), null);
- req2 = new ServiceRequest(cluster1, serviceName2, "HDP-0.2", "0.2-1234",
+ req2 = new ServiceRequest(cluster1, serviceName2, repositoryVersion02.getId(),
State.STARTED.toString(), null);
reqs.add(req1);
reqs.add(req2);
@@ -3508,9 +3503,9 @@ public class AmbariManagementControllerTest {
// test no-op
reqs.clear();
- req1 = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.STARTED.toString(), null);
- req2 = new ServiceRequest(cluster1, serviceName2, "HDP-0.2", "0.2-1234",
+ req2 = new ServiceRequest(cluster1, serviceName2, repositoryVersion02.getId(),
State.STARTED.toString(), null);
reqs.add(req1);
reqs.add(req2);
@@ -4681,7 +4676,7 @@ public class AmbariManagementControllerTest {
.getServiceComponentHost(host2));
// Install
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(),
State.INSTALLED.toString(), null);
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -4701,7 +4696,7 @@ public class AmbariManagementControllerTest {
}
// Start
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234",
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(),
State.STARTED.toString(), null);
requests.clear();
requests.add(r);
@@ -4793,7 +4788,7 @@ public class AmbariManagementControllerTest {
configVersions.put("typeC", "v2");
configVersions.put("typeE", "v1");
sReqs.clear();
- sReqs.add(new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", null, null));
+ sReqs.add(new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), null, null));
Assert.assertNull(ServiceResourceProviderTest.updateServices(controller, sReqs, mapRequestProps, true, false));
@@ -4942,7 +4937,7 @@ public class AmbariManagementControllerTest {
configVersions.put("typeC", "v2");
configVersions.put("typeE", "v1");
sReqs.clear();
- sReqs.add(new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", null, null));
+ sReqs.add(new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), null, null));
Assert.assertNull(ServiceResourceProviderTest.updateServices(controller, sReqs, mapRequestProps, true, false));
// update configs at SCH level
@@ -5008,7 +5003,7 @@ public class AmbariManagementControllerTest {
host2, null);
// Install
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(),
State.INSTALLED.toString());
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -5108,7 +5103,7 @@ public class AmbariManagementControllerTest {
configVersions.put("core-site", "version1");
configVersions.put("hdfs-site", "version1");
sReqs.clear();
- sReqs.add(new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", null));
+ sReqs.add(new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), null));
Assert.assertNull(ServiceResourceProviderTest.updateServices(controller, sReqs, mapRequestProps, true, false));
// Reconfigure S Level
@@ -5116,7 +5111,7 @@ public class AmbariManagementControllerTest {
configVersions.put("core-site", "version122");
sReqs.clear();
- sReqs.add(new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", null));
+ sReqs.add(new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), null));
Assert.assertNull(ServiceResourceProviderTest.updateServices(controller, sReqs, mapRequestProps, true, false));
entityManager.clear();
@@ -5429,7 +5424,7 @@ public class AmbariManagementControllerTest {
createServiceComponentHost(cluster1, null, componentName1,
host2, null);
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(),
State.INSTALLED.toString());
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -5466,7 +5461,7 @@ public class AmbariManagementControllerTest {
}
}
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", State.STARTED.toString());
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), State.STARTED.toString());
requests.clear();
requests.add(r);
@@ -5890,7 +5885,7 @@ public class AmbariManagementControllerTest {
// Start Service
ServiceRequest sr = new ServiceRequest(
- cluster1, serviceName, "HDP-2.0.6", "2.0.6-1234", State.STARTED.name());
+ cluster1, serviceName, repositoryVersion206.getId(), State.STARTED.name());
Set<ServiceRequest> setReqs = new HashSet<>();
setReqs.add(sr);
RequestStatusResponse resp = ServiceResourceProviderTest.updateServices(controller,
@@ -6120,12 +6115,12 @@ public class AmbariManagementControllerTest {
RepositoryVersionEntity repositoryVersion = repositoryVersion206;
ConfigFactory cf = injector.getInstance(ConfigFactory.class);
- Config config1 = cf.createNew(cluster, "global", "version1",
+ cf.createNew(cluster, "global", "version1",
new HashMap<String, String>() {{
put("key1", "value1");
}}, new HashMap<String, Map<String,String>>());
- Config config2 = cf.createNew(cluster, "core-site", "version1",
+ cf.createNew(cluster, "core-site", "version1",
new HashMap<String, String>() {{
put("key1", "value1");
}}, new HashMap<String, Map<String,String>>());
@@ -6493,7 +6488,7 @@ public class AmbariManagementControllerTest {
put("core-site", "version1");
put("hdfs-site", "version1");
}};
- ServiceRequest sr = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", null);
+ ServiceRequest sr = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), null);
ServiceResourceProviderTest.updateServices(controller, Collections.singleton(sr), new HashMap<String,String>(), false, false);
// Install
@@ -6544,7 +6539,7 @@ public class AmbariManagementControllerTest {
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234",
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(),
State.INSTALLED.toString());
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -7536,7 +7531,7 @@ public class AmbariManagementControllerTest {
.getServiceComponentHost(host2));
// Install
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", State.INSTALLED.toString());
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), State.INSTALLED.toString());
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -7555,7 +7550,7 @@ public class AmbariManagementControllerTest {
}
// Start
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", State.STARTED.toString());
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), State.STARTED.toString());
requests.clear();
requests.add(r);
ServiceResourceProviderTest.updateServices(controller, requests, mapRequestProps, true, false);
@@ -7600,7 +7595,7 @@ public class AmbariManagementControllerTest {
}
// Stop all services
- r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", State.INSTALLED.toString());
+ r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), State.INSTALLED.toString());
requests.clear();
requests.add(r);
ServiceResourceProviderTest.updateServices(controller, requests, mapRequestProps, true, false);
@@ -7800,7 +7795,7 @@ public class AmbariManagementControllerTest {
// Install
- ServiceRequest r = new ServiceRequest(cluster1, serviceName, "HDP-0.1", "0.1-1234", State.INSTALLED.toString());
+ ServiceRequest r = new ServiceRequest(cluster1, serviceName, repositoryVersion01.getId(), State.INSTALLED.toString());
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r);
@@ -7898,7 +7893,7 @@ public class AmbariManagementControllerTest {
sch3.setState(State.INSTALLED);
// an UNKOWN failure will throw an exception
- ServiceRequest req = new ServiceRequest(cluster1, serviceName1, "HDP-0.2", "0.2-1234",
+ ServiceRequest req = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
State.INSTALLED.toString());
ServiceResourceProviderTest.updateServices(controller, Collections.singleton(req), Collections.<String, String>emptyMap(), true, false);
}
@@ -8425,7 +8420,7 @@ public class AmbariManagementControllerTest {
amc.createCluster(clusterRequest);
Set<ServiceRequest> serviceRequests = new HashSet<>();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);
@@ -8486,9 +8481,9 @@ public class AmbariManagementControllerTest {
HostResourceProviderTest.createHosts(amc, hrs);
Set<ServiceRequest> serviceRequests = new HashSet<>();
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", STACK_ID, "2.0.1-1234", null));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", STACK_ID, "2.0.1-1234", null));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", STACK_ID, "2.0.1-1234", null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), null));
ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);
@@ -8562,8 +8557,8 @@ public class AmbariManagementControllerTest {
amc.createCluster(clusterRequest);
Set<ServiceRequest> serviceRequests = new HashSet<>();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
- serviceRequests.add(new ServiceRequest(cluster1, "HIVE", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HIVE", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);
@@ -8584,7 +8579,7 @@ public class AmbariManagementControllerTest {
Assert.assertTrue(clusters.getCluster(cluster1).getDesiredConfigs().containsKey("hive-site"));
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);
@@ -8614,7 +8609,7 @@ public class AmbariManagementControllerTest {
amc.createHostComponents(componentHostRequests);
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", "INSTALLED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);
Cluster cluster = clusters.getCluster(cluster1);
@@ -8681,7 +8676,7 @@ public class AmbariManagementControllerTest {
componentHost.handleEvent(new ServiceComponentHostOpSucceededEvent(componentHost.getServiceComponentName(), componentHost.getHostName(), System.currentTimeMillis()));
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", "STARTED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), "STARTED"));
RequestStatusResponse response = ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
@@ -8743,14 +8738,14 @@ public class AmbariManagementControllerTest {
// ServiceComponentHost remains in disabled after service stop
assertEquals(sch.getServiceComponentName(),"DATANODE");
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", "INSTALLED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
assertEquals(State.DISABLED, sch.getState());
// ServiceComponentHost remains in disabled after service start
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", "STARTED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), "STARTED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
assertEquals(State.DISABLED, sch.getState());
@@ -8772,14 +8767,14 @@ public class AmbariManagementControllerTest {
*Test remove service
*/
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", "INSTALLED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);
serviceRequests.clear();
serviceRequests.add(new ServiceRequest(cluster1, null, null, null, null));
org.junit.Assert.assertEquals(2, ServiceResourceProviderTest.getServices(amc, serviceRequests).size());
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
- serviceRequests.add(new ServiceRequest(cluster1, "HIVE", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HIVE", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.deleteServices(amc, serviceRequests);
serviceRequests.clear();
serviceRequests.add(new ServiceRequest(cluster1, null, null, null, null));
@@ -8789,7 +8784,7 @@ public class AmbariManagementControllerTest {
*Test add service again
*/
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);
@@ -8806,7 +8801,7 @@ public class AmbariManagementControllerTest {
amc.createConfiguration(configurationRequest);
//Add configs to service
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-1.2.0", "1.2.0-1234", null));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);
//Crate service components
serviceComponentRequests = new HashSet<>();
@@ -8861,9 +8856,9 @@ public class AmbariManagementControllerTest {
amc.createCluster(clusterRequest);
Set<ServiceRequest> serviceRequests = new HashSet<>();
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", "HDP-2.0.1", "2.0.1-1234", null));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", "HDP-2.0.1", "2.0.1-1234", null));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", "HDP-2.0.1", "2.0.1-1234", null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), null));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), null));
ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);
@@ -8894,9 +8889,9 @@ public class AmbariManagementControllerTest {
//Install services
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", "HDP-2.0.1", "2.0.1-1234", State.INSTALLED.name()));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", "HDP-2.0.1", "2.0.1-1234", State.INSTALLED.name()));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", "HDP-2.0.1", "2.0.1-1234", State.INSTALLED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), State.INSTALLED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), State.INSTALLED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), State.INSTALLED.name()));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);
@@ -8918,9 +8913,9 @@ public class AmbariManagementControllerTest {
//Start services
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", "HDP-2.0.1", "2.0.1-1234", State.STARTED.name()));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", "HDP-2.0.1", "2.0.1-1234", State.STARTED.name()));
- serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", "HDP-2.0.1", "2.0.1-1234", State.STARTED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), State.STARTED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), State.STARTED.name()));
+ serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), State.STARTED.name()));
RequestStatusResponse response = ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
@@ -9102,7 +9097,7 @@ public class AmbariManagementControllerTest {
//Stopping HDFS service
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", "INSTALLED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, false,
false);
@@ -9110,7 +9105,7 @@ public class AmbariManagementControllerTest {
// test(HDFS_SERVICE_CHECK) won't run
boolean runSmokeTest = false;
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", "STARTED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), "STARTED"));
response = ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps,
runSmokeTest, false);
@@ -9125,7 +9120,7 @@ public class AmbariManagementControllerTest {
//Stopping HDFS service
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", "INSTALLED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, false,
false);
@@ -9133,7 +9128,7 @@ public class AmbariManagementControllerTest {
//run_smoke_test flag is set, smoke test will be run
runSmokeTest = true;
serviceRequests.clear();
- serviceRequests.add(new ServiceRequest(cluster1, "HDFS", "HDP-0.2", "0.2-1234", "STARTED"));
+ serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion02.getId(), "STARTED"));
response = ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps,
runSmokeTest, false);
@@ -9373,7 +9368,7 @@ public class AmbariManagementControllerTest {
MaintenanceStateHelper maintenanceStateHelper = MaintenanceStateHelperTest.getMaintenanceStateHelperInstance(clusters);
// test updating a service
- ServiceRequest sr = new ServiceRequest(cluster1, serviceName, "HDP-1.2.0", "1.2.0-1234", null);
+ ServiceRequest sr = new ServiceRequest(cluster1, serviceName, repositoryVersion120.getId(), null);
sr.setMaintenanceState(MaintenanceState.ON.name());
ServiceResourceProviderTest.updateServices(controller,
Collections.singleton(sr), requestProperties, false, false,
@@ -9590,7 +9585,7 @@ public class AmbariManagementControllerTest {
MaintenanceStateHelperTest.getMaintenanceStateHelperInstance(clusters);
// test updating a service
- ServiceRequest sr = new ServiceRequest(cluster1, service1Name, "HDP-2.2.0", "2.2.0-1234", null);
+ ServiceRequest sr = new ServiceRequest(cluster1, service1Name, repositoryVersion220.getId(), null);
sr.setCredentialStoreEnabled("true");
ServiceResourceProviderTest.updateServices(controller,
@@ -9600,7 +9595,7 @@ public class AmbariManagementControllerTest {
Assert.assertTrue(service1.isCredentialStoreSupported());
Assert.assertFalse(service1.isCredentialStoreRequired());
- ServiceRequest sr2 = new ServiceRequest(cluster1, service2Name, "HDP-2.2.0", "2.2.0-1234", null);
+ ServiceRequest sr2 = new ServiceRequest(cluster1, service2Name, repositoryVersion220.getId(), null);
sr2.setCredentialStoreEnabled("true");
try {
ServiceResourceProviderTest.updateServices(controller,
@@ -9612,7 +9607,7 @@ public class AmbariManagementControllerTest {
"Invalid arguments, cannot enable credential store as it is not supported by the service. Service=STORM"));
}
- ServiceRequest sr3 = new ServiceRequest(cluster1, service3Name, "HDP-2.2.0", "2.2.0-1234", null);
+ ServiceRequest sr3 = new ServiceRequest(cluster1, service3Name, repositoryVersion220.getId(), null);
sr3.setCredentialStoreEnabled("false");
try {
ServiceResourceProviderTest.updateServices(controller,
@@ -9624,7 +9619,7 @@ public class AmbariManagementControllerTest {
"Invalid arguments, cannot disable credential store as it is required by the service. Service=ZOOKEEPER"));
}
- ServiceRequest sr4 = new ServiceRequest(cluster1, service3Name, "HDP-2.2.0", "2.2.0-1234", null);
+ ServiceRequest sr4 = new ServiceRequest(cluster1, service3Name, repositoryVersion220.getId(), null);
sr4.setCredentialStoreSupported("true");
try {
ServiceResourceProviderTest.updateServices(controller,
@@ -9701,8 +9696,8 @@ public class AmbariManagementControllerTest {
service2.setMaintenanceState(MaintenanceState.ON);
Set<ServiceRequest> srs = new HashSet<>();
- srs.add(new ServiceRequest(cluster1, serviceName1, "HDP-0.1", "0.1-1234", State.INSTALLED.name()));
- srs.add(new ServiceRequest(cluster1, serviceName2, "HDP-0.1", "0.1-1234", State.INSTALLED.name()));
+ srs.add(new ServiceRequest(cluster1, serviceName1, repositoryVersion01.getId(), State.INSTALLED.name()));
+ srs.add(new ServiceRequest(cluster1, serviceName2, repositoryVersion01.getId(), State.INSTALLED.name()));
RequestStatusResponse rsr = ServiceResourceProviderTest.updateServices(controller, srs,
requestProperties, false, false, maintenanceStateHelper);
@@ -9735,8 +9730,8 @@ public class AmbariManagementControllerTest {
h1.setMaintenanceState(cluster.getClusterId(), MaintenanceState.ON);
srs = new HashSet<>();
- srs.add(new ServiceRequest(cluster1, serviceName1, "HDP-0.1", "0.1-1234", State.INSTALLED.name()));
- srs.add(new ServiceRequest(cluster1, serviceName2, "HDP-0.1", "0.1-1234", State.INSTALLED.name()));
+ srs.add(new ServiceRequest(cluster1, serviceName1, repositoryVersion01.getId(), State.INSTALLED.name()));
+ srs.add(new ServiceRequest(cluster1, serviceName2, repositoryVersion01.getId(), State.INSTALLED.name()));
rsr = ServiceResourceProviderTest.updateServices(controller, srs, requestProperties,
false, false, maintenanceStateHelper);
@@ -9750,7 +9745,7 @@ public class AmbariManagementControllerTest {
service2.setMaintenanceState(MaintenanceState.ON);
- ServiceRequest sr = new ServiceRequest(cluster1, serviceName2, "HDP-0.1", "0.1-1234", State.INSTALLED.name());
+ ServiceRequest sr = new ServiceRequest(cluster1, serviceName2, repositoryVersion01.getId(), State.INSTALLED.name());
rsr = ServiceResourceProviderTest.updateServices(controller,
Collections.singleton(sr), requestProperties, false, false, maintenanceStateHelper);
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
index 8ce5b26..4c237a7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
@@ -218,7 +218,7 @@ public class BackgroundCustomCommandExecutionTest {
dStateStr = desiredState.toString();
}
ServiceRequest r1 = new ServiceRequest(clusterName, serviceName,
- m_repositoryVersion.getStackId().getStackId(), m_repositoryVersion.getVersion(), dStateStr);
+ m_repositoryVersion.getId(), m_repositoryVersion.getVersion(), dStateStr);
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r1);
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/ClusterResponseTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/ClusterResponseTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/ClusterResponseTest.java
index 270086f..35a1af3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/ClusterResponseTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/ClusterResponseTest.java
@@ -1,6 +1,4 @@
-package org.apache.ambari.server.controller;
-
-/**
+/*
* 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
@@ -17,6 +15,7 @@ package org.apache.ambari.server.controller;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.ambari.server.controller;
import java.util.HashSet;
import java.util.Set;
@@ -30,7 +29,7 @@ public class ClusterResponseTest {
@Test
public void testBasicGetAndSet() {
- long clusterId = new Long(10);
+ long clusterId = 10L;
String clusterName = "foo";
State provisioningState = State.INSTALLED;
SecurityType securityType = SecurityType.KERBEROS;
@@ -40,12 +39,11 @@ public class ClusterResponseTest {
ClusterResponse r1 =
new ClusterResponse(clusterId, clusterName, provisioningState, securityType,
hostNames, hostNames.size(), "bar", null);
-
+
Assert.assertEquals(clusterId, r1.getClusterId());
Assert.assertEquals(clusterName, r1.getClusterName());
- Assert.assertEquals(provisioningState.name(), r1.getProvisioningState());
- Assert.assertEquals(securityType.name(), r1.getSecurityType());
- Assert.assertArrayEquals(hostNames.toArray(), r1.getHostNames().toArray());
+ Assert.assertEquals(provisioningState, r1.getProvisioningState());
+ Assert.assertEquals(securityType, r1.getSecurityType());
Assert.assertEquals(1, r1.getTotalHosts());
Assert.assertEquals("bar", r1.getDesiredStackVersion());
}
@@ -53,7 +51,7 @@ public class ClusterResponseTest {
@Test
public void testToString() {
ClusterResponse r =
- new ClusterResponse(null, null, null, null, null, null, null, null);
+ new ClusterResponse(0, null, null, null, null, 0, null, null);
r.toString();
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
index d7cbe06..122e4ef 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
@@ -214,7 +214,7 @@ public class RefreshYarnCapacitySchedulerReleaseConfigTest {
new StackId("HDP-2.0.7"), "2.0.7-1234");
ServiceRequest r1 = new ServiceRequest(clusterName, serviceName,
- repositoryVersion.getStackId().getStackId(), repositoryVersion.getVersion(), dStateStr);
+ repositoryVersion.getId(), repositoryVersion.getVersion(), dStateStr);
Set<ServiceRequest> requests = new HashSet<>();
requests.add(r1);