ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [4/6] ambari git commit: AMBARI-20957. Remove cluster_version use (ncole)
Date Tue, 09 May 2017 16:25:09 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
index 584ce98..c43d3ba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
@@ -30,7 +30,6 @@ import org.apache.ambari.server.AmbariService;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.state.Cluster;
@@ -165,12 +164,6 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
    * @return Request Id of active stack upgrade.
    */
   private Long getActiveUpgradeRequestId(Cluster cluster) {
-    ClusterVersionEntity currentVersion = cluster.getCurrentClusterVersion();
-
-    if (currentVersion == null) {
-      LOG.debug("No Cluster Version exists as CURRENT. Skip retrying failed tasks.");
-      return null;
-    }
 
     // May be null, and either upgrade or downgrade
     UpgradeEntity currentUpgrade = cluster.getUpgradeInProgress();

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog220.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog220.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog220.java
index 11e90ee..a11fd96 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog220.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog220.java
@@ -51,7 +51,6 @@ import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.ArtifactDAO;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.DaoUtils;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
@@ -60,7 +59,6 @@ import org.apache.ambari.server.orm.dao.UpgradeDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.ArtifactEntity;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
@@ -724,7 +722,6 @@ public class UpgradeCatalog220 extends AbstractUpgradeCatalog {
     StackDAO stackDAO = injector.getInstance(StackDAO.class);
     RepositoryVersionHelper repositoryVersionHelper = injector.getInstance(RepositoryVersionHelper.class);
     RepositoryVersionDAO repositoryVersionDAO = injector.getInstance(RepositoryVersionDAO.class);
-    ClusterVersionDAO clusterVersionDAO = injector.getInstance(ClusterVersionDAO.class);
     HostVersionDAO hostVersionDAO = injector.getInstance(HostVersionDAO.class);
 
     Clusters clusters = amc.getClusters();
@@ -766,6 +763,7 @@ public class UpgradeCatalog220 extends AbstractUpgradeCatalog {
             repoVersionEntity.getId(), displayName, operatingSystems));
         }
 
+        /*
         // Create the Cluster Version if it doesn't already exist.
         ClusterVersionEntity clusterVersionEntity = clusterVersionDAO.findByClusterAndStackAndVersion(cluster.getClusterName(),
           stackId, hardcodedInitialVersion);
@@ -791,6 +789,7 @@ public class UpgradeCatalog220 extends AbstractUpgradeCatalog {
             clusterVersionEntity.getId(), cluster.getClusterName(), clusterVersionEntity.getRepositoryVersion().getVersion(),
             clusterVersionEntity.getState()));
         }
+        */
 
         // Create the Host Versions if they don't already exist.
         Collection<HostEntity> hosts = clusterEntity.getHostEntities();

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index c2a9239..359d446 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -163,17 +163,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id BIGINT NOT NULL,
-  repo_version_id BIGINT NOT NULL,
-  cluster_id BIGINT NOT NULL,
-  state VARCHAR(32) NOT NULL,
-  start_time BIGINT NOT NULL,
-  end_time BIGINT,
-  user_name VARCHAR(32),
-  CONSTRAINT PK_cluster_version PRIMARY KEY (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
 
 CREATE TABLE servicecomponentdesiredstate (
   id BIGINT NOT NULL,
@@ -1102,8 +1091,6 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value)
   union all
   select 'repo_version_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
-  select 'cluster_version_id_seq', 0 FROM SYSIBM.SYSDUMMY1
-  union all
   select 'host_version_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
   select 'service_config_id_seq', 1 FROM SYSIBM.SYSDUMMY1

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 48d2c35..d5221dc 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -183,17 +183,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id BIGINT NOT NULL,
-  repo_version_id BIGINT NOT NULL,
-  cluster_id BIGINT NOT NULL,
-  state VARCHAR(32) NOT NULL,
-  start_time BIGINT NOT NULL,
-  end_time BIGINT,
-  user_name VARCHAR(32),
-  CONSTRAINT PK_cluster_version PRIMARY KEY (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
 
 CREATE TABLE servicecomponentdesiredstate (
   id BIGINT NOT NULL,
@@ -1086,7 +1075,6 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) VALUES
   ('permission_id_seq', 7),
   ('privilege_id_seq', 1),
   ('config_id_seq', 1),
-  ('cluster_version_id_seq', 0),
   ('host_version_id_seq', 0),
   ('service_config_id_seq', 1),
   ('alert_definition_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 26201fc..d49bd95 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -164,17 +164,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id NUMBER(19) NULL,
-  repo_version_id NUMBER(19) NOT NULL,
-  cluster_id NUMBER(19) NOT NULL,
-  state VARCHAR2(32) NOT NULL,
-  start_time NUMBER(19) NOT NULL,
-  end_time NUMBER(19),
-  user_name VARCHAR2(32),
-  CONSTRAINT PK_cluster_version PRIMARY KEY (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
 
 CREATE TABLE servicecomponentdesiredstate (
   id NUMBER(19) NOT NULL,
@@ -1065,7 +1054,6 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('principal_i
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('permission_id_seq', 7);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('privilege_id_seq', 1);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('config_id_seq', 1);
-INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('cluster_version_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('host_version_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('service_config_id_seq', 1);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('alert_definition_id_seq', 0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 156fc08..2bd5a9d 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -163,18 +163,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id BIGINT NOT NULL,
-  repo_version_id BIGINT NOT NULL,
-  cluster_id BIGINT NOT NULL,
-  state VARCHAR(32) NOT NULL,
-  start_time BIGINT NOT NULL,
-  end_time BIGINT,
-  user_name VARCHAR(32),
-  CONSTRAINT PK_cluster_version PRIMARY KEY (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
-
 CREATE TABLE servicecomponentdesiredstate (
   id BIGINT NOT NULL,
   component_name VARCHAR(255) NOT NULL,
@@ -1074,7 +1062,6 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value) VALUES
   ('alert_current_id_seq', 0),
   ('config_id_seq', 1),
   ('repo_version_id_seq', 0),
-  ('cluster_version_id_seq', 0),
   ('host_version_id_seq', 0),
   ('service_config_id_seq', 1),
   ('upgrade_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 979ea44..72ae04b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -162,18 +162,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id NUMERIC(19) NOT NULL,
-  repo_version_id NUMERIC(19) NOT NULL,
-  cluster_id NUMERIC(19) NOT NULL,
-  state VARCHAR(32) NOT NULL,
-  start_time NUMERIC(19) NOT NULL,
-  end_time NUMERIC(19),
-  user_name VARCHAR(32),
-  CONSTRAINT PK_cluster_version PRIMARY KEY (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
-
 CREATE TABLE servicecomponentdesiredstate (
   id NUMERIC(19) NOT NULL,
   component_name VARCHAR(255) NOT NULL,
@@ -1064,7 +1052,6 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('principal_i
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('permission_id_seq', 7);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('privilege_id_seq', 1);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('config_id_seq', 1);
-INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('cluster_version_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('host_version_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('service_config_id_seq', 1);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('alert_definition_id_seq', 0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 08c71ff..676fde2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -176,18 +176,6 @@ CREATE TABLE repo_version (
   CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
   CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
 
-CREATE TABLE cluster_version (
-  id BIGINT NOT NULL,
-  cluster_id BIGINT NOT NULL,
-  repo_version_id BIGINT NOT NULL,
-  STATE VARCHAR(255) NOT NULL,
-  start_time BIGINT NOT NULL,
-  end_time BIGINT,
-  user_name VARCHAR(255),
-  CONSTRAINT PK_cluster_version PRIMARY KEY CLUSTERED (id),
-  CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
-  CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
-
 CREATE TABLE servicecomponentdesiredstate (
   id BIGINT NOT NULL,
   component_name VARCHAR(255) NOT NULL,
@@ -1098,7 +1086,6 @@ BEGIN TRANSACTION
     ('alert_current_id_seq', 0),
     ('config_id_seq', 11),
     ('repo_version_id_seq', 0),
-    ('cluster_version_id_seq', 0),
     ('host_version_id_seq', 0),
     ('service_config_id_seq', 1),
     ('upgrade_id_seq', 0),

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 0375650..8fd539a 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -24,11 +24,9 @@
     <class>org.apache.ambari.server.orm.entities.BlueprintSettingEntity</class>
     <class>org.apache.ambari.server.orm.entities.BlueprintEntity</class>
     <class>org.apache.ambari.server.orm.entities.ClusterConfigEntity</class>
-    <class>org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity</class>
     <class>org.apache.ambari.server.orm.entities.ClusterEntity</class>
     <class>org.apache.ambari.server.orm.entities.ClusterServiceEntity</class>
     <class>org.apache.ambari.server.orm.entities.ClusterStateEntity</class>
-    <class>org.apache.ambari.server.orm.entities.ClusterVersionEntity</class>
     <class>org.apache.ambari.server.orm.entities.ConfigGroupConfigMappingEntity</class>
     <class>org.apache.ambari.server.orm.entities.ConfigGroupEntity</class>
     <class>org.apache.ambari.server.orm.entities.ConfigGroupHostMappingEntity</class>

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/StateRecoveryManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/StateRecoveryManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/StateRecoveryManagerTest.java
index c5be8f4..898875e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/StateRecoveryManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/StateRecoveryManagerTest.java
@@ -27,16 +27,14 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
 import java.sql.SQLException;
-import java.util.ArrayList;
 
 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.HostVersionDAO;
-import org.apache.ambari.server.orm.entities.ClusterEntity;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
+import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
 import org.apache.ambari.server.state.RepositoryVersionState;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
@@ -44,6 +42,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.collect.Lists;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -53,13 +52,13 @@ public class StateRecoveryManagerTest {
 
   private Injector injector;
   private HostVersionDAO hostVersionDAOMock;
-  private ClusterVersionDAO clusterVersionDAOMock;
+  private ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAOMock;
 
   @Before
   public void setup() throws Exception {
     // Create instances of mocks
-    clusterVersionDAOMock = createNiceMock(ClusterVersionDAO.class);
     hostVersionDAOMock = createNiceMock(HostVersionDAO.class);
+    serviceComponentDesiredStateDAOMock = createNiceMock(ServiceComponentDesiredStateDAO.class);
     // Initialize injector
     InMemoryDefaultTestModule module = new InMemoryDefaultTestModule();
     injector = Guice.createInjector(Modules.override(module).with(new MockModule()));
@@ -86,13 +85,12 @@ public class StateRecoveryManagerTest {
     final Capture<RepositoryVersionState> upgradedHostVersionCapture = EasyMock.newCapture();
     final Capture<RepositoryVersionState> currentHostVersionCapture = EasyMock.newCapture();
 
-    expect(hostVersionDAOMock.findAll()).andReturn(new ArrayList<HostVersionEntity>() {{
-      add(getHostVersionMock("install_failed_version", RepositoryVersionState.INSTALL_FAILED, installFailedHostVersionCapture));
-      add(getHostVersionMock("installing_version", RepositoryVersionState.INSTALLING, installingHostVersionCapture));
-      add(getHostVersionMock("installed_version", RepositoryVersionState.INSTALLED, installedHostVersionCapture));
-      add(getHostVersionMock("out_of_sync_version", RepositoryVersionState.OUT_OF_SYNC, outOfSyncHostVersionCapture));
-      add(getHostVersionMock("current_version", RepositoryVersionState.CURRENT, currentHostVersionCapture));
-    }});
+    expect(hostVersionDAOMock.findAll()).andReturn(Lists.newArrayList(
+      getHostVersionMock("install_failed_version", RepositoryVersionState.INSTALL_FAILED, installFailedHostVersionCapture),
+      getHostVersionMock("installing_version", RepositoryVersionState.INSTALLING, installingHostVersionCapture),
+      getHostVersionMock("installed_version", RepositoryVersionState.INSTALLED, installedHostVersionCapture),
+      getHostVersionMock("out_of_sync_version", RepositoryVersionState.OUT_OF_SYNC, outOfSyncHostVersionCapture),
+      getHostVersionMock("current_version", RepositoryVersionState.CURRENT, currentHostVersionCapture)));
 
     // Adding all possible cluster version states
 
@@ -105,15 +103,14 @@ public class StateRecoveryManagerTest {
     final Capture<RepositoryVersionState> upgradedClusterVersionCapture = EasyMock.newCapture();
     final Capture<RepositoryVersionState> currentClusterVersionCapture = EasyMock.newCapture();
 
-    expect(clusterVersionDAOMock.findAll()).andReturn(new ArrayList<ClusterVersionEntity>() {{
-      add(getClusterVersionMock("install_failed_version", RepositoryVersionState.INSTALL_FAILED, installFailedClusterVersionCapture));
-      add(getClusterVersionMock("installing_version", RepositoryVersionState.INSTALLING, installingClusterVersionCapture));
-      add(getClusterVersionMock("installed_version", RepositoryVersionState.INSTALLED, installedClusterVersionCapture));
-      add(getClusterVersionMock("out_of_sync_version", RepositoryVersionState.OUT_OF_SYNC, outOfSyncClusterVersionCapture));
-      add(getClusterVersionMock("current_version", RepositoryVersionState.CURRENT, currentClusterVersionCapture));
-    }});
+    expect(serviceComponentDesiredStateDAOMock.findAll()).andReturn(Lists.newArrayList(
+      getDesiredStateEntityMock("install_failed_version", RepositoryVersionState.INSTALL_FAILED, installFailedClusterVersionCapture),
+      getDesiredStateEntityMock("installing_version", RepositoryVersionState.INSTALLING, installingClusterVersionCapture),
+      getDesiredStateEntityMock("installed_version", RepositoryVersionState.INSTALLED, installedClusterVersionCapture),
+      getDesiredStateEntityMock("out_of_sync_version", RepositoryVersionState.OUT_OF_SYNC, outOfSyncClusterVersionCapture),
+      getDesiredStateEntityMock("current_version", RepositoryVersionState.CURRENT, currentClusterVersionCapture)));
 
-    replay(hostVersionDAOMock, clusterVersionDAOMock);
+    replay(hostVersionDAOMock, serviceComponentDesiredStateDAOMock);
 
     stateRecoveryManager.checkHostAndClusterVersions();
 
@@ -158,35 +155,30 @@ public class StateRecoveryManagerTest {
     return hvMock;
   }
 
+  private ServiceComponentDesiredStateEntity getDesiredStateEntityMock(String name, RepositoryVersionState state, Capture<RepositoryVersionState> newStateCapture) {
 
-  private ClusterVersionEntity getClusterVersionMock(String name, RepositoryVersionState state,
-                                               Capture<RepositoryVersionState> newStateCaptor) {
-    ClusterVersionEntity cvMock = createNiceMock(ClusterVersionEntity.class);
-    expect(cvMock.getState()).andReturn(state);
-
-    cvMock.setState(capture(newStateCaptor));
+    ServiceComponentDesiredStateEntity mock = createNiceMock(ServiceComponentDesiredStateEntity.class);
+    expect(mock.getRepositoryState()).andReturn(state);
+    mock.setRepositoryState(capture(newStateCapture));
     expectLastCall();
 
-    RepositoryVersionEntity rvMock = createNiceMock(RepositoryVersionEntity.class);
-    expect(rvMock.getDisplayName()).andReturn(name);
+    RepositoryVersionEntity repositoryVersionMock = createNiceMock(RepositoryVersionEntity.class);
+    expect(repositoryVersionMock.getVersion()).andReturn(name);
 
-    expect(cvMock.getRepositoryVersion()).andReturn(rvMock);
+    expect(mock.getDesiredRepositoryVersion()).andReturn(repositoryVersionMock);
 
-    ClusterEntity ceMock = createNiceMock(ClusterEntity.class);
-    expect(ceMock.getClusterName()).andReturn("somecluster");
+    replay(mock, repositoryVersionMock);
 
-    expect(cvMock.getClusterEntity()).andReturn(ceMock);
+    return mock;
+  }
 
-    replay(cvMock, rvMock, ceMock);
 
-    return cvMock;
-  }
 
   public class MockModule extends AbstractModule {
     @Override
     protected void configure() {
       bind(HostVersionDAO.class).toInstance(hostVersionDAOMock);
-      bind(ClusterVersionDAO.class).toInstance(clusterVersionDAOMock);
+      bind(ServiceComponentDesiredStateDAO.class).toInstance(serviceComponentDesiredStateDAOMock);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
index 5afeb77..5fa3e41 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
@@ -62,9 +62,9 @@ import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.OrmTestHelper;
 import org.apache.ambari.server.orm.dao.HostDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.HostEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Alert;
@@ -86,21 +86,17 @@ import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.apache.ambari.server.utils.StageUtils;
 import org.easymock.EasyMock;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.gson.JsonObject;
 import com.google.inject.Guice;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 
-import junit.framework.Assert;
-
 public class HeartbeatProcessorTest {
 
-  private static final Logger log = LoggerFactory.getLogger(TestHeartbeatHandler.class);
   private Injector injector;
   private long requestId = 23;
   private long stageId = 31;
@@ -132,6 +128,9 @@ public class HeartbeatProcessorTest {
   @Inject
   private AmbariMetaInfo metaInfo;
 
+  @Inject
+  private OrmTestHelper helper;
+
 
   public HeartbeatProcessorTest(){
     InMemoryDefaultTestModule module = HeartbeatTestHelper.getTestModule();
@@ -153,7 +152,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testHeartbeatWithConfigs() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -222,7 +220,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testRestartRequiredAfterInstallClient() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -287,7 +284,6 @@ public class HeartbeatProcessorTest {
 
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testHeartbeatCustomCommandWithConfigs() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -371,7 +367,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testHeartbeatCustomStartStop() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -455,7 +450,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testStatusHeartbeat() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -580,7 +574,6 @@ public class HeartbeatProcessorTest {
    * @throws InvalidStateTransitionException
    */
   @Test
-  @SuppressWarnings("unchecked")
   public void testCommandReportOnHeartbeatUpdatedState()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
@@ -700,7 +693,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testUpgradeSpecificHandling() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -794,7 +786,6 @@ public class HeartbeatProcessorTest {
 
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testCommandStatusProcesses() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -873,7 +864,6 @@ public class HeartbeatProcessorTest {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testComponentUpgradeFailReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -985,7 +975,6 @@ public class HeartbeatProcessorTest {
 
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testComponentUpgradeInProgressReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -1068,7 +1057,6 @@ public class HeartbeatProcessorTest {
    * @throws Exception
    */
   @Test
-  @SuppressWarnings("unchecked")
   public void testHeartBeatWithAlertAndInvalidCluster() throws Exception {
     ActionManager am = actionManagerTestHelper.getMockActionManager();
 
@@ -1173,20 +1161,16 @@ public class HeartbeatProcessorTest {
     StackId stackId = new StackId("HDP", "0.1");
 
     RepositoryVersionDAO dao = injector.getInstance(RepositoryVersionDAO.class);
-    RepositoryVersionEntity entity = dao.findByStackAndVersion(stackId, "0.1-1234");
+    RepositoryVersionEntity entity = helper.getOrCreateRepositoryVersion(cluster);
     Assert.assertNotNull(entity);
 
     heartbeatProcessor.processHeartbeat(hb);
 
     entity = dao.findByStackAndVersion(stackId, "0.1-1234");
     Assert.assertNull(entity);
-
-    entity = dao.findByStackAndVersion(stackId, "2.2.1.0-2222");
-    Assert.assertNotNull(entity);
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testComponentInProgressStatusSafeAfterStatusReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -1270,8 +1254,7 @@ public class HeartbeatProcessorTest {
    * @throws AmbariException
    */
   private Service addService(Cluster cluster, String serviceName) throws AmbariException {
-    ClusterVersionEntity clusterVersion = cluster.getCurrentClusterVersion();
-    RepositoryVersionEntity repositoryVersion = clusterVersion.getRepositoryVersion();
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     return cluster.addService(serviceName, repositoryVersion);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
index 6e1ebdd..2f2c79e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
@@ -60,7 +60,6 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
@@ -196,9 +195,6 @@ public class HeartbeatTestHelper {
     Config config = cf.createNew(cluster, "cluster-env", "version1", configProperties, new HashMap<String, Map<String, String>>());
     cluster.addDesiredConfig("user", Collections.singleton(config));
 
-    helper.getOrCreateRepositoryVersion(stackId, repositoryVersion);
-    cluster.createClusterVersion(stackId, repositoryVersion, "admin",
-        RepositoryVersionState.INSTALLING);
 
     Map<String, String> hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 83e7d56..76de02c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -75,7 +75,7 @@ import org.apache.ambari.server.audit.AuditLogger;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
+import org.apache.ambari.server.orm.OrmTestHelper;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.serveraction.kerberos.KerberosIdentityDataFileWriter;
 import org.apache.ambari.server.serveraction.kerberos.KerberosIdentityDataFileWriterFactory;
@@ -145,6 +145,9 @@ public class TestHeartbeatHandler {
   @Inject
   AuditLogger auditLogger;
 
+  @Inject
+  private OrmTestHelper helper;
+
   @Rule
   public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
@@ -168,7 +171,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testHeartbeat() throws Exception {
     ActionManager am = actionManagerTestHelper.getMockActionManager();
     expect(am.getTasks(EasyMock.<List<Long>>anyObject())).andReturn(new ArrayList<HostRoleCommand>());
@@ -223,14 +225,7 @@ public class TestHeartbeatHandler {
     assertEquals(0, aq.dequeueAll(hostname).size());
   }
 
-
-
-
-
-
-
   @Test
-  @SuppressWarnings("unchecked")
   public void testStatusHeartbeatWithAnnotation() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -281,7 +276,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testLiveStatusUpdateAfterStopFailed() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -791,7 +785,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testTaskInProgressHandling() throws Exception, InvalidStateTransitionException {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -848,7 +841,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testOPFailedEventForAbortedTask() throws Exception, InvalidStateTransitionException {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -918,11 +910,7 @@ public class TestHeartbeatHandler {
       componentState1);
   }
 
-
-
-
   @Test
-  @SuppressWarnings("unchecked")
   public void testStatusHeartbeat() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -979,10 +967,7 @@ public class TestHeartbeatHandler {
     assertTrue(hb.getAgentEnv().getHostHealth().getServerTimeStampAtReporting() >= hb.getTimestamp());
   }
 
-
-
   @Test
-  @SuppressWarnings("unchecked")
   public void testRecoveryStatusReports() throws Exception {
     Clusters fsm = clusters;
 
@@ -1063,7 +1048,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testProcessStatusReports() throws Exception {
     Clusters fsm = clusters;
 
@@ -1263,7 +1247,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testIgnoreCustomActionReport() throws Exception, InvalidStateTransitionException {
     CommandReport cr1 = new CommandReport();
     cr1.setActionId(StageUtils.getActionId(requestId, stageId));
@@ -1390,7 +1373,6 @@ public class TestHeartbeatHandler {
   }
 
   @Test
-  @SuppressWarnings("unchecked")
   public void testCommandStatusProcesses_empty() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = addService(cluster, HDFS);
@@ -1398,7 +1380,6 @@ public class TestHeartbeatHandler {
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
-    ActionQueue aq = new ActionQueue();
     HeartBeat hb = new HeartBeat();
     hb.setTimestamp(System.currentTimeMillis());
     hb.setResponseId(0);
@@ -1427,7 +1408,6 @@ public class TestHeartbeatHandler {
             }});
     replay(am);
 
-    HeartBeatHandler handler = heartbeatTestHelper.getHeartBeatHandler(am, aq);
     ServiceComponentHost sch = hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
 
     Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(sch.getProcesses().size()));
@@ -1592,8 +1572,7 @@ public class TestHeartbeatHandler {
    * @throws AmbariException
    */
   private Service addService(Cluster cluster, String serviceName) throws AmbariException {
-    ClusterVersionEntity clusterVersion = cluster.getCurrentClusterVersion();
-    RepositoryVersionEntity repositoryVersion = clusterVersion.getRepositoryVersion();
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     return cluster.addService(serviceName, repositoryVersion);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
index 4c536a9..e7bccc3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
@@ -48,7 +48,6 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostState;
-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;
@@ -155,8 +154,6 @@ public class TestHeartbeatMonitor {
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
 
-    cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
     Set<String> hostNames = new HashSet<String>(){{
       add(hostname1);
       add(hostname2);
@@ -238,8 +235,7 @@ public class TestHeartbeatMonitor {
 
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
-    cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
+
     Set<String> hostNames = new HashSet<String>() {{
       add(hostname1);
       add(hostname2);
@@ -250,6 +246,8 @@ public class TestHeartbeatMonitor {
       new HashMap<String, String>() {{
         put("a", "b");
       }}, new HashMap<String, Map<String,String>>());
+
+
     Config hbaseEnvConfig = configFactory.createNew(cluster, "hbase-env", "version1",
             new HashMap<String, String>() {{
               put("a", "b");
@@ -359,8 +357,6 @@ public class TestHeartbeatMonitor {
 
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
-    cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     Set<String> hostNames = new HashSet<String>(){{
       add(hostname1);
@@ -442,8 +438,6 @@ public class TestHeartbeatMonitor {
 
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
-    cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-            RepositoryVersionState.INSTALLING);
 
     Set<String> hostNames = new HashSet<String>(){{
       add(hostname1);
@@ -561,8 +555,6 @@ public class TestHeartbeatMonitor {
     cluster.setDesiredStackVersion(stackId);
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
-    cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     Set<String> hostNames = new HashSet<String>(){{
       add(hostname1);

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
index 86a682c..986a0f1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/InstallPackagesCheckTest.java
@@ -24,10 +24,8 @@ import java.util.List;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
-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.StackEntity;
@@ -58,7 +56,7 @@ import com.google.inject.Provider;
 @PrepareForTest(HostComponentSummary.class)   // This class has a static method that will be mocked
 public class InstallPackagesCheckTest {
   private final Clusters clusters = Mockito.mock(Clusters.class);
-  private final ClusterVersionDAO clusterVersionDAO = Mockito.mock(ClusterVersionDAO.class);
+
   private final HostVersionDAO hostVersionDAO = Mockito.mock(HostVersionDAO.class);
   private final RepositoryVersionDAO repositoryVersionDAO = Mockito.mock(RepositoryVersionDAO.class);
   private AmbariMetaInfo ambariMetaInfo = Mockito.mock(AmbariMetaInfo.class);
@@ -101,13 +99,6 @@ public class InstallPackagesCheckTest {
       }
     };
 
-    installPackagesCheck.clusterVersionDAOProvider = new Provider<ClusterVersionDAO>() {
-      @Override
-      public ClusterVersionDAO get() {
-        return clusterVersionDAO;
-      }
-    };
-
     installPackagesCheck.hostVersionDaoProvider = new Provider<HostVersionDAO>() {
       @Override
       public HostVersionDAO get() {
@@ -132,10 +123,6 @@ public class InstallPackagesCheckTest {
 
     Mockito.when(cluster.getCurrentStackVersion()).thenReturn(stackId);
     Mockito.when(clusters.getCluster(clusterName)).thenReturn(cluster);
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(clusterVersionEntity.getState()).thenReturn(RepositoryVersionState.INSTALLED);
-    Mockito.when(clusterVersionDAO.findByClusterAndStackAndVersion(
-        clusterName, targetStackId, repositoryVersion)).thenReturn(clusterVersionEntity);
     final List<String> hostNames = new ArrayList<>();
     hostNames.add("host1");
     hostNames.add("host2");
@@ -168,21 +155,10 @@ public class InstallPackagesCheckTest {
 
     // Case 2: Install Packages failed on host1
     Mockito.when(hostVersionEntities.get(0).getState()).thenReturn(RepositoryVersionState.INSTALL_FAILED);
-    Mockito.when(clusterVersionEntity.getState()).thenReturn(RepositoryVersionState.INSTALL_FAILED);
     check = new PrerequisiteCheck(null, null);
     installPackagesCheck.perform(check, checkRequest);
     Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
     Assert.assertNotNull(check.getFailedOn());
     Assert.assertTrue(check.getFailedOn().contains("host1"));
-
-    // Case 3: Install Packages failed on host1 and host1 was put in Maintenance Mode
-    Mockito.when(hostVersionEntities.get(0).getState()).thenReturn(RepositoryVersionState.INSTALL_FAILED);
-    Mockito.when(hosts.get(0).getMaintenanceState(1L)).thenReturn(MaintenanceState.ON);
-    Mockito.when(clusterVersionEntity.getState()).thenReturn(RepositoryVersionState.INSTALL_FAILED);
-    check = new PrerequisiteCheck(null, null);
-    installPackagesCheck.perform(check, checkRequest);
-    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
-    Assert.assertNotNull(check.getFailedOn());
-    Assert.assertTrue(check.getFailedOn().contains(clusterName));
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
index c899af6..016bdd08 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/MapReduce2JobHistoryStatePreservingCheckTest.java
@@ -23,7 +23,6 @@ import java.util.Map;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -91,9 +90,6 @@ public class MapReduce2JobHistoryStatePreservingCheckTest {
     Map<String, Service> services = new HashMap<>();
     Mockito.when(cluster.getServices()).thenReturn(services);
 
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
-
     PrereqCheckRequest request = new PrereqCheckRequest("cluster");
     request.setTargetStackId(new StackId("HDP", "2.3.1.1"));
     request.setSourceStackId(new StackId("HDP", "2.3.0.0"));
@@ -156,10 +152,7 @@ public class MapReduce2JobHistoryStatePreservingCheckTest {
       }
     });
     Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("MYSTACK-12.2"));
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
     RepositoryVersionEntity repositoryVersionEntity = Mockito.mock(RepositoryVersionEntity.class);
-    Mockito.when(clusterVersionEntity.getRepositoryVersion()).thenReturn(repositoryVersionEntity);
     Mockito.when(m_clusters.getCluster("c1")).thenReturn(cluster);
     PrereqCheckRequest request = new PrereqCheckRequest("c1");
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
index 7486c71..5c423b5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/YarnTimelineServerStatePreservingCheckTest.java
@@ -22,7 +22,6 @@ import java.util.Map;
 
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -80,11 +79,7 @@ public class YarnTimelineServerStatePreservingCheckTest {
     Map<String, Service> services = new HashMap<>();
     Mockito.when(cluster.getServices()).thenReturn(services);
 
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
-
     RepositoryVersionEntity repositoryVersionEntity = Mockito.mock(RepositoryVersionEntity.class);
-    Mockito.when(clusterVersionEntity.getRepositoryVersion()).thenReturn(repositoryVersionEntity);
     Mockito.when(repositoryVersionEntity.getVersion()).thenReturn("2.2.4.2");
 
     Map<String, String> checkProperties = new HashMap<>();
@@ -150,10 +145,7 @@ public class YarnTimelineServerStatePreservingCheckTest {
       }
     });
     Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP-2.2"));
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
     RepositoryVersionEntity repositoryVersionEntity = Mockito.mock(RepositoryVersionEntity.class);
-    Mockito.when(clusterVersionEntity.getRepositoryVersion()).thenReturn(repositoryVersionEntity);
     Mockito.when(m_clusters.getCluster("c1")).thenReturn(cluster);
 
     Map<String, String> checkProperties = new HashMap<>();
@@ -198,10 +190,7 @@ public class YarnTimelineServerStatePreservingCheckTest {
       }
     });
     Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("MYSTACK-12.2"));
-    ClusterVersionEntity clusterVersionEntity = Mockito.mock(ClusterVersionEntity.class);
-    Mockito.when(cluster.getCurrentClusterVersion()).thenReturn(clusterVersionEntity);
     RepositoryVersionEntity repositoryVersionEntity = Mockito.mock(RepositoryVersionEntity.class);
-    Mockito.when(clusterVersionEntity.getRepositoryVersion()).thenReturn(repositoryVersionEntity);
     Mockito.when(m_clusters.getCluster("c1")).thenReturn(cluster);
 
     Map<String, String> checkProperties = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
index 00fc962..0ae79d0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
@@ -38,6 +38,7 @@ import org.apache.ambari.server.agent.RecoveryConfig;
 import org.apache.ambari.server.agent.RecoveryConfigHelper;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.OrmTestHelper;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.Cluster;
@@ -74,10 +75,8 @@ public class RecoveryConfigHelperTest {
   @Inject
   private RepositoryVersionDAO repositoryVersionDAO;
 
-  /**
-   * The repository created when creating the test cluster.
-   */
-  private RepositoryVersionEntity repositoryVersion;
+  @Inject
+  private OrmTestHelper helper;
 
   private final String STACK_VERSION = "0.1";
   private final String REPO_VERSION = "0.1-1234";
@@ -146,7 +145,8 @@ public class RecoveryConfigHelperTest {
   public void testServiceComponentInstalled()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
+
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
@@ -180,7 +180,7 @@ public class RecoveryConfigHelperTest {
   public void testServiceComponentUninstalled()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
@@ -216,7 +216,7 @@ public class RecoveryConfigHelperTest {
   public void testClusterEnvConfigChanged()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
@@ -256,7 +256,7 @@ public class RecoveryConfigHelperTest {
   public void testMaintenanceModeChanged()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
@@ -291,7 +291,7 @@ public class RecoveryConfigHelperTest {
   public void testServiceComponentRecoveryChanged()
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
@@ -332,6 +332,8 @@ public class RecoveryConfigHelperTest {
     // Create a cluster with 2 hosts
     Cluster cluster = getDummyCluster(hostNames);
 
+    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
+
     // Add HDFS service with DATANODE component to the cluster
     Service hdfs = cluster.addService(HDFS, repositoryVersion);
 
@@ -357,6 +359,7 @@ public class RecoveryConfigHelperTest {
 
   private Cluster getDummyCluster(Set<String> hostNames)
       throws Exception {
+
     Map<String, String> configProperties = new HashMap<String, String>() {{
       put(RecoveryConfigHelper.RECOVERY_ENABLED_KEY, "true");
       put(RecoveryConfigHelper.RECOVERY_TYPE_KEY, "AUTO_START");
@@ -369,8 +372,6 @@ public class RecoveryConfigHelperTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster("cluster1", stackId, REPO_VERSION,
         configProperties, hostNames);
 
-    repositoryVersion = repositoryVersionDAO.findByStackAndVersion(stackId, REPO_VERSION);
-    assertNotNull(repositoryVersion);
     return cluster;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/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 f5848f4..4170342 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
@@ -73,9 +73,7 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.RequestStageContainer;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
 import org.apache.ambari.server.orm.entities.LdapSyncSpecEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.security.authorization.Users;
@@ -94,7 +92,6 @@ import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -919,7 +916,6 @@ public class AmbariManagementControllerImplTest {
     expect(cluster.getResourceId()).andReturn(1L).times(3);
     expect(cluster.getClusterName()).andReturn("cluster").times(1);
     expect(cluster.getSecurityType()).andReturn(SecurityType.KERBEROS).anyTimes();
-    expect(cluster.getCurrentClusterVersion()).andReturn(null).anyTimes();
     expect(cluster.getCurrentStackVersion()).andReturn(null).anyTimes();
     expect(cluster.getDesiredStackVersion()).andReturn(null).anyTimes();
 
@@ -2059,8 +2055,6 @@ public class AmbariManagementControllerImplTest {
     Cluster cluster = createNiceMock(Cluster.class);
     Injector injector = createNiceMock(Injector.class);
     Configuration configuration = createNiceMock(Configuration.class);
-    ClusterVersionDAO clusterVersionDAO = createNiceMock(ClusterVersionDAO.class);
-    ClusterVersionEntity clusterVersionEntity = createNiceMock(ClusterVersionEntity.class);
     RepositoryVersionEntity repositoryVersionEntity = createNiceMock(RepositoryVersionEntity.class);
     ConfigHelper configHelper = createNiceMock(ConfigHelper.class);
 
@@ -2081,15 +2075,12 @@ public class AmbariManagementControllerImplTest {
     expect(configuration.areHostsSysPrepped()).andReturn("true");
     expect(configuration.getDatabaseConnectorNames()).andReturn(new HashMap<String, String>()).anyTimes();
     expect(configuration.getPreviousDatabaseConnectorNames()).andReturn(new HashMap<String, String>()).anyTimes();
-    expect(clusterVersionDAO.findByClusterAndStateCurrent(clusterName)).andReturn(clusterVersionEntity).anyTimes();
-    expect(clusterVersionEntity.getRepositoryVersion()).andReturn(repositoryVersionEntity).anyTimes();
     expect(repositoryVersionEntity.getVersion()).andReturn("1234").anyTimes();
     expect(configHelper.getPropertyValuesWithPropertyType(stackId,
         PropertyInfo.PropertyType.NOT_MANAGED_HDFS_PATH, cluster, desiredConfigs)).andReturn(
             notManagedHdfsPathSet);
 
-    replay(manager, clusters, cluster, injector, stackId, configuration, clusterVersionDAO, clusterVersionEntity,
-        repositoryVersionEntity, configHelper);
+    replay(manager, clusters, cluster, injector, stackId, configuration, repositoryVersionEntity, configHelper);
 
     AmbariManagementControllerImpl ambariManagementControllerImpl =
         createMockBuilder(AmbariManagementControllerImpl.class)
@@ -2116,10 +2107,6 @@ public class AmbariManagementControllerImplTest {
     f.setAccessible(true);
     f.set(helper, configuration);
 
-    f = helperClass.getDeclaredField("clusterVersionDAO");
-    f.setAccessible(true);
-    f.set(helper, clusterVersionDAO);
-
     f = helperClass.getDeclaredField("configHelper");
     f.setAccessible(true);
     f.set(helper, configHelper);
@@ -2128,7 +2115,7 @@ public class AmbariManagementControllerImplTest {
     f.setAccessible(true);
     f.set(helper, gson);
 
-    Map<String, String> defaultHostParams = helper.createDefaultHostParams(cluster);
+    Map<String, String> defaultHostParams = helper.createDefaultHostParams(cluster, repositoryVersionEntity);
 
     assertEquals(defaultHostParams.size(), 16);
     assertEquals(defaultHostParams.get(DB_DRIVER_FILENAME), MYSQL_JAR);
@@ -2221,10 +2208,10 @@ public class AmbariManagementControllerImplTest {
       super(actionManager, clusters, injector);
     }
 
-    public ServiceOsSpecific testPopulateServicePackagesInfo(ServiceInfo serviceInfo, Map<String, String> hostParams,
-                                                             String osFamily) {
-      return super.populateServicePackagesInfo(serviceInfo, hostParams, osFamily);
-    }
+//    public ServiceOsSpecific testPopulateServicePackagesInfo(ServiceInfo serviceInfo, Map<String, String> hostParams,
+//                                                             String osFamily) {
+//      return super.populateServicePackagesInfo(serviceInfo, hostParams, osFamily);
+//    }
 
   }
 
@@ -2341,10 +2328,6 @@ public class AmbariManagementControllerImplTest {
   public void testCreateClusterWithRepository() throws Exception {
     Injector injector = createNiceMock(Injector.class);
 
-    ClusterVersionDAO clusterVersionDAO = createNiceMock(ClusterVersionDAO.class);
-    expect(clusterVersionDAO.findByClusterAndStackAndVersion(anyObject(String.class),
-        anyObject(StackId.class), anyObject(String.class))).andReturn(null).once();
-
     RepositoryVersionEntity repoVersion = createNiceMock(RepositoryVersionEntity.class);
     RepositoryVersionDAO repoVersionDAO = createNiceMock(RepositoryVersionDAO.class);
     expect(repoVersionDAO.findByStackAndVersion(anyObject(StackId.class),
@@ -2353,17 +2336,10 @@ public class AmbariManagementControllerImplTest {
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).atLeastOnce();
     expect(injector.getInstance(Gson.class)).andReturn(null);
     expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class));
-    expect(injector.getInstance(ClusterVersionDAO.class)).andReturn(clusterVersionDAO);
 
     Cluster cluster = createNiceMock(Cluster.class);
     expect(cluster.getDesiredStackVersion()).andReturn(new StackId("HDP-2.1")).atLeastOnce();
 
-    // this getting called one time means the cluster version is getting created
-    ClusterVersionEntity clusterVersionEntity = createNiceMock(ClusterVersionEntity.class);
-    expect(cluster.createClusterVersion(anyObject(StackId.class), anyObject(String.class),
-        anyObject(String.class), anyObject(RepositoryVersionState.class))).andReturn(
-            clusterVersionEntity).once();
-
     expect(clusters.getCluster("c1")).andReturn(cluster).atLeastOnce();
 
     StackInfo stackInfo = createNiceMock(StackInfo.class);
@@ -2371,7 +2347,7 @@ public class AmbariManagementControllerImplTest {
 
     expect(ambariMetaInfo.getStack("HDP", "2.1")).andReturn(stackInfo).atLeastOnce();
 
-    replay(injector, clusters, ambariMetaInfo, stackInfo, cluster, repoVersionDAO, repoVersion, clusterVersionDAO);
+    replay(injector, clusters, ambariMetaInfo, stackInfo, cluster, repoVersionDAO, repoVersion);
 
     AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
     setAmbariMetaInfo(ambariMetaInfo, controller);
@@ -2393,7 +2369,7 @@ public class AmbariManagementControllerImplTest {
     controller.createCluster(cr);
 
     // verification
-    verify(injector, clusters, ambariMetaInfo, stackInfo, cluster, repoVersionDAO, repoVersion, clusterVersionDAO);
+    verify(injector, clusters, ambariMetaInfo, stackInfo, cluster, repoVersionDAO, repoVersion);
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaa821cc/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 1899b3a..d1d819f 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
@@ -128,7 +128,6 @@ import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -381,15 +380,6 @@ public class AmbariManagementControllerTest {
       dStateStr = desiredState.toString();
     }
 
-    Cluster cluster = clusters.getCluster(clusterName);
-    if (null == cluster.getCurrentClusterVersion()) {
-      StackId stackId = cluster.getCurrentStackVersion();
-      helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
-
-      cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-          RepositoryVersionState.INSTALLING);
-    }
-
     ServiceRequest r1 = new ServiceRequest(clusterName, serviceName,
         repositoryVersion.getStackId().getStackId(), repositoryVersion.getVersion(), dStateStr,
         null);
@@ -685,11 +675,6 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
-  public void testCreateClusterWithDesiredClusterConfigs() {
-    // TODO implement after configs integration
-  }
-
-  @Test
   public void testCreateClusterWithInvalidRequest() {
     ClusterRequest r = new ClusterRequest(null, null, null, null);
     r.toString();
@@ -1052,9 +1037,6 @@ public class AmbariManagementControllerTest {
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
         stackId.getStackVersion());
 
-    c1.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
-
     Service s1 = serviceFactory.createNew(c1, "HDFS", repositoryVersion);
     Service s2 = serviceFactory.createNew(c1, "MAPREDUCE", repositoryVersion);
     c1.addService(s1);
@@ -1378,8 +1360,6 @@ public class AmbariManagementControllerTest {
     StackId stackId = new StackId("HDP-0.2");
 
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
-    c1.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     Service s1 = serviceFactory.createNew(c1, "HDFS", repositoryVersion);
     Service s2 = serviceFactory.createNew(c1, "MAPREDUCE", repositoryVersion);
@@ -1664,23 +1644,14 @@ public class AmbariManagementControllerTest {
 
     foo.setDesiredStackVersion(stackId);
     foo.setCurrentStackVersion(stackId);
-    foo.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
-    foo.transitionClusterVersion(stackId, stackId.getStackVersion(), RepositoryVersionState.CURRENT);
 
     stackId = new StackId("HDP-0.2");
     c1.setDesiredStackVersion(stackId);
     c1.setCurrentStackVersion(stackId);
-    c1.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
-    c1.transitionClusterVersion(stackId, stackId.getStackVersion(), RepositoryVersionState.CURRENT);
 
     stackId = new StackId("HDP-0.2");
     c2.setDesiredStackVersion(stackId);
     c2.setCurrentStackVersion(stackId);
-    c2.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
-    c2.transitionClusterVersion(stackId, stackId.getStackVersion(), RepositoryVersionState.CURRENT);
 
     try {
       set1.clear();
@@ -1886,8 +1857,6 @@ public class AmbariManagementControllerTest {
     c.setDesiredStackVersion(stackId);
     c.setCurrentStackVersion(stackId);
     helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
-    c.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     HostResourceProviderTest.createHosts(controller, requests);
 
@@ -1915,8 +1884,6 @@ public class AmbariManagementControllerTest {
     c.setDesiredStackVersion(stackID);
     c.setCurrentStackVersion(stackID);
     helper.getOrCreateRepositoryVersion(stackID, stackID.getStackVersion());
-    c.createClusterVersion(stackID, stackID.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     setOsFamily(clusters.getHost(host1), "redhat", "5.9");
     setOsFamily(clusters.getHost(host2), "redhat", "5.9");
@@ -2261,8 +2228,6 @@ public class AmbariManagementControllerTest {
     StackId stackId = new StackId("HDP-0.1");
     c1.setDesiredStackVersion(stackId);
     helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
-    c1.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
 
     ClusterRequest r = new ClusterRequest(null, null, null, null);
     Set<ClusterResponse> resp = controller.getClusters(Collections.singleton(r));
@@ -7694,8 +7659,6 @@ public class AmbariManagementControllerTest {
     Long clusterId = c.getClusterId();
 
     helper.getOrCreateRepositoryVersion(stackID, stackID.getStackVersion());
-    c.createClusterVersion(stackID, stackID.getStackVersion(), "admin",
-        RepositoryVersionState.INSTALLING);
     clusters.addHost(hostName1);
     setOsFamily(clusters.getHost(hostName1), "redhat", "5.9");
 


Mime
View raw message