Author: ncole
Date: Mon May 20 16:50:04 2013
New Revision: 1484522
URL: http://svn.apache.org/r1484522
Log:
AMBARI-2147. Added config change auditing
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/conf/unix/log4j.properties
incubator/ambari/trunk/ambari-server/src/main/conf/log4j.properties
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAOTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AuthorizationHelperTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon May 20 16:50:04 2013
@@ -315,6 +315,8 @@ Trunk (unreleased changes):
AMBARI-2111. Enable customization of smoke test user. (yusaku)
+ AMBARI-2147. Added config change auditing. (ncole)
+
AMBARI-2110. Update hive-site.xml, set fs.file.impl.disable.cache=true.
(mahadev)
Modified: incubator/ambari/trunk/ambari-server/conf/unix/log4j.properties
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/conf/unix/log4j.properties?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/conf/unix/log4j.properties (original)
+++ incubator/ambari/trunk/ambari-server/conf/unix/log4j.properties Mon May 20
16:50:04 2013
@@ -27,3 +27,11 @@ log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=20
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+# Log config changes
+log4j.logger.configchange=INFO,configchange
+log4j.additivity.configchange=false
+log4j.appender.configchange=org.apache.log4j.FileAppender
+log4j.appender.configchange.File=/var/log/ambari-server/ambari-config-changes.log
+log4j.appender.configchange.layout=org.apache.log4j.PatternLayout
+log4j.appender.configchange.layout.ConversionPattern=%d{ISO8601} %5p - %m%n
Modified: incubator/ambari/trunk/ambari-server/src/main/conf/log4j.properties
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/conf/log4j.properties?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/conf/log4j.properties
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/conf/log4j.properties Mon May
20 16:50:04 2013
@@ -20,6 +20,7 @@
ambari.root.logger=INFO,DRFA
ambari.log.dir=/var/log/ambari-server
ambari.log.file=ambari.log
+ambari.config-changes.file=ambari-config-changes.log
# Define the root logger to the system property "ambari.root.logger".
@@ -57,3 +58,11 @@ log4j.appender.console=org.apache.log4j.
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p
%c{2}: %m%n
+
+# Log config changes
+log4j.logger.configchange=INFO,configchange
+log4j.additivity.configchange=false
+log4j.appender.configchange=org.apache.log4j.FileAppender
+log4j.appender.configchange.File=${ambari.log.dir}/${ambari.config-changes.file}
+log4j.appender.configchange.layout=org.apache.log4j.PatternLayout
+log4j.appender.configchange.layout.ConversionPattern=%d{ISO8601} %5p - %m%n
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
Mon May 20 16:50:04 2013
@@ -143,7 +143,7 @@ public class Configuration {
public static final String OS_VERSION_KEY =
"server.os_type";
- public static final String SRVR_HOSTS_MAPPING =
+ public static final String SRVR_HOSTS_MAPPING =
"server.hosts.mapping";
// Command parameter names
@@ -164,6 +164,8 @@ public class Configuration {
private static final String RESOURCES_DIR_DEFAULT =
"/var/share/ambari/resources/";
+ private static final String ANONYMOUS_AUDIT_NAME_KEY =
"anonymous.audit.name";
+
private static final String CLIENT_SECURITY_DEFAULT = "local";
private static final int CLIENT_API_PORT_DEFAULT = 8080;
@@ -530,4 +532,12 @@ public class Configuration {
return Integer.parseInt(properties.getProperty
(SERVER_CONNECTION_MAX_IDLE_TIME, String.valueOf("900000")));
}
+
+ /**
+ * @return the name to be used for audit information if there is no
+ * logged-in user. Default is '_anonymous'.
+ */
+ public String getAnonymousAuditName() {
+ return properties.getProperty(ANONYMOUS_AUDIT_NAME_KEY, "_anonymous");
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
Mon May 20 16:50:04 2013
@@ -31,7 +31,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
-import com.google.inject.persist.Transactional;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ClusterNotFoundException;
import org.apache.ambari.server.DuplicateResourceException;
@@ -55,6 +54,7 @@ import org.apache.ambari.server.api.serv
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.metadata.ActionMetadata;
import org.apache.ambari.server.metadata.RoleCommandOrder;
+import org.apache.ambari.server.security.authorization.AuthorizationHelper;
import org.apache.ambari.server.security.authorization.User;
import org.apache.ambari.server.security.authorization.Users;
import org.apache.ambari.server.serveraction.ServerAction;
@@ -98,6 +98,7 @@ import com.google.gson.Gson;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
@Singleton
public class AmbariManagementControllerImpl implements
@@ -988,7 +989,7 @@ public class AmbariManagementControllerI
+ ", clusterId=" + request.getClusterId()
+ ", stackInfo=" + request.getStackVersion());
}
-
+
if (request.getClusterName() != null) {
Cluster c = clusters.getCluster(request.getClusterName());
ClusterResponse cr = c.convertToResponse();
@@ -1422,7 +1423,14 @@ public class AmbariManagementControllerI
Config baseConfig = cluster.getConfig(cr.getType(), cr.getVersionTag());
if (null != baseConfig) {
- cluster.addDesiredConfig(baseConfig);
+ String authName = getAuthName();
+ if (cluster.addDesiredConfig(authName, baseConfig)) {
+ Logger logger = LoggerFactory.getLogger("configchange");
+ logger.info("cluster '" + request.getClusterName() + "' "
+ + "changed by: '" + authName + "'; "
+ + "type='" + baseConfig.getType() + "' "
+ + "tag='" + baseConfig.getVersionTag() + "'");
+ }
}
}
@@ -2990,9 +2998,18 @@ public class AmbariManagementControllerI
}
Config baseConfig = c.getConfig(cr.getType(), cr.getVersionTag());
- if (null != baseConfig)
- h.addDesiredConfig(c.getClusterId(), cr.isSelected(), baseConfig);
-
+ if (null != baseConfig) {
+ String authName = getAuthName();
+ if (h.addDesiredConfig(c.getClusterId(), cr.isSelected(),
authName, baseConfig)) {
+ Logger logger = LoggerFactory.getLogger("configchange");
+ logger.info("cluster '" + c.getClusterName() + "', "
+ + "host '" + h.getHostName() + "' "
+ + "changed by: '" + authName + "'; "
+ + "type='" + baseConfig.getType() + "' "
+ + "tag='" + baseConfig.getVersionTag() + "'");
+ }
+ }
+
}
}
@@ -4438,4 +4455,11 @@ public class AmbariManagementControllerI
return response;
}
+
+ /**
+ * @return the authenticated user's name
+ */
+ private String getAuthName() {
+ return
AuthorizationHelper.getAuthenticatedName(configs.getAnonymousAuditName());
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
Mon May 20 16:50:04 2013
@@ -50,6 +50,9 @@ public class ClusterConfigMappingEntity
@Column(name = "selected", insertable = true, updatable = true, nullable =
false)
private int selectedInd = 0;
+
+ @Column(name = "user_name", insertable = true, updatable = true, nullable =
false)
+ private String user;
@ManyToOne
@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id",
nullable = false)
@@ -76,7 +79,7 @@ public class ClusterConfigMappingEntity
public void setCreateTimestamp(Long timestamp) {
createTimestamp = timestamp;
- }
+ }
public String getVersion() {
return versionTag;
@@ -94,6 +97,20 @@ public class ClusterConfigMappingEntity
selectedInd = selected;
}
+ /**
+ * @return the user
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * @param userName the user
+ */
+ public void setUser(String userName) {
+ user = userName;
+ }
+
public ClusterEntity getClusterEntity() {
return clusterEntity;
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
Mon May 20 16:50:04 2013
@@ -55,6 +55,9 @@ public class HostConfigMappingEntity {
@Column(name = "selected", insertable = true, updatable = true, nullable =
false)
private int selected = 0;
+
+ @Column(name = "user_name", insertable = true, updatable = true, nullable =
false)
+ private String user = null;
public Long getClusterId() {
return clusterId;
@@ -111,5 +114,19 @@ public class HostConfigMappingEntity {
public void setServiceName(String name) {
serviceName = name;
}
+
+ /**
+ * @return the user
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * @param userName the user
+ */
+ public void setUser(String userName) {
+ user = userName;
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
Mon May 20 16:50:04 2013
@@ -19,8 +19,11 @@ package org.apache.ambari.server.securit
import com.google.inject.Singleton;
import org.apache.ambari.server.orm.entities.RoleEntity;
+import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.Collection;
@@ -44,4 +47,26 @@ public class AuthorizationHelper {
return authorities;
}
+
+ /**
+ * Gets the name of the logged in user. Thread-safe due to use of
thread-local.
+ * @return the name of the logged in user, or <code>null</code> if none set.
+ */
+ public static String getAuthenticatedName() {
+ return getAuthenticatedName(null);
+ }
+
+ /**
+ * Gets the name of the logged-in user, if any. Thread-safe due to use of
+ * thread-local.
+ * @param defaultUsername the value if there is no logged-in user
+ * @return the name of the logged-in user, or the default
+ */
+ public static String getAuthenticatedName(String defaultUsername) {
+ SecurityContext securityContext = SecurityContextHolder.getContext();
+
+ Authentication auth = securityContext.getAuthentication();
+
+ return (null == auth) ? defaultUsername : auth.getName();
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
Mon May 20 16:50:04 2013
@@ -126,9 +126,12 @@ public interface Cluster {
/**
* Adds and sets a DESIRED configuration to be applied to a cluster. There
* can be only one selected config per type.
+ * @param user the user making the change for audit purposes
* @param config the {@link Config} object to set as desired
+ * @return <code>true</code> if the config was added, or <code>false</code>
+ * if the config is already set as the current
*/
- public void addDesiredConfig(Config config);
+ public boolean addDesiredConfig(String user, Config config);
/**
* Gets the desired (and selected) config by type.
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
Mon May 20 16:50:04 2013
@@ -32,6 +32,7 @@ public class DesiredConfig {
private String versionTag;
private String serviceName;
+ private String user;
private List<HostOverride> hostOverrides = new ArrayList<HostOverride>();
/**
@@ -68,7 +69,7 @@ public class DesiredConfig {
public void setServiceName(String name) {
serviceName = name;
}
-
+
/**
* Sets the host overrides for the desired config. Cluster-based desired
configs only.
* @param overrides the host names
@@ -78,6 +79,22 @@ public class DesiredConfig {
}
/**
+ * Gets the user that set the desired config.
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * Sets the user that set the desired config.
+ * @param userName the username
+ */
+ public void setUser(String userName) {
+ user = userName;
+ }
+
+
+ /**
* Gets the host overrides for the desired config. Cluster-based desired
configs only.
* @return the host names that override the desired config
*/
@@ -86,7 +103,7 @@ public class DesiredConfig {
public List<HostOverride> getHostOverrides() {
return hostOverrides;
}
-
+
/**
* Used to represent an override on a host.
*/
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
Mon May 20 16:50:04 2013
@@ -45,7 +45,7 @@ public interface Host {
public void setPublicHostName(String hostName);
/**
- * Sets the public-facing host name.
+ * Sets the public-facing host name.
*/
public String getPublicHostName();
@@ -83,12 +83,12 @@ public interface Host {
/**
* @return the physical cpu cores
- */
+ */
public int getPhCpuCount();
/**
* @param phCpuCount the physical cpu cores to set
- */
+ */
public void setPhCpuCount(int phCpuCount);
/**
@@ -287,9 +287,12 @@ public interface Host {
* @param clusterId the cluster id that the config applies to
* @param selected <code>true</code> if the configuration is selected.
Applies
* only to remove the override, otherwise this value should always be
<code>true</code>.
+ * @param user the user making the change for audit purposes
* @param config the configuration object
+ * @return <code>true</code> if the config was added, or <code>false</code>
+ * if the config is already set as the current
*/
- public void addDesiredConfig(long clusterId, boolean selected, Config
config);
+ public boolean addDesiredConfig(long clusterId, boolean selected, String
user, Config config);
/**
* Gets all the selected configurations for the host.
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
Mon May 20 16:50:04 2013
@@ -19,7 +19,6 @@
package org.apache.ambari.server.state.cluster;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -53,7 +52,6 @@ import org.apache.ambari.server.state.Cl
import org.apache.ambari.server.state.Config;
import org.apache.ambari.server.state.ConfigFactory;
import org.apache.ambari.server.state.DesiredConfig;
-import org.apache.ambari.server.state.DesiredConfig.HostOverride;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
@@ -797,13 +795,16 @@ public class ClusterImpl implements Clus
}
@Override
- public void addDesiredConfig(Config config) {
-
+ @Transactional
+ public boolean addDesiredConfig(String user, Config config) {
+ if (null == user)
+ throw new NullPointerException("User must be specified.");
+
Config currentDesired = getDesiredConfigByType(config.getType());
// do not set if it is already the current
if (null != currentDesired &&
currentDesired.getVersionTag().equals(config.getVersionTag())) {
- return;
+ return false;
}
Collection<ClusterConfigMappingEntity> entities =
clusterEntity.getConfigMappingEntities();
@@ -817,16 +818,16 @@ public class ClusterImpl implements Clus
ClusterConfigMappingEntity entity = new ClusterConfigMappingEntity();
entity.setClusterEntity(clusterEntity);
entity.setClusterId(clusterEntity.getClusterId());
- entity.setCreateTimestamp(Long.valueOf (new java.util.Date().getTime()));
+ entity.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
entity.setSelected(1);
+ entity.setUser(user);
entity.setType(config.getType());
entity.setVersion(config.getVersionTag());
entities.add(entity);
- clusterEntity.setConfigMappingEntities(entities);
-
clusterDAO.merge(clusterEntity);
-
+
+ return true;
}
@Override
@@ -839,6 +840,7 @@ public class ClusterImpl implements Clus
DesiredConfig c = new DesiredConfig();
c.setServiceName(null);
c.setVersion(e.getVersion());
+ c.setUser(e.getUser());
List<HostConfigMappingEntity> hostMappings =
hostConfigMappingDAO.findSelectedHostsByType(clusterEntity.getClusterId().longValue(),
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
Mon May 20 16:50:04 2013
@@ -20,7 +20,6 @@
package org.apache.ambari.server.state.host;
import java.lang.reflect.Type;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -44,8 +43,8 @@ import org.apache.ambari.server.orm.enti
import org.apache.ambari.server.state.AgentVersion;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
-import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostEvent;
import org.apache.ambari.server.state.HostEventType;
import org.apache.ambari.server.state.HostHealthStatus;
@@ -1062,7 +1061,9 @@ public class HostImpl implements Host {
@Override
@Transactional
- public void addDesiredConfig(long clusterId, boolean selected, Config
config) {
+ public boolean addDesiredConfig(long clusterId, boolean selected, String
user, Config config) {
+ if (null == user)
+ throw new NullPointerException("User must be specified.");
HostConfigMappingEntity exist = getDesiredConfigEntity(clusterId,
config.getType());
if (null != exist && exist.getVersion().equals(config.getVersionTag())) {
@@ -1070,10 +1071,10 @@ public class HostImpl implements Host {
exist.setSelected(0);
hostConfigMappingDAO.merge(exist);
}
- return;
+ return false;
}
- writeLock.lock();
+ writeLock.lock();
try {
// set all old mappings for this type to empty
@@ -1085,9 +1086,10 @@ public class HostImpl implements Host {
HostConfigMappingEntity entity = new HostConfigMappingEntity();
entity.setClusterId(Long.valueOf(clusterId));
- entity.setCreateTimestamp(Long.valueOf(new Date().getTime()));
+ entity.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
entity.setHostName(hostEntity.getHostName());
entity.setSelected(1);
+ entity.setUser(user);
entity.setType(config.getType());
entity.setVersion(config.getVersionTag());
@@ -1098,6 +1100,8 @@ public class HostImpl implements Host {
}
hostDAO.merge(hostEntity);
+
+ return true;
}
@Override
@@ -1110,7 +1114,7 @@ public class HostImpl implements Host {
DesiredConfig dc = new DesiredConfig();
dc.setVersion(e.getVersion());
dc.setServiceName(e.getServiceName());
-
+ dc.setUser(e.getUser());
map.put(e.getType(), dc);
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
Mon May 20 16:50:04 2013
@@ -34,7 +34,7 @@ CREATE TABLE ambari.clusterconfig (versi
GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfig TO :username;
-CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL,
type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL,
create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY
KEY (cluster_id, type_name, create_timestamp));
+CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL,
type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL,
create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id,
type_name, create_timestamp));
GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
@@ -114,7 +114,7 @@ GRANT ALL PRIVILEGES ON TABLE ambari.use
CREATE TABLE ambari.key_value_store ("key" VARCHAR(255), "value" VARCHAR,
PRIMARY KEY("key"));
GRANT ALL PRIVILEGES ON TABLE ambari.key_value_store TO :username;
-CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag
VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT
NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (cluster_id, host_name,
type_name, create_timestamp));
+CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag
VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT
NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL
DEFAULT '_db', PRIMARY KEY (cluster_id, host_name, type_name,
create_timestamp));
GRANT ALL PRIVILEGES ON TABLE ambari.hostconfigmapping TO :username;
Modified:
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
Mon May 20 16:50:04 2013
@@ -29,7 +29,7 @@ ALTER TABLE ambari.clusterstate
CREATE TABLE ambari.metainfo ("metainfo_key" VARCHAR(255), "metainfo_value"
VARCHAR, PRIMARY KEY("metainfo_key"));
GRANT ALL PRIVILEGES ON TABLE ambari.metainfo TO :username;
-CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL,
type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL,
create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY
KEY (cluster_id, type_name, create_timestamp));
+CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL,
type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL,
create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id,
type_name, create_timestamp));
GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
ALTER TABLE ambari.clusterconfigmapping ADD CONSTRAINT
FK_clusterconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES
ambari.clusters (cluster_id);
INSERT INTO ambari.clusterconfigmapping(cluster_id, type_name, version_tag,
create_timestamp, selected)
@@ -38,7 +38,7 @@ INSERT INTO ambari.clusterconfigmapping(
WHERE timestamp = (SELECT max(timestamp) FROM ambari.serviceconfigmapping
WHERE cluster_id = scm.cluster_id AND config_type = scm.config_type));
DELETE FROM ambari.serviceconfigmapping;
-CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag
VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT
NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (cluster_id, host_name,
type_name, create_timestamp));
+CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag
VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT
NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL
DEFAULT '_db', PRIMARY KEY (cluster_id, host_name, type_name,
create_timestamp));
GRANT ALL PRIVILEGES ON TABLE ambari.hostconfigmapping TO :username;
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT
FK_hostconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES
ambari.clusters (cluster_id);
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT
FK_hostconfigmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts
(host_name);
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
Mon May 20 16:50:04 2013
@@ -113,7 +113,7 @@ public class TestHeartbeatMonitor {
new HashMap<String,String>() {{ put("a", "b"); }});
config.setVersionTag("version1");
cluster.addConfig(config);
- cluster.addDesiredConfig(config);
+ cluster.addDesiredConfig("_test", config);
clusters.mapHostsToCluster(hostNames, clusterName);
@@ -191,7 +191,7 @@ public class TestHeartbeatMonitor {
}});
config.setVersionTag("version1");
cluster.addConfig(config);
- cluster.addDesiredConfig(config);
+ cluster.addDesiredConfig("_test", config);
clusters.mapHostsToCluster(hostNames, clusterName);
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
Mon May 20 16:50:04 2013
@@ -3454,8 +3454,8 @@ public class AmbariManagementControllerT
cluster.addConfig(config1);
cluster.addConfig(config2);
- cluster.addDesiredConfig(config1);
- cluster.addDesiredConfig(config2);
+ cluster.addDesiredConfig("_test", config1);
+ cluster.addDesiredConfig("_test", config2);
Service hdfs = cluster.addService("HDFS");
Service mapReduce = cluster.addService("MAPREDUCE");
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAOTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAOTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAOTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAOTest.java
Mon May 20 16:50:04 2013
@@ -58,11 +58,12 @@ public class HostConfigMappingDAOTest {
private HostConfigMappingEntity createEntity(long clusterId, String host,
String type, String version) throws Exception {
HostConfigMappingEntity entity = new HostConfigMappingEntity();
entity.setClusterId(Long.valueOf(clusterId));
- entity.setCreateTimestamp(Long.valueOf(new Date().getTime()));
+ entity.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
entity.setHostName(host);
entity.setSelected(1);
entity.setType(type);
entity.setVersion(version);
+ entity.setUser("_test");
hostConfigMappingDAO.create(entity);
@@ -105,7 +106,7 @@ public class HostConfigMappingDAOTest {
Assert.assertEquals("Expected one result", 1, target.size());
Assert.assertEquals("Expected version 'v1'", source.getVersion(),
target.get(0).getVersion());
- Assert.assertEquals("Expected selected flag 0", 0,
target.get(0).isSelected());
+ Assert.assertEquals("Expected selected flag 0", 0,
target.get(0).isSelected());
}
@Test
@@ -144,7 +145,7 @@ public class HostConfigMappingDAOTest {
target = hostConfigMappingDAO.findSelectedByType(1L, "h1", "global");
Assert.assertNotNull("Expected non-null entity for type 'global'", target);
- Assert.assertEquals("Expected version to be '" + entity2.getVersion() +
"'", entity2.getVersion(), target.getVersion());
+ Assert.assertEquals("Expected version to be '" + entity2.getVersion() +
"'", entity2.getVersion(), target.getVersion());
Assert.assertEquals("Expected instance equality", entity2, target);
}
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AuthorizationHelperTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AuthorizationHelperTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AuthorizationHelperTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AuthorizationHelperTest.java
Mon May 20 16:50:04 2013
@@ -17,15 +17,19 @@
*/
package org.apache.ambari.server.security.authorization;
-import org.apache.ambari.server.orm.entities.RoleEntity;
-import org.junit.Test;
-import org.springframework.security.core.GrantedAuthority;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
+import org.apache.ambari.server.orm.entities.RoleEntity;
+import org.junit.Assert;
+import org.junit.Test;
+import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
public class AuthorizationHelperTest {
@@ -46,4 +50,17 @@ public class AuthorizationHelperTest {
assertEquals("Wrong authority name", "ADMIN",
iterator.next().getAuthority());
}
+
+ @Test
+ public void testAuthName() throws Exception {
+ String user = AuthorizationHelper.getAuthenticatedName();
+ Assert.assertNull(user);
+
+ Authentication auth = new
UsernamePasswordAuthenticationToken("admin",null);
+ SecurityContextHolder.getContext().setAuthentication(auth);
+
+ user = AuthorizationHelper.getAuthenticatedName();
+ Assert.assertEquals("admin", user);
+
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
Mon May 20 16:50:04 2013
@@ -33,10 +33,12 @@ public class DesiredConfigTest {
DesiredConfig dc = new DesiredConfig();
dc.setServiceName("service");
dc.setVersion("global");
+ dc.setUser("_test");
Assert.assertEquals("Expected service 'service'", "service",
dc.getServiceName());
Assert.assertEquals("Expected version 'global'", "global",
dc.getVersion());
Assert.assertEquals("Expected no host overrides", 0,
dc.getHostOverrides().size());
+ Assert.assertEquals("Expected user '_test'", "_test", dc.getUser());
List<DesiredConfig.HostOverride> hosts = Arrays.asList(
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
Mon May 20 16:50:04 2013
@@ -310,14 +310,14 @@ public class ClusterTest {
c1.addConfig(config2);
c1.addConfig(config3);
- c1.addDesiredConfig(config1);
+ c1.addDesiredConfig("_test", config1);
Config res = c1.getDesiredConfigByType("global");
Assert.assertNotNull("Expected non-null config", res);
res = c1.getDesiredConfigByType("core-site");
Assert.assertNull("Expected null config", res);
- c1.addDesiredConfig(config2);
+ c1.addDesiredConfig("_test", config2);
res = c1.getDesiredConfigByType("global");
Assert.assertEquals("Expected version tag to be 'version2'", "version2",
res.getVersionTag());
@@ -341,8 +341,16 @@ public class ClusterTest {
c1.addConfig(config2);
c1.addConfig(config3);
- c1.addDesiredConfig(config1);
- c1.addDesiredConfig(config3);
+ try {
+ c1.addDesiredConfig(null, config1);
+ fail("Cannot set a null user with config");
+ }
+ catch (Exception e) {
+ // test failure
+ }
+
+ c1.addDesiredConfig("_test1", config1);
+ c1.addDesiredConfig("_test3", config3);
Map<String, DesiredConfig> desiredConfigs = c1.getDesiredConfigs();
Assert.assertFalse("Expect desired config not contain 'mapred-site'",
desiredConfigs.containsKey("mapred-site"));
@@ -350,13 +358,20 @@ public class ClusterTest {
Assert.assertTrue("Expect desired config contain " + config3.getType(),
desiredConfigs.containsKey("core-site"));
Assert.assertEquals("Expect desired config for global should be " +
config1.getVersionTag(),
config1.getVersionTag(),
desiredConfigs.get(config1.getType()).getVersion());
+ Assert.assertEquals("_test1",
desiredConfigs.get(config1.getType()).getUser());
+ Assert.assertEquals("_test3",
desiredConfigs.get(config3.getType()).getUser());
DesiredConfig dc = desiredConfigs.get(config1.getType());
Assert.assertTrue("Expect no host-level overrides",
(null == dc.getHostOverrides() || dc.getHostOverrides().size() == 0));
+
+ c1.addDesiredConfig("_test2", config2);
+ Assert.assertEquals("_test2",
c1.getDesiredConfigs().get(config2.getType()).getUser());
+
+ c1.addDesiredConfig("_test1", config1);
// setup a host that also has a config override
Host host = clusters.getHost("h1");
- host.addDesiredConfig(c1.getClusterId(), true, config2);
+ host.addDesiredConfig(c1.getClusterId(), true, "_test2", config2);
desiredConfigs = c1.getDesiredConfigs();
dc = desiredConfigs.get(config1.getType());
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
Mon May 20 16:50:04 2013
@@ -322,7 +322,7 @@ public class ClustersTest {
config2.persist();
// cluster desired config
- cluster.addDesiredConfig(config1);
+ cluster.addDesiredConfig("_test", config1);
clusters.addHost(h1);
clusters.addHost(h2);
@@ -341,7 +341,7 @@ public class ClustersTest {
}, c1);
// host config override
- host1.addDesiredConfig(cluster.getClusterId(), true, config2);
+ host1.addDesiredConfig(cluster.getClusterId(), true, "_test", config2);
host1.persist();
Service hdfs = cluster.addService("HDFS");
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java?rev=1484522&r1=1484521&r2=1484522&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
Mon May 20 16:50:04 2013
@@ -372,30 +372,40 @@ public class HostTest {
new HashMap<String,String>() {{ put("a", "b"); put("x", "y"); }});
try {
- host.addDesiredConfig(c1.getClusterId(), true, config);
+ host.addDesiredConfig(c1.getClusterId(), true, "_test", config);
Assert.fail("Expect failure when version is not specified.");
}
catch (Exception e) {
// testing exception
}
+
+ try {
+ host.addDesiredConfig(c1.getClusterId(), true, null, config);
+ Assert.fail("Expect failure when user is not specified.");
+ }
+ catch (Exception e) {
+ // testing exception
+ }
+
config.setVersionTag("v1");
- host.addDesiredConfig(c1.getClusterId(), true, config);
+ host.addDesiredConfig(c1.getClusterId(), true, "_test", config);
Map<String, DesiredConfig> map = host.getDesiredConfigs(c1.getClusterId());
Assert.assertTrue("Expect desired config to contain global",
map.containsKey("global"));
+ Assert.assertEquals("Expect global user to be '_test'", "_test",
map.get("global").getUser());
config = configFactory.createNew(c1, "global",
new HashMap<String,String>() {{ put("c", "d"); }});
config.setVersionTag("v2");
- host.addDesiredConfig(c1.getClusterId(), true, config);
+ host.addDesiredConfig(c1.getClusterId(), true, "_test1", config);
map = host.getDesiredConfigs(c1.getClusterId());
Assert.assertTrue("Expect desired config to contain global",
map.containsKey("global"));
- Assert.assertEquals("Expect version to be 'v2'",
- "v2", map.get("global").getVersion());
+ Assert.assertEquals("Expect version to be 'v2'", "v2",
map.get("global").getVersion());
+ Assert.assertEquals("Expect user to be '_test1'", "_test1",
map.get("global").getUser());
- host.addDesiredConfig(c1.getClusterId(), false, config);
+ host.addDesiredConfig(c1.getClusterId(), false, "_test2", config);
map = host.getDesiredConfigs(c1.getClusterId());
Assert.assertEquals("Expect no mapping configs", 0, map.size());