ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [28/50] [abbrv] ambari git commit: AMBARI-22051 - VDFs Which Are Correct Never Get Resolved (jonathanhurley)
Date Tue, 26 Sep 2017 22:26:27 GMT
AMBARI-22051 -  VDFs Which Are Correct Never Get Resolved (jonathanhurley)


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

Branch: refs/heads/branch-3.0-ams
Commit: 08da9611188d9c4c246ee6d77894da5edf317860
Parents: 4b59ba8
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Mon Sep 25 10:11:52 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Mon Sep 25 12:36:44 2017 -0400

----------------------------------------------------------------------
 .../DistributeRepositoriesActionListener.java   |  7 ++++
 .../listeners/upgrade/StackVersionListener.java |  7 ++++
 .../upgrade/StackVersionListenerTest.java       | 41 ++++++++++++++++++++
 3 files changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/08da9611/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/DistributeRepositoriesActionListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/DistributeRepositoriesActionListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/DistributeRepositoriesActionListener.java
index 376e20d..1944761 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/DistributeRepositoriesActionListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/DistributeRepositoriesActionListener.java
@@ -127,6 +127,13 @@ public class DistributeRepositoriesActionListener {
             repoVersion.setResolved(true);
             repoVersionDAO.merge(repoVersion);
             repositoryVersion = actualVersion;
+          } else {
+            // the reported versions are the same - we should ensure that the
+            // repo is resolved
+            if (!repoVersion.isResolved()) {
+              repoVersion.setResolved(true);
+              repoVersionDAO.merge(repoVersion);
+            }
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/08da9611/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
index 0ce64bf..e5298dc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
@@ -101,6 +101,13 @@ public class StackVersionListener {
           rve.setVersion(newVersion);
           rve.setResolved(true);
           repositoryVersionDAO.merge(rve);
+        } else {
+          // the reported versions are the same - we should ensure that the repo
+          // is resolved
+          if (!rve.isResolved()) {
+            rve.setResolved(true);
+            repositoryVersionDAO.merge(rve);
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/08da9611/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
index 68d9c56..5e12cdf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
@@ -330,6 +330,47 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   /**
+   * Tests that if a component advertises a version and the repository already
+   * matches, that we ensure that it is marked as resolved.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testRepositoryResolvedWhenVersionsMatch() throws Exception {
+    String version = "2.4.0.0";
+
+    expect(sch.getVersion()).andReturn(version);
+    expect(componentInfo.isVersionAdvertised()).andReturn(true).once();
+
+    RepositoryVersionDAO dao = createNiceMock(RepositoryVersionDAO.class);
+    RepositoryVersionEntity entity = createNiceMock(RepositoryVersionEntity.class);
+    expect(entity.getVersion()).andReturn(version).once();
+    expect(entity.isResolved()).andReturn(false).once();
+
+    // when the version gets reported back, we set this repo to resolved
+    entity.setResolved(true);
+    expectLastCall().once();
+
+    expect(dao.findByPK(1L)).andReturn(entity).once();
+    expect(dao.merge(entity)).andReturn(entity).once();
+
+    replayAll();
+
+    String newVersion = version;
+
+    HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cluster,
sch, newVersion, 1L);
+    
+    // !!! avoid injector for test class
+    Field field = StackVersionListener.class.getDeclaredField("repositoryVersionDAO");
+    field.setAccessible(true);
+    field.set(listener, dao);
+
+    listener.onAmbariEvent(event);
+
+    verifyAll();
+  }
+
+  /**
    * Tests that the {@link RepositoryVersionEntity} is not updated if there is
    * an upgrade, even if the repo ID is passed back and the versions don't
    * match.


Mime
View raw message