You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2016/06/03 10:12:23 UTC

[2/2] ambari git commit: AMBARI-17026 NPE during EU at Update Target Stack step (dlysnichenko)

AMBARI-17026 NPE during EU at Update Target Stack step (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: e3f6ec7a1f2876007ecd6b4a30ba25c561e2729e
Parents: 7038957
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Fri Jun 3 13:11:17 2016 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Fri Jun 3 13:11:59 2016 +0300

----------------------------------------------------------------------
 .../ambari/server/state/PropertyInfo.java       | 10 +++++++-
 .../ambari/server/state/PropertyInfoTest.java   | 27 ++++++++++++++++++--
 2 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3f6ec7a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
index 6ea7983..fba2daa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
@@ -89,7 +89,15 @@ public class PropertyInfo {
   }
 
   public PropertyInfo() {
-
+    propertyStackUpgradeBehavior = new PropertyUpgradeBehavior();
+    propertyStackUpgradeBehavior.setAdd(true);
+    propertyStackUpgradeBehavior.setChange(true);
+    propertyStackUpgradeBehavior.setDelete(false);
+
+    propertyAmbariUpgradeBehavior = new PropertyUpgradeBehavior();
+    propertyAmbariUpgradeBehavior.setAdd(false);
+    propertyAmbariUpgradeBehavior.setChange(true);
+    propertyAmbariUpgradeBehavior.setDelete(true);
   }
 
   public String getName() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3f6ec7a/ambari-server/src/test/java/org/apache/ambari/server/state/PropertyInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/PropertyInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/PropertyInfoTest.java
index e55058f..9a3d195 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/PropertyInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/PropertyInfoTest.java
@@ -103,14 +103,37 @@ public class PropertyInfoTest {
       "<property>\n" +
       "  <name>prop_name</name>\n" +
       "  <value>prop_val</value>\n" +
-      "  <on-ambari-upgrade add=\"false\" change=\"true\" delete=\"true\"/>\n" +
-      "  <on-stack-upgrade add=\"true\" change=\"true\" delete=\"false\"/>\n" +
+      "  <on-ambari-upgrade add=\"true\" change=\"true\" delete=\"true\"/>\n" +
+      "  <on-stack-upgrade add=\"false\" change=\"false\" delete=\"false\"/>\n" +
       "</property>";
 
     // when
     PropertyInfo propertyInfo = propertyInfoFrom(xml);
 
     // then
+    assertTrue(propertyInfo.getPropertyAmbariUpgradeBehavior().isAdd());
+    assertTrue(propertyInfo.getPropertyAmbariUpgradeBehavior().isChange());
+    assertTrue(propertyInfo.getPropertyAmbariUpgradeBehavior().isDelete());
+
+    assertFalse(propertyInfo.getPropertyStackUpgradeBehavior().isAdd());
+    assertFalse(propertyInfo.getPropertyStackUpgradeBehavior().isChange());
+    assertFalse(propertyInfo.getPropertyStackUpgradeBehavior().isDelete());
+  }
+
+  @Test
+  public void testBehaviorWithoutUpgradeTags() throws JAXBException {
+    // given
+    String xml =
+        "<property>\n" +
+            "  <name>prop_name</name>\n" +
+            "  <value>prop_val</value>\n" +
+            "</property>";
+
+    // when
+    PropertyInfo propertyInfo = propertyInfoFrom(xml);
+
+    // then
+
     assertFalse(propertyInfo.getPropertyAmbariUpgradeBehavior().isAdd());
     assertTrue(propertyInfo.getPropertyAmbariUpgradeBehavior().isChange());
     assertTrue(propertyInfo.getPropertyAmbariUpgradeBehavior().isDelete());