ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-9370. Upgrades: enhancements for downgrade direction/skippable (ncole)
Date Wed, 28 Jan 2015 14:19:23 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f0f5c28d4 -> d88dfe6cf


AMBARI-9370. Upgrades: enhancements for downgrade direction/skippable (ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d88dfe6c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d88dfe6c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d88dfe6c

Branch: refs/heads/trunk
Commit: d88dfe6cf9c6f46330ea71cd225d897b7a8178f3
Parents: f0f5c28
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Jan 27 22:27:01 2015 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Wed Jan 28 08:56:19 2015 -0500

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       |  4 +++
 .../server/orm/entities/UpgradeEntity.java      | 21 +++++++++++
 .../ambari/server/state/UpgradeHelper.java      |  5 +++
 .../state/stack/upgrade/ColocatedGrouping.java  | 13 ++++---
 .../server/state/stack/upgrade/Grouping.java    |  3 +-
 .../stack/upgrade/ServiceCheckGrouping.java     |  3 ++
 .../server/upgrade/UpgradeCatalog200.java       |  1 +
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  1 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  1 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  1 +
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  1 +
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  1 +
 .../internal/UpgradeResourceProviderTest.java   |  7 ++--
 .../ambari/server/state/UpgradeHelperTest.java  | 37 +++++++++++++++++---
 .../server/upgrade/UpgradeCatalog200Test.java   |  2 +-
 15 files changed, 88 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 91b8c98..2af90f6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -103,6 +103,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   protected static final String UPGRADE_FORCE_DOWNGRADE = "Upgrade/force_downgrade";
   protected static final String UPGRADE_FROM_VERSION = "Upgrade/from_version";
   protected static final String UPGRADE_TO_VERSION = "Upgrade/to_version";
+  protected static final String UPGRADE_DIRECTION = "Upgrade/direction";
 
   private static final Set<String> PK_PROPERTY_IDS = new HashSet<String>(
       Arrays.asList(UPGRADE_REQUEST_ID, UPGRADE_CLUSTER_NAME));
@@ -153,6 +154,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     PROPERTY_IDS.add(UPGRADE_FORCE_DOWNGRADE);
     PROPERTY_IDS.add(UPGRADE_FROM_VERSION);
     PROPERTY_IDS.add(UPGRADE_TO_VERSION);
+    PROPERTY_IDS.add(UPGRADE_DIRECTION);
 
     // !!! boo
     for (String requestPropertyId : RequestResourceProvider.PROPERTY_IDS) {
@@ -305,6 +307,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     setResourceProperty(resource, UPGRADE_REQUEST_ID, entity.getRequestId(), requestedIds);
     setResourceProperty(resource, UPGRADE_FROM_VERSION, entity.getFromVersion(), requestedIds);
     setResourceProperty(resource, UPGRADE_TO_VERSION, entity.getToVersion(), requestedIds);
+    setResourceProperty(resource, UPGRADE_DIRECTION, entity.getDirection(), requestedIds);
 
     return resource;
   }
@@ -477,6 +480,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     entity.setToVersion(version);
     entity.setUpgradeGroups(groupEntities);
     entity.setClusterId(Long.valueOf(cluster.getClusterId()));
+    entity.setDirection(direction);
 
     req.getRequestStatusResponse();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
index 5804a1d..a2eeea3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
@@ -22,6 +22,8 @@ import java.util.List;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -31,6 +33,8 @@ import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 
+import org.apache.ambari.server.state.stack.upgrade.Direction;
+
 /**
  * Models the data representation of an upgrade
  */
@@ -64,6 +68,9 @@ public class UpgradeEntity {
   @Column(name="to_version", nullable = false)
   private String toVersion = null;
 
+  @Column(name="direction", nullable = false)
+  @Enumerated(value = EnumType.STRING)
+  private Direction direction = Direction.UPGRADE;
 
   @OneToMany(mappedBy = "upgradeEntity", cascade = { CascadeType.ALL })
   private List<UpgradeGroupEntity> upgradeGroupEntities;
@@ -156,5 +163,19 @@ public class UpgradeEntity {
     toVersion = version;
   }
 
+  /**
+   * @return the direction of the upgrade
+   */
+  public Direction getDirection() {
+    return direction;
+  }
+
+  /**
+   * @param direction the direction of the upgrade
+   */
+  public void setDirection(Direction direction) {
+    this.direction = direction;
+  }
+
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index 5a4879d..a3f747b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -146,6 +146,11 @@ public class UpgradeHelper {
       groupHolder.skippable = group.skippable;
       groupHolder.allowRetry = group.allowRetry;
 
+      // !!! all downgrades are skippable
+      if (Direction.DOWNGRADE == context.getDirection()) {
+        groupHolder.skippable = true;
+      }
+
       StageWrapperBuilder builder = group.getBuilder();
 
       List<UpgradePack.OrderService> services = group.services;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
index 61fab0b..f3fb0e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ColocatedGrouping.java
@@ -142,7 +142,7 @@ public class ColocatedGrouping extends Grouping {
         LOG.debug("RU final: {}", finalBatches);
       }
 
-      results.addAll(fromProxies(initialBatch));
+      results.addAll(fromProxies(ctx.getDirection(), initialBatch));
 
       // !!! TODO when manual tasks are ready
       ManualTask task = new ManualTask();
@@ -151,16 +151,18 @@ public class ColocatedGrouping extends Grouping {
 
       StageWrapper wrapper = new StageWrapper(
           StageWrapper.Type.SERVER_SIDE_ACTION,
-          "Validate Partial Upgrade",
+          "Validate Partial " +
+              (Direction.UPGRADE == ctx.getDirection() ? "Upgrade" : "Downgrade"),
           new TaskWrapper(null, null, Collections.<String>emptySet(), task));
       results.add(wrapper);
 
-      results.addAll(fromProxies(finalBatches));
+      results.addAll(fromProxies(ctx.getDirection(), finalBatches));
 
       return results;
     }
 
-    private List<StageWrapper> fromProxies(Map<String, List<TaskProxy>>
wrappers) {
+    private List<StageWrapper> fromProxies(Direction direction,
+        Map<String, List<TaskProxy>> wrappers) {
       List<StageWrapper> results = new ArrayList<StageWrapper>();
 
       Set<String> serviceChecks = new HashSet<String>();
@@ -195,7 +197,8 @@ public class ColocatedGrouping extends Grouping {
 
       }
 
-      if (m_serviceCheck && serviceChecks.size() > 0) {
+      if (Direction.UPGRADE == direction && m_serviceCheck &&
+          serviceChecks.size() > 0) {
         // !!! add the service check task
         List<TaskWrapper> tasks = new ArrayList<TaskWrapper>();
         for (String service : serviceChecks) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
index fe911c8..ba4dca1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/Grouping.java
@@ -139,7 +139,8 @@ public class Grouping {
             service, "", Collections.<String>emptySet(), new ServiceCheckTask()));
       }
 
-      if (m_serviceCheck && m_servicesToCheck.size() > 0) {
+      if (Direction.UPGRADE == ctx.getDirection() && m_serviceCheck &&
+          m_servicesToCheck.size() > 0) {
         StageWrapper wrapper = new StageWrapper(
             StageWrapper.Type.SERVICE_CHECK,
             "Service Check " + StringUtils.join(m_servicesToCheck, ", "),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
index f2e8521..ac8b5dd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
@@ -76,6 +76,9 @@ public class ServiceCheckGrouping extends Grouping {
       m_metaInfo = ctx.getAmbariMetaInfo();
 
       List<StageWrapper> result = new ArrayList<StageWrapper>();
+      if (Direction.DOWNGRADE == ctx.getDirection()) {
+        return result;
+      }
 
       Map<String, Service> serviceMap = m_cluster.getServices();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
index 9bacd08..a8b3fc3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
@@ -235,6 +235,7 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
     columns.add(new DBAccessor.DBColumnInfo("request_id", Long.class, null, null, false));
     columns.add(new DBAccessor.DBColumnInfo("from_version", String.class, 255, "", false));
     columns.add(new DBAccessor.DBColumnInfo("to_version", String.class, 255, "", false));
+    columns.add(new DBAccessor.DBColumnInfo("direction", String.class, 255, "UPGRADE", false));
     dbAccessor.createTable("upgrade", columns, "upgrade_id");
     dbAccessor.addFKConstraint("upgrade", "fk_upgrade_cluster_id", "cluster_id", "clusters",
"cluster_id", false);
     dbAccessor.addFKConstraint("upgrade", "fk_upgrade_request_id", "request_id", "request",
"request_id", false);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/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 33e8b94..3e0d39e 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -717,6 +717,7 @@ CREATE TABLE upgrade (
   request_id BIGINT NOT NULL,
   from_version VARCHAR(255) DEFAULT '' NOT NULL,
   to_version VARCHAR(255) DEFAULT '' NOT NULL,
+  direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
   FOREIGN KEY (request_id) REFERENCES request(request_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/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 d29f920..2c33b37 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -707,6 +707,7 @@ CREATE TABLE upgrade (
   request_id NUMBER(19) NOT NULL,
   from_version VARCHAR2(255) DEFAULT '' NOT NULL,
   to_version VARCHAR2(255) DEFAULT '' NOT NULL,
+  direction VARCHAR2(255) DEFAULT 'UPGRADE' NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
   FOREIGN KEY (request_id) REFERENCES request(request_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/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 b589993..ff42074 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -704,6 +704,7 @@ CREATE TABLE upgrade (
   request_id BIGINT NOT NULL,
   from_version VARCHAR(255) DEFAULT '' NOT NULL,
   to_version VARCHAR(255) DEFAULT '' NOT NULL,
+  direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
   FOREIGN KEY (request_id) REFERENCES request(request_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 0bd637c..8f7a6ea 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -788,6 +788,7 @@ CREATE TABLE ambari.upgrade (
   request_id BIGINT NOT NULL,
   from_version VARCHAR(255) DEFAULT '' NOT NULL,
   to_version VARCHAR(255) DEFAULT '' NOT NULL,
+  direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES ambari.clusters(cluster_id),
   FOREIGN KEY (request_id) REFERENCES ambari.request(request_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/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 15f9399..f53d552 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -281,6 +281,7 @@ CREATE TABLE upgrade (
   request_id BIGINT NOT NULL,
   from_version VARCHAR(255) DEFAULT '' NOT NULL,
   to_version VARCHAR(255) DEFAULT '' NOT NULL,
+  direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
   PRIMARY KEY (upgrade_id),
   FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
   FOREIGN KEY (request_id) REFERENCES request(request_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 9a06b8c..00ba387 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -63,6 +63,7 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.easymock.EasyMock;
 import org.junit.After;
@@ -286,7 +287,8 @@ public class UpgradeResourceProviderTest {
     assertEquals(1, resources.size());
     res = resources.iterator().next();
     assertNotNull(res.getPropertyValue("Upgrade/progress_percent"));
-
+    assertNotNull(res.getPropertyValue("Upgrade/direction"));
+    assertEquals(Direction.UPGRADE, res.getPropertyValue("Upgrade/direction"));
 
     // upgrade groups
     propertyIds.clear();
@@ -392,7 +394,7 @@ public class UpgradeResourceProviderTest {
 
     UpgradeGroupEntity group = upgradeGroups.get(2);
     assertEquals("ZOOKEEPER", group.getName());
-    assertEquals(4, group.getItems().size());
+    assertEquals(3, group.getItems().size());
 
   }
 
@@ -441,6 +443,7 @@ public class UpgradeResourceProviderTest {
     assertNotNull(entity);
     assertEquals("2.1.1", entity.getFromVersion());
     assertEquals("2.2", entity.getToVersion());
+    assertEquals(Direction.DOWNGRADE, entity.getDirection());
 
     StageDAO dao = injector.getInstance(StageDAO.class);
     List<StageEntity> stages = dao.findByRequestId(entity.getRequestId());

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index 518f0f2..686cc6e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -169,9 +169,9 @@ public class UpgradeHelperTest {
     assertEquals(postGroup.items.get(2).getText(), "Save Cluster State");
     assertEquals(postGroup.items.get(2).getType(), StageWrapper.Type.SERVER_SIDE_ACTION);
 
-    assertEquals(9, groups.get(1).items.size());
-    assertEquals(8, groups.get(2).items.size());
-    assertEquals(6, groups.get(3).items.size());
+    assertEquals(7, groups.get(1).items.size());
+    assertEquals(7, groups.get(2).items.size());
+    assertEquals(5, groups.get(3).items.size());
   }
 
   @Test
@@ -223,7 +223,7 @@ public class UpgradeHelperTest {
 
 
   @Test
-  public void testServiceCheckStages() throws Exception {
+  public void testServiceCheckUpgradeStages() throws Exception {
 
     Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
     assertTrue(upgrades.containsKey("upgrade_test_checks"));
@@ -250,6 +250,35 @@ public class UpgradeHelperTest {
         manualTask.message);
   }
 
+  @Test
+  public void testServiceCheckDowngradeStages() throws Exception {
+
+    Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
+    assertTrue(upgrades.containsKey("upgrade_test_checks"));
+    UpgradePack upgrade = upgrades.get("upgrade_test_checks");
+    assertNotNull(upgrade);
+
+    makeCluster();
+
+    UpgradeContext context = new UpgradeContext(m_masterHostResolver,
+        DOWNGRADE_VERSION, Direction.DOWNGRADE);
+
+    List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgrade, context);
+
+    assertEquals(5, groups.size());
+
+    // grab the manual task out of ZK which has placeholder text
+
+    UpgradeGroupHolder zookeeperGroup = groups.get(3);
+    assertEquals("ZOOKEEPER", zookeeperGroup.name);
+    ManualTask manualTask = (ManualTask) zookeeperGroup.items.get(0).getTasks().get(
+        0).getTasks().get(0);
+
+    assertEquals(
+        "This is a manual task with a placeholder of placeholder-rendered-properly",
+        manualTask.message);
+  }
+
 
   /**
    * Create an HA cluster

http://git-wip-us.apache.org/repos/asf/ambari/blob/d88dfe6c/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index fd4f992..d6f9e6e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -290,7 +290,7 @@ public class UpgradeCatalog200Test {
     assertViewInstancePropertyColumns(valueColumnCapture);
     assertViewInstanceDataColumns(dataValueColumnCapture);
 
-    assertEquals(5, upgradeCapture.getValue().size());
+    assertEquals(6, upgradeCapture.getValue().size());
     assertEquals(4, upgradeGroupCapture.getValue().size());
     assertEquals(7, upgradeItemCapture.getValue().size());
   }


Mime
View raw message