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/08 00:43:32 UTC
[08/10] ambari git commit: AMBARI-21430 - Allow Multiple Versions of
Stack Tools to Co-Exist (jonathanhurley)
http://git-wip-us.apache.org/repos/asf/ambari/blob/6a3bfd5d/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
index 1c2f33e..7018245 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
@@ -19,111 +19,111 @@
package org.apache.ambari.server.controller.internal;
import static org.easymock.EasyMock.anyLong;
- import static org.easymock.EasyMock.anyObject;
- import static org.easymock.EasyMock.capture;
- import static org.easymock.EasyMock.createMock;
- import static org.easymock.EasyMock.createNiceMock;
- import static org.easymock.EasyMock.eq;
- import static org.easymock.EasyMock.expect;
- import static org.easymock.EasyMock.expectLastCall;
- import static org.easymock.EasyMock.replay;
- import static org.easymock.EasyMock.verify;
-
- import java.io.File;
- import java.io.FileInputStream;
- import java.lang.reflect.Field;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.LinkedHashSet;
- import java.util.List;
- import java.util.Map;
- import java.util.Properties;
- import java.util.Set;
-
- import org.apache.ambari.annotations.Experimental;
- import org.apache.ambari.annotations.ExperimentalFeature;
- import org.apache.ambari.server.AmbariException;
- import org.apache.ambari.server.H2DatabaseCleaner;
- import org.apache.ambari.server.Role;
- import org.apache.ambari.server.actionmanager.ActionManager;
- import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper;
- import org.apache.ambari.server.actionmanager.HostRoleCommand;
- import org.apache.ambari.server.actionmanager.Stage;
- import org.apache.ambari.server.actionmanager.StageFactory;
- import org.apache.ambari.server.agent.CommandReport;
- import org.apache.ambari.server.agent.ExecutionCommand;
- import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
- 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.ExecuteActionRequest;
- import org.apache.ambari.server.controller.RequestStatusResponse;
- import org.apache.ambari.server.controller.ResourceProviderFactory;
- import org.apache.ambari.server.controller.spi.Request;
- import org.apache.ambari.server.controller.spi.RequestStatus;
- import org.apache.ambari.server.controller.spi.Resource;
- import org.apache.ambari.server.controller.spi.ResourceProvider;
- import org.apache.ambari.server.controller.utilities.PropertyHelper;
- import org.apache.ambari.server.orm.GuiceJpaInitializer;
- import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
- import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
- import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
- import org.apache.ambari.server.orm.dao.HostVersionDAO;
- import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
- import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
- import org.apache.ambari.server.orm.dao.StackDAO;
- import org.apache.ambari.server.orm.entities.ClusterEntity;
- import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
- import org.apache.ambari.server.orm.entities.HostVersionEntity;
- import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
- import org.apache.ambari.server.orm.entities.ResourceEntity;
- import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
- import org.apache.ambari.server.orm.entities.StackEntity;
- import org.apache.ambari.server.orm.entities.UpgradeEntity;
- import org.apache.ambari.server.security.TestAuthenticationFactory;
- import org.apache.ambari.server.security.authorization.AuthorizationException;
- import org.apache.ambari.server.security.authorization.ResourceType;
- import org.apache.ambari.server.serveraction.upgrades.FinalizeUpgradeAction;
- import org.apache.ambari.server.state.Cluster;
- import org.apache.ambari.server.state.Clusters;
- import org.apache.ambari.server.state.ConfigHelper;
- import org.apache.ambari.server.state.Host;
- import org.apache.ambari.server.state.MaintenanceState;
- import org.apache.ambari.server.state.RepositoryType;
- import org.apache.ambari.server.state.RepositoryVersionState;
- import org.apache.ambari.server.state.Service;
- import org.apache.ambari.server.state.ServiceComponent;
- import org.apache.ambari.server.state.ServiceComponentHost;
- import org.apache.ambari.server.state.ServiceInfo;
- import org.apache.ambari.server.state.ServiceOsSpecific;
- import org.apache.ambari.server.state.StackId;
- import org.apache.ambari.server.state.cluster.ClusterImpl;
- import org.apache.ambari.server.state.stack.upgrade.Direction;
- import org.apache.ambari.server.topology.TopologyManager;
- import org.apache.ambari.server.utils.StageUtils;
- import org.apache.commons.io.IOUtils;
- import org.easymock.Capture;
- import org.easymock.EasyMock;
- import org.easymock.IAnswer;
- import org.junit.After;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Ignore;
- import org.junit.Test;
- import org.springframework.security.core.Authentication;
- import org.springframework.security.core.context.SecurityContextHolder;
-
- import com.google.gson.JsonArray;
- import com.google.gson.JsonObject;
- import com.google.gson.JsonParser;
- import com.google.inject.AbstractModule;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- import com.google.inject.util.Modules;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.lang.reflect.Field;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.ambari.annotations.Experimental;
+import org.apache.ambari.annotations.ExperimentalFeature;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.H2DatabaseCleaner;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.Stage;
+import org.apache.ambari.server.actionmanager.StageFactory;
+import org.apache.ambari.server.agent.CommandReport;
+import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
+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.ExecuteActionRequest;
+import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.ResourceProviderFactory;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
+import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
+import org.apache.ambari.server.orm.dao.HostVersionDAO;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
+import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
+import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
+import org.apache.ambari.server.orm.entities.HostVersionEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.orm.entities.ResourceEntity;
+import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
+import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.orm.entities.UpgradeEntity;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
+import org.apache.ambari.server.security.authorization.ResourceType;
+import org.apache.ambari.server.serveraction.upgrades.FinalizeUpgradeAction;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.ServiceOsSpecific;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.cluster.ClusterImpl;
+import org.apache.ambari.server.state.stack.upgrade.Direction;
+import org.apache.ambari.server.topology.TopologyManager;
+import org.apache.ambari.server.utils.StageUtils;
+import org.apache.commons.io.IOUtils;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.util.Modules;
/**
@@ -222,7 +222,7 @@ public class ClusterStackVersionResourceProviderTest {
repoVersion.setId(1l);
repoVersion.setOperatingSystems(OS_JSON);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
int hostCount = 10;
for (int i = 0; i < hostCount; i++) {
String hostname = "host" + i;
@@ -271,7 +271,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -363,9 +363,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -413,7 +413,7 @@ public class ClusterStackVersionResourceProviderTest {
ambariMetaInfo.getComponent("HDP", "2.1.1", "HBASE", "HBASE_MASTER").setVersionAdvertised(true);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
int hostCount = 10;
for (int i = 0; i < hostCount; i++) {
String hostname = "host" + i;
@@ -491,7 +491,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -585,9 +585,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -646,7 +646,7 @@ public class ClusterStackVersionResourceProviderTest {
ambariMetaInfo.getComponent("HDP", "2.1.1", "HBASE", "HBASE_MASTER").setVersionAdvertised(true);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
int hostCount = 10;
for (int i = 0; i < hostCount; i++) {
String hostname = "host" + i;
@@ -708,7 +708,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -806,9 +806,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -877,7 +877,7 @@ public class ClusterStackVersionResourceProviderTest {
ambariMetaInfo.getComponent("HDP", "2.1.1", "HBASE", "HBASE_MASTER").setVersionAdvertised(true);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
int hostCount = 10;
for (int i = 0; i < hostCount; i++) {
String hostname = "host" + i;
@@ -939,7 +939,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -1038,9 +1038,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -1152,7 +1152,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -1169,7 +1169,7 @@ public class ClusterStackVersionResourceProviderTest {
expect(cluster.getCurrentStackVersion()).andReturn(stackId);
expect(cluster.getServiceComponentHosts(anyObject(String.class))).andReturn(schs).anyTimes();
- Capture<StackId> capturedStackId = new Capture<StackId>();
+ Capture<StackId> capturedStackId = new Capture<>();
cluster.setDesiredStackVersion(capture(capturedStackId));
expectLastCall().once();
expect(cluster.getHosts()).andReturn(hosts).anyTimes();
@@ -1206,7 +1206,7 @@ public class ClusterStackVersionResourceProviderTest {
field.set(provider, finalizeUpgradeAction);
// add the property map to a set for the request. add more maps for multiple creates
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, clusterName);
@@ -1305,7 +1305,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -1327,7 +1327,7 @@ public class ClusterStackVersionResourceProviderTest {
ClusterVersionEntity current = new ClusterVersionEntity();
current.setRepositoryVersion(currentRepo);
- Capture<StackId> capturedStackId = new Capture<StackId>();
+ Capture<StackId> capturedStackId = new Capture<>();
cluster.setDesiredStackVersion(capture(capturedStackId));
expectLastCall().once();
expect(cluster.getHosts()).andReturn(hosts).anyTimes();
@@ -1362,7 +1362,7 @@ public class ClusterStackVersionResourceProviderTest {
// add the property map to a set for the request. add more maps for multiple creates
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, clusterName);
@@ -1424,7 +1424,7 @@ public class ClusterStackVersionResourceProviderTest {
repoVersion.setType(RepositoryType.STANDARD);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
int hostCount = 10;
for (int i = 0; i < hostCount; i++) {
String hostname = "host" + i;
@@ -1473,7 +1473,7 @@ public class ClusterStackVersionResourceProviderTest {
AbstractControllerResourceProvider.init(resourceProviderFactory);
- Map<String, Map<String, String>> hostConfigTags = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> hostConfigTags = new HashMap<>();
expect(configHelper.getEffectiveDesiredTags(anyObject(ClusterImpl.class), anyObject(String.class))).andReturn(hostConfigTags);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -1570,9 +1570,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -1636,7 +1636,7 @@ public class ClusterStackVersionResourceProviderTest {
repoVersionEntity.setVersionXsd("version_definition.xsd");
repoVersionEntity.setType(RepositoryType.STANDARD);
- Map<String, Host> hostsForCluster = new HashMap<String, Host>();
+ Map<String, Host> hostsForCluster = new HashMap<>();
List<HostVersionEntity> hostVersionEntitiesMergedWithNotRequired = new ArrayList<>();
int hostCount = 10;
@@ -1714,8 +1714,8 @@ public class ClusterStackVersionResourceProviderTest {
expect(cluster.getClusterName()).andReturn(clusterName).atLeastOnce();
expect(cluster.getHosts()).andReturn(hostsForCluster.values()).atLeastOnce();
expect(cluster.getServices()).andReturn(serviceMap).anyTimes();
- expect(cluster.getServiceComponentHosts(anyObject(String.class))).andReturn(
- serviceComponentHosts).anyTimes();
+ expect(cluster.getServiceComponentHosts(anyObject(String.class))).andReturn(serviceComponentHosts).anyTimes();
+ expect(cluster.getCurrentStackVersion()).andReturn(stackId).atLeastOnce();
expect(repositoryVersionDAOMock.findByStackAndVersion(anyObject(StackId.class),
anyObject(String.class))).andReturn(repoVersionEntity);
@@ -1757,9 +1757,9 @@ public class ClusterStackVersionResourceProviderTest {
// add the property map to a set for the request. add more maps for multiple
// creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(
@@ -1826,9 +1826,9 @@ public class ClusterStackVersionResourceProviderTest {
injector.injectMembers(provider);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+ Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ Map<String, Object> properties = new LinkedHashMap<>();
// add properties to the request map
properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
http://git-wip-us.apache.org/repos/asf/ambari/blob/6a3bfd5d/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
index 53bd405..6e47b02 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
@@ -18,6 +18,27 @@
package org.apache.ambari.server.topology;
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
import org.apache.ambari.server.controller.AmbariManagementController;
@@ -28,20 +49,11 @@ import org.apache.ambari.server.controller.internal.Stack;
import org.apache.ambari.server.serveraction.kerberos.KerberosInvalidConfigurationException;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.Maps;
-import org.easymock.EasyMock;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.StackId;
import org.easymock.Capture;
import org.easymock.CaptureType;
+import org.easymock.EasyMock;
import org.easymock.EasyMockRule;
import org.easymock.Mock;
import org.easymock.MockType;
@@ -52,18 +64,7 @@ import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.easymock.EasyMock.capture;
-import static org.junit.Assert.assertEquals;
+import com.google.common.collect.Maps;
/**
* ClusterConfigurationRequest unit tests
@@ -103,6 +104,13 @@ public class ClusterConfigurationRequestTest {
@Mock(type = MockType.NICE)
private KerberosHelper kerberosHelper;
+ @Mock(type = MockType.NICE)
+ private ConfigHelper configHelper;
+
+ private final String STACK_NAME = "testStack";
+ private final String STACK_VERSION = "1";
+ private final Map<String, Map<String, String>> stackProperties = new HashMap<>();
+
/**
* testConfigType config type should be in updatedConfigTypes, as no custom property in Blueprint
* ==> Kerberos config property should be updated
@@ -198,7 +206,7 @@ public class ClusterConfigurationRequestTest {
ConfigurationTopologyException {
- Map<String, Map<String, String>> existingConfig = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> existingConfig = new HashMap<>();
Configuration stackDefaultConfig = new Configuration(existingConfig,
new HashMap<String, Map<String, Map<String, String>>>());
if (stackPropertyValue != null) {
@@ -221,6 +229,8 @@ public class ClusterConfigurationRequestTest {
expect(clusters.getCluster("testCluster")).andReturn(cluster).anyTimes();
expect(blueprint.getStack()).andReturn(stack).anyTimes();
+ expect(stack.getName()).andReturn(STACK_NAME).anyTimes();
+ expect(stack.getVersion()).andReturn(STACK_VERSION).anyTimes();
expect(stack.getServiceForConfigType("testConfigType")).andReturn("KERBEROS").anyTimes();
expect(stack.getAllConfigurationTypes(anyString())).andReturn(Collections.<String>singletonList("testConfigType")
).anyTimes();
@@ -246,6 +256,7 @@ public class ClusterConfigurationRequestTest {
expect(blueprint.getComponents("KERBEROS")).andReturn(kerberosComponents).anyTimes();
expect(blueprint.getComponents("ZOOKEPER")).andReturn(zookeeperComponents).anyTimes();
+ expect(topology.getAmbariContext()).andReturn(ambariContext).anyTimes();
expect(topology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY).anyTimes();
expect(topology.getBlueprint()).andReturn(blueprint).anyTimes();
expect(blueprint.isValidConfigType("testConfigType")).andReturn(true).anyTimes();
@@ -256,10 +267,14 @@ public class ClusterConfigurationRequestTest {
expect(topology.getHostGroupsForComponent(anyString())).andReturn(Collections.<String>emptyList())
.anyTimes();
- expect(ambariContext.getClusterName(Long.valueOf(1))).andReturn("testCluster").anyTimes();
+ expect(ambariContext.getConfigHelper()).andReturn(configHelper).anyTimes();
+ expect(ambariContext.getClusterName(Long.valueOf(1))).andReturn("testCluster").anyTimes();
expect(ambariContext.createConfigurationRequests(anyObject(Map.class))).andReturn(Collections
.<ConfigurationRequest>emptyList()).anyTimes();
+ expect(configHelper.getDefaultStackProperties(
+ EasyMock.eq(new StackId(STACK_NAME, STACK_VERSION)))).andReturn(stackProperties).anyTimes();
+
if (kerberosConfig == null) {
kerberosConfig = new HashMap<>();
Map<String, String> properties = new HashMap<>();
@@ -277,15 +292,14 @@ public class ClusterConfigurationRequestTest {
(captureUpdatedConfigTypes));
expectLastCall();
- PowerMock.replay(stack, blueprint, topology, controller, clusters, kerberosHelper, ambariContext,
- AmbariContext
- .class);
+ PowerMock.replay(stack, blueprint, topology, controller, clusters, kerberosHelper,
+ ambariContext, AmbariContext.class, configHelper);
ClusterConfigurationRequest clusterConfigurationRequest = new ClusterConfigurationRequest(
ambariContext, topology, false, stackAdvisorBlueprintProcessor, true);
clusterConfigurationRequest.process();
- verify(blueprint, topology, ambariContext, controller, kerberosHelper);
+ verify(blueprint, topology, ambariContext, controller, kerberosHelper, configHelper);
String clusterName = captureClusterName.getValue();
@@ -296,7 +310,7 @@ public class ClusterConfigurationRequestTest {
@Test
public void testProcessClusterConfigRequestDontIncludeKererosConfigs() throws Exception {
- Map<String, Map<String, String>> existingConfig = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> existingConfig = new HashMap<>();
Configuration stackConfig = new Configuration(existingConfig,
new HashMap<String, Map<String, Map<String, String>>>());
@@ -308,8 +322,9 @@ public class ClusterConfigurationRequestTest {
expect(clusters.getCluster("testCluster")).andReturn(cluster).anyTimes();
expect(blueprint.getStack()).andReturn(stack).anyTimes();
- expect(stack.getAllConfigurationTypes(anyString())).andReturn(Collections.<String>singletonList("testConfigType")
- ).anyTimes();
+ expect(stack.getName()).andReturn(STACK_NAME).anyTimes();
+ expect(stack.getVersion()).andReturn(STACK_VERSION).anyTimes();
+ expect(stack.getAllConfigurationTypes(anyString())).andReturn(Collections.<String>singletonList("testConfigType")).anyTimes();
expect(stack.getExcludedConfigurationTypes(anyString())).andReturn(Collections.<String>emptySet()).anyTimes();
expect(stack.getConfigurationPropertiesWithMetadata(anyString(), anyString())).andReturn(Collections.<String,
Stack.ConfigProperty>emptyMap()).anyTimes();
@@ -331,25 +346,29 @@ public class ClusterConfigurationRequestTest {
expect(blueprint.getComponents("KERBEROS")).andReturn(kerberosComponents).anyTimes();
expect(blueprint.getComponents("ZOOKEPER")).andReturn(zookeeperComponents).anyTimes();
+ expect(topology.getAmbariContext()).andReturn(ambariContext).anyTimes();
expect(topology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY).anyTimes();
expect(topology.getBlueprint()).andReturn(blueprint).anyTimes();
expect(topology.getConfiguration()).andReturn(stackConfig).anyTimes();
expect(topology.getHostGroupInfo()).andReturn(Collections.<String, HostGroupInfo>emptyMap()).anyTimes();
expect(topology.getClusterId()).andReturn(Long.valueOf(1)).anyTimes();
+
+ expect(ambariContext.getConfigHelper()).andReturn(configHelper).anyTimes();
expect(ambariContext.getClusterName(Long.valueOf(1))).andReturn("testCluster").anyTimes();
expect(ambariContext.createConfigurationRequests(anyObject(Map.class))).andReturn(Collections
.<ConfigurationRequest>emptyList()).anyTimes();
+ expect(configHelper.getDefaultStackProperties(
+ EasyMock.eq(new StackId(STACK_NAME, STACK_VERSION)))).andReturn(stackProperties).anyTimes();
PowerMock.replay(stack, blueprint, topology, controller, clusters, ambariContext,
- AmbariContext
- .class);
+ AmbariContext.class, configHelper);
ClusterConfigurationRequest clusterConfigurationRequest = new ClusterConfigurationRequest(
ambariContext, topology, false, stackAdvisorBlueprintProcessor);
clusterConfigurationRequest.process();
- verify(blueprint, topology, ambariContext, controller);
+ verify(blueprint, topology, ambariContext, controller, configHelper);
}
@@ -357,7 +376,7 @@ public class ClusterConfigurationRequestTest {
public void testProcessClusterConfigRequestRemoveUnusedConfigTypes() throws Exception {
// GIVEN
Configuration configuration = createConfigurations();
- Set<String> services = new HashSet<String>();
+ Set<String> services = new HashSet<>();
services.add("HDFS");
services.add("RANGER");
Map<String, HostGroupInfo> hostGroupInfoMap = Maps.newHashMap();
@@ -365,6 +384,7 @@ public class ClusterConfigurationRequestTest {
hg1.setConfiguration(createConfigurationsForHostGroup());
hostGroupInfoMap.put("hg1", hg1);
+ expect(topology.getAmbariContext()).andReturn(ambariContext).anyTimes();
expect(topology.getConfiguration()).andReturn(configuration).anyTimes();
expect(topology.getBlueprint()).andReturn(blueprint).anyTimes();
expect(topology.getHostGroupInfo()).andReturn(hostGroupInfoMap);
@@ -377,7 +397,12 @@ public class ClusterConfigurationRequestTest {
expect(blueprint.isValidConfigType("cluster-env")).andReturn(true).anyTimes();
expect(blueprint.isValidConfigType("global")).andReturn(true).anyTimes();
- EasyMock.replay(stack, blueprint, topology);
+ expect(ambariContext.getConfigHelper()).andReturn(configHelper).anyTimes();
+
+ expect(configHelper.getDefaultStackProperties(
+ EasyMock.eq(new StackId(STACK_NAME, STACK_VERSION)))).andReturn(stackProperties).anyTimes();
+
+ EasyMock.replay(stack, blueprint, topology, ambariContext, configHelper);
// WHEN
new ClusterConfigurationRequest(ambariContext, topology, false, stackAdvisorBlueprintProcessor);
// THEN
@@ -388,7 +413,7 @@ public class ClusterConfigurationRequestTest {
assertFalse("SPARK service not present in topology host group config thus 'spark-env' config type should be removed from config.", hg1.getConfiguration().getFullAttributes().containsKey("spark-env"));
assertTrue("HDFS service is present in topology host group config thus 'hdfs-site' config type should be left in the config.", hg1.getConfiguration().getFullAttributes().containsKey("hdfs-site"));
- verify(stack, blueprint, topology);
+ verify(stack, blueprint, topology, ambariContext, configHelper);
}
@Test
@@ -409,6 +434,7 @@ public class ClusterConfigurationRequestTest {
hg1.setConfiguration(createConfigurationsForHostGroup());
hostGroupInfoMap.put("hg1", hg1);
+ expect(topology.getAmbariContext()).andReturn(ambariContext).anyTimes();
expect(topology.getConfiguration()).andReturn(configuration).anyTimes();
expect(topology.getBlueprint()).andReturn(blueprint).anyTimes();
expect(topology.getHostGroupInfo()).andReturn(hostGroupInfoMap);
@@ -419,7 +445,12 @@ public class ClusterConfigurationRequestTest {
expect(blueprint.isValidConfigType("cluster-env")).andReturn(true).anyTimes();
expect(blueprint.isValidConfigType("global")).andReturn(true).anyTimes();
- EasyMock.replay(stack, blueprint, topology);
+ expect(ambariContext.getConfigHelper()).andReturn(configHelper).anyTimes();
+
+ expect(configHelper.getDefaultStackProperties(
+ EasyMock.eq(new StackId(STACK_NAME, STACK_VERSION)))).andReturn(stackProperties).anyTimes();
+
+ EasyMock.replay(stack, blueprint, topology, ambariContext, configHelper);
// When
@@ -431,7 +462,7 @@ public class ClusterConfigurationRequestTest {
assertFalse("SPARK service not present in topology host group config thus 'spark-env' config type should be removed from config.", hg1.getConfiguration().getFullAttributes().containsKey("spark-env"));
assertTrue("HDFS service is present in topology host group config thus 'hdfs-site' config type should be left in the config.", hg1.getConfiguration().getFullAttributes().containsKey("hdfs-site"));
- verify(stack, blueprint, topology);
+ verify(stack, blueprint, topology, ambariContext, configHelper);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6a3bfd5d/ambari-server/src/test/python/common-services/configs/hawq_default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/common-services/configs/hawq_default.json b/ambari-server/src/test/python/common-services/configs/hawq_default.json
index 79864a9..1b6fafb 100644
--- a/ambari-server/src/test/python/common-services/configs/hawq_default.json
+++ b/ambari-server/src/test/python/common-services/configs/hawq_default.json
@@ -73,7 +73,11 @@
"cluster-env": {
"managed_hdfs_resource_property_names": "",
"security_enabled": "false",
- "user_group": "hadoop"
+ "user_group": "hadoop",
+ "stack_name": "PHD",
+ "stack_root": "{\"PHD\": \"/usr/phd\"}",
+ "stack_tools": "{\n \"PHD\": { \"stack_selector\": [\"phd-select\", \"/usr/bin/phd-select\", \"phd-select\"],\n \"conf_selector\": [\"conf-select\", \"/usr/bin/conf-select\", \"conf-select\"]\n}\n}",
+ "stack_features": "{\"PHD\":{\"stack_features\":[{\"name\":\"express_upgrade\",\"description\":\"Express upgrade support\",\"min_version\":\"3.0.0.0\"},{\"name\":\"rolling_upgrade\",\"description\":\"Rolling upgrade support\",\"min_version\":\"3.0.0.0\"},{\"name\":\"config_versioning\",\"description\":\"Configurable versions support\",\"min_version\":\"3.0.0.0\"}]\n}\n}"
}
},
"clusterHostInfo": {
http://git-wip-us.apache.org/repos/asf/ambari/blob/6a3bfd5d/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
index 0d47061..e6cce98 100644
--- a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
+++ b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
@@ -41,7 +41,11 @@ class TestAlertDiskSpace(RMFTestCase):
total = 21673930752L, used = 5695861760L,
free = 15978068992L, path="/")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ configurations = {'{{cluster-env/stack_name}}': 'HDP',
+ '{{cluster-env/stack_root}}': '{"HDP":"/usr/hdp"}'}
+
+ res = alert_disk_space.execute(configurations=configurations)
+
self.assertEqual(res,
('OK', ['Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB], path=/']))
@@ -50,7 +54,7 @@ class TestAlertDiskSpace(RMFTestCase):
total = 21673930752L, used = 14521533603L,
free = 7152397149L, path="/")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ res = alert_disk_space.execute(configurations = configurations)
self.assertEqual(res, (
'WARNING',
['Capacity Used: [67.00%, 14.5 GB], Capacity Total: [21.7 GB], path=/']))
@@ -60,7 +64,7 @@ class TestAlertDiskSpace(RMFTestCase):
total = 21673930752L, used = 20590234214L,
free = 1083696538, path="/")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ res = alert_disk_space.execute(configurations = configurations)
self.assertEqual(res, ('CRITICAL',
['Capacity Used: [95.00%, 20.6 GB], Capacity Total: [21.7 GB], path=/']))
@@ -69,7 +73,7 @@ class TestAlertDiskSpace(RMFTestCase):
total = 5418482688L, used = 1625544806L,
free = 3792937882L, path="/")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ res = alert_disk_space.execute(configurations = configurations)
self.assertEqual(res, ('WARNING', [
'Capacity Used: [30.00%, 1.6 GB], Capacity Total: [5.4 GB], path=/. Total free space is less than 5.0 GB']))
@@ -81,7 +85,7 @@ class TestAlertDiskSpace(RMFTestCase):
total = 21673930752L, used = 5695861760L,
free = 15978068992L, path="/usr/hdp")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ res = alert_disk_space.execute(configurations = configurations)
self.assertEqual(res,
('OK', ['Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB], path=/usr/hdp']))
@@ -90,6 +94,6 @@ class TestAlertDiskSpace(RMFTestCase):
total = 5418482688L, used = 1625544806L,
free = 3792937882L, path="/usr/hdp")
- res = alert_disk_space.execute(configurations={'{{cluster-env/stack_root}}': '/usr/hdp'})
+ res = alert_disk_space.execute(configurations = configurations)
self.assertEqual(res, (
'WARNING', ["Capacity Used: [30.00%, 1.6 GB], Capacity Total: [5.4 GB], path=/usr/hdp. Total free space is less than 5.0 GB"]))