ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [37/50] [abbrv] ambari git commit: AMBARI-13457: RU API Enhancement: Add handsfree execution mode (jluniya)
Date Mon, 19 Oct 2015 13:54:23 GMT
AMBARI-13457: RU API Enhancement: Add handsfree execution mode (jluniya)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: f6ff71b8cb4d9d2b5dc0acd98eb8d27865302cc8
Parents: d8d1926
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Fri Oct 16 14:53:41 2015 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Fri Oct 16 14:53:41 2015 -0700

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       |  30 +++--
 .../ambari/server/state/UpgradeContext.java     |  25 +++-
 .../internal/UpgradeResourceProviderTest.java   | 123 ++++++++++++++++++-
 3 files changed, 165 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f6ff71b8/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 109f29b..3a52025 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
@@ -139,6 +139,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    */
   protected static final String UPGRADE_SKIP_SC_FAILURES = "Upgrade/skip_service_check_failures";
 
+  /**
+   * Skip manual verification tasks for hands-free upgrade/downgrade experience.
+   */
+  protected static final String UPGRADE_SKIP_MANUAL_VERIFICATION = "Upgrade/skip_manual_verification";
+
   /*
    * Lifted from RequestResourceProvider
    */
@@ -235,6 +240,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     PROPERTY_IDS.add(UPGRADE_DIRECTION);
     PROPERTY_IDS.add(UPGRADE_SKIP_FAILURES);
     PROPERTY_IDS.add(UPGRADE_SKIP_SC_FAILURES);
+    PROPERTY_IDS.add(UPGRADE_SKIP_MANUAL_VERIFICATION);
     PROPERTY_IDS.add(UPGRADE_SKIP_PREREQUISITE_CHECKS);
     PROPERTY_IDS.add(UPGRADE_FAIL_ON_CHECK_WARNINGS);
 
@@ -473,8 +479,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     String clusterName = (String) requestMap.get(UPGRADE_CLUSTER_NAME);
     String version = (String) requestMap.get(UPGRADE_VERSION);
     String versionForUpgradePack = (String) requestMap.get(UPGRADE_FROM_VERSION);
-    boolean skipPrereqChecks = Boolean.parseBoolean((String) requestMap.get(UPGRADE_SKIP_PREREQUISITE_CHECKS));
-    boolean failOnCheckWarnings = Boolean.parseBoolean((String) requestMap.get(UPGRADE_FAIL_ON_CHECK_WARNINGS));
 
     /**
      * For the unit tests tests, there are multiple upgrade packs for the same type, so
@@ -683,8 +687,14 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
           (String) requestMap.get(UPGRADE_SKIP_SC_FAILURES));
     }
 
+    boolean skipManualVerification = false;
+    if(requestMap.containsKey(UPGRADE_SKIP_MANUAL_VERIFICATION)) {
+      skipManualVerification = Boolean.parseBoolean((String) requestMap.get(UPGRADE_SKIP_MANUAL_VERIFICATION));
+    }
+
     ctx.setAutoSkipComponentFailures(skipComponentFailures);
     ctx.setAutoSkipServiceCheckFailures(skipServiceCheckFailures);
+    ctx.setAutoSkipManualVerification(skipManualVerification);
 
     List<UpgradeGroupHolder> groups = s_upgradeHelper.createSequence(pack, ctx);
 
@@ -730,14 +740,10 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     }
 
     for (UpgradeGroupHolder group : groups) {
-      UpgradeGroupEntity groupEntity = new UpgradeGroupEntity();
-      groupEntity.setName(group.name);
-      groupEntity.setTitle(group.title);
       boolean skippable = group.skippable;
       boolean allowRetry = group.allowRetry;
 
       List<UpgradeItemEntity> itemEntities = new ArrayList<UpgradeItemEntity>();
-
       for (StageWrapper wrapper : group.items) {
         if (wrapper.getType() == StageWrapper.Type.SERVER_SIDE_ACTION) {
           // !!! each stage is guaranteed to be of one type. but because there
@@ -745,6 +751,9 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
           // the same host, break them out into individual stages.
           for (TaskWrapper taskWrapper : wrapper.getTasks()) {
             for (Task task : taskWrapper.getTasks()) {
+              if(ctx.isManualVerificationAutoSkipped() && task.getType() == Task.Type.MANUAL)
{
+                continue;
+              }
               UpgradeItemEntity itemEntity = new UpgradeItemEntity();
               itemEntity.setText(wrapper.getText());
               itemEntity.setTasks(wrapper.getTasksJson());
@@ -777,8 +786,13 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         }
       }
 
-      groupEntity.setItems(itemEntities);
-      groupEntities.add(groupEntity);
+      if(!itemEntities.isEmpty()) {
+        UpgradeGroupEntity groupEntity = new UpgradeGroupEntity();
+        groupEntity.setName(group.name);
+        groupEntity.setTitle(group.title);
+        groupEntity.setItems(itemEntities);
+        groupEntities.add(groupEntity);
+      }
     }
 
     UpgradeEntity entity = new UpgradeEntity();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f6ff71b8/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index 7f307cf..a856ffc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -80,6 +80,11 @@ public class UpgradeContext {
   private boolean m_autoSkipServiceCheckFailures = false;
 
   /**
+   * {@code true} if manual verification tasks should be automatically skipped.
+   */
+  private boolean m_autoSkipManualVerification = false;
+
+  /**
    * Constructor.
    *
    * @param resolver
@@ -313,7 +318,7 @@ public class UpgradeContext {
   /**
    * Sets whether skippable components that failed are automatically skipped.
    *
-   * @param skipComponentFailures
+   * @param autoSkipComponentFailures
    *          {@code true} to automatically skip component failures which are
    *          marked as skippable.
    */
@@ -343,4 +348,22 @@ public class UpgradeContext {
     m_autoSkipServiceCheckFailures = autoSkipServiceCheckFailures;
   }
 
+  /**
+   * Gets whether manual verification tasks can be automatically skipped.
+   *
+   * @return the skipManualVerification
+   */
+  public boolean isManualVerificationAutoSkipped() {
+    return m_autoSkipManualVerification;
+  }
+
+  /**
+   * Sets whether manual verification checks are automatically skipped.
+   *
+   * @param autoSkipManualVerification
+   *          {@code true} to automatically skip manual verification tasks.
+   */
+  public void setAutoSkipManualVerification(boolean autoSkipManualVerification) {
+    m_autoSkipManualVerification = autoSkipManualVerification;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f6ff71b8/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 d6091a3..d79eab6 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
@@ -235,7 +235,6 @@ public class UpgradeResourceProviderTest {
   }
 
   @Test
-  @Ignore
   public void testCreateResourcesWithAutoSkipFailures() throws Exception {
     Cluster cluster = clusters.getCluster("c1");
 
@@ -246,6 +245,7 @@ public class UpgradeResourceProviderTest {
     requestProps.put(UpgradeResourceProvider.UPGRADE_TYPE, UpgradeType.ROLLING.toString());
     requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, Boolean.TRUE.toString());
     requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_MANUAL_VERIFICATION, Boolean.FALSE.toString());
     requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, Boolean.TRUE.toString());
 
     ResourceProvider upgradeResourceProvider = createProvider(amc);
@@ -261,15 +261,130 @@ public class UpgradeResourceProviderTest {
     List<UpgradeGroupEntity> upgradeGroups = entity.getUpgradeGroups();
     assertEquals(3, upgradeGroups.size());
 
+    UpgradeGroupEntity preClusterGroup = upgradeGroups.get(0);
+    assertEquals("PRE_CLUSTER", preClusterGroup.getName());
+
+    List<UpgradeItemEntity> preClusterUpgradeItems = preClusterGroup.getItems();
+    assertEquals(2, preClusterUpgradeItems.size());
+    assertEquals("Foo", preClusterUpgradeItems.get(0).getText());
+    assertEquals("Foo", preClusterUpgradeItems.get(1).getText());
+
     UpgradeGroupEntity zookeeperGroup = upgradeGroups.get(1);
     assertEquals("ZOOKEEPER", zookeeperGroup.getName());
 
-    List<UpgradeItemEntity> upgradeItems = zookeeperGroup.getItems();
-    assertEquals(5, upgradeItems.size());
+    List<UpgradeItemEntity> zookeeperUpgradeItems = zookeeperGroup.getItems();
+    assertEquals(5, zookeeperUpgradeItems.size());
+
+    assertEquals("This is a manual task with a placeholder of placeholder-rendered-properly",
+        zookeeperUpgradeItems.get(0).getText());
+    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(1).getText());
+    assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(2).getText());
+    assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(3).getText());
+    assertEquals("Verifying Skipped Failures", zookeeperUpgradeItems.get(4).getText());
+
+    // the last upgrade item is the skipped failure check
+    UpgradeItemEntity skippedFailureCheck = zookeeperUpgradeItems.get(zookeeperUpgradeItems.size()
- 1);
+    skippedFailureCheck.getTasks().contains(AutoSkipFailedSummaryAction.class.getName());
+
+    UpgradeGroupEntity postClusterGroup = upgradeGroups.get(2);
+    assertEquals("POST_CLUSTER", postClusterGroup.getName());
+
+    List<UpgradeItemEntity> postClusterUpgradeItems = postClusterGroup.getItems();
+    assertEquals(2, postClusterUpgradeItems.size());
+    assertEquals("Please confirm you are ready to finalize", postClusterUpgradeItems.get(0).getText());
+    assertEquals("Save Cluster State", postClusterUpgradeItems.get(1).getText());
+  }
+
+  @Test
+  public void testCreateResourcesWithAutoSkipManualVerification() throws Exception {
+    Cluster cluster = clusters.getCluster("c1");
+
+    Map<String, Object> requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_test");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_TYPE, UpgradeType.ROLLING.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_MANUAL_VERIFICATION, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, Boolean.TRUE.toString());
+
+    ResourceProvider upgradeResourceProvider = createProvider(amc);
+    Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps),
null);
+    upgradeResourceProvider.createResources(request);
+
+    List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
+    assertEquals(1, upgrades.size());
+
+    UpgradeEntity entity = upgrades.get(0);
+    assertEquals(cluster.getClusterId(), entity.getClusterId().longValue());
+
+    List<UpgradeGroupEntity> upgradeGroups = entity.getUpgradeGroups();
+    assertEquals(2, upgradeGroups.size());
+
+    UpgradeGroupEntity zookeeperGroup = upgradeGroups.get(0);
+    assertEquals("ZOOKEEPER", zookeeperGroup.getName());
+
+    List<UpgradeItemEntity> zookeeperUpgradeItems = zookeeperGroup.getItems();
+    assertEquals(3, zookeeperUpgradeItems.size());
+    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(0).getText());
+    assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(1).getText());
+    assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(2).getText());
+
+    UpgradeGroupEntity postClusterGroup = upgradeGroups.get(1);
+    assertEquals("POST_CLUSTER", postClusterGroup.getName());
+
+    List<UpgradeItemEntity> postClusterUpgradeItems = postClusterGroup.getItems();
+    assertEquals(1, postClusterUpgradeItems.size());
+    assertEquals("Save Cluster State", postClusterUpgradeItems.get(0).getText());
+  }
+
+  @Test
+  public void testCreateResourcesWithAutoSkipAll() throws Exception {
+    Cluster cluster = clusters.getCluster("c1");
+
+    Map<String, Object> requestProps = new HashMap<String, Object>();
+    requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_test");
+    requestProps.put(UpgradeResourceProvider.UPGRADE_TYPE, UpgradeType.ROLLING.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_MANUAL_VERIFICATION, Boolean.TRUE.toString());
+    requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, Boolean.TRUE.toString());
+
+    ResourceProvider upgradeResourceProvider = createProvider(amc);
+    Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps),
null);
+    upgradeResourceProvider.createResources(request);
+
+    List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
+    assertEquals(1, upgrades.size());
+
+    UpgradeEntity entity = upgrades.get(0);
+    assertEquals(cluster.getClusterId(), entity.getClusterId().longValue());
+
+    List<UpgradeGroupEntity> upgradeGroups = entity.getUpgradeGroups();
+    assertEquals(2, upgradeGroups.size());
+
+    UpgradeGroupEntity zookeeperGroup = upgradeGroups.get(0);
+    assertEquals("ZOOKEEPER", zookeeperGroup.getName());
+
+    List<UpgradeItemEntity> zookeeperUpgradeItems = zookeeperGroup.getItems();
+    assertEquals(4, zookeeperUpgradeItems.size());
+
+    assertEquals("Restarting ZooKeeper Server on h1", zookeeperUpgradeItems.get(0).getText());
+    assertEquals("Skipping Configuration Task", zookeeperUpgradeItems.get(1).getText());
+    assertEquals("Service Check ZooKeeper", zookeeperUpgradeItems.get(2).getText());
+    assertEquals("Verifying Skipped Failures", zookeeperUpgradeItems.get(3).getText());
 
     // the last upgrade item is the skipped failure check
-    UpgradeItemEntity skippedFailureCheck = upgradeItems.get(upgradeItems.size() - 1);
+    UpgradeItemEntity skippedFailureCheck = zookeeperUpgradeItems.get(zookeeperUpgradeItems.size()
- 1);
     skippedFailureCheck.getTasks().contains(AutoSkipFailedSummaryAction.class.getName());
+
+    UpgradeGroupEntity postClusterGroup = upgradeGroups.get(1);
+    assertEquals("POST_CLUSTER", postClusterGroup.getName());
+
+    List<UpgradeItemEntity> postClusterUpgradeItems = postClusterGroup.getItems();
+    assertEquals(1, postClusterUpgradeItems.size());
+    assertEquals("Save Cluster State", postClusterUpgradeItems.get(0).getText());
   }
 
   @Ignore


Mime
View raw message