eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: [MINOR] Fix unit test cases with ApplicationSimulator
Date Mon, 19 Dec 2016 15:13:18 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 12a0fb961 -> a34ef878a


[MINOR] Fix unit test cases with ApplicationSimulator


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

Branch: refs/heads/master
Commit: a34ef878a21dada05c8c297a4b66f93889361d50
Parents: 12a0fb9
Author: Hao Chen <hao@apache.org>
Authored: Mon Dec 19 23:10:26 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Mon Dec 19 23:13:15 2016 +0800

----------------------------------------------------------------------
 .../impl/ApplicationManagementServiceImpl.java    |  2 +-
 .../impl/ApplicationStatusUpdateServiceImpl.java  |  4 +++-
 .../eagle/app/test/ApplicationSimulatorImpl.java  | 18 +++++++++++++++++-
 .../auditlog/MapRFSAuditLogAppProviderTest.java   |  2 +-
 4 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a34ef878/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
index 96118aa..cd97496 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationManagementServiceImpl.java
@@ -161,7 +161,7 @@ public class ApplicationManagementServiceImpl implements ApplicationManagementSe
 
                 return applicationEntityService.delete(appEntity);
             } else {
-                throw new ApplicationWrongStatusException("App: " + appEntity.getAppId()
+ " status is" + currentStatus + ", uninstall operation is not allowed");
+                throw new ApplicationWrongStatusException("App: " + appEntity.getAppId()
+ " status is " + currentStatus + ", uninstall operation is not allowed");
             }
         } catch (Throwable throwable) {
             LOGGER.error(throwable.getMessage(), throwable);

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a34ef878/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
index a1ceb83..02c3a5e 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java
@@ -113,7 +113,9 @@ public class ApplicationStatusUpdateServiceImpl extends ApplicationStatusUpdateS
                     applicationEntityService.create(applicationEntity);
                 }
             }
-            //"STOPPED" is not used in Eagle, so just do nothing.
+            // "STOPPED" is not used in Eagle, so just do nothing.
+
+            applicationEntity.setStatus(topologyStatus);
         } catch (RuntimeException e) {
             LOG.error(e.getMessage(), e);
         }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a34ef878/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
index 51ee2cf..1b066ef 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java
@@ -75,7 +75,23 @@ public class ApplicationSimulatorImpl extends ApplicationSimulator {
         applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
         statusUpdateService.updateApplicationEntityStatus(applicationEntity);
         applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
-        statusUpdateService.updateApplicationEntityStatus(applicationEntity);
+        int attempt = 0;
+        while (attempt < 10) {
+            attempt++;
+            statusUpdateService.updateApplicationEntityStatus(applicationEntity);
+            if (applicationEntity.getStatus() == ApplicationEntity.Status.STOPPED) {
+                break;
+            } else {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    // Ignore
+                }
+            }
+        }
+        if (attempt >= 10 ) {
+            throw new IllegalStateException("Application status didn't become STOPPED in
10 attempts");
+        }
         applicationResource.uninstallApplication(new ApplicationOperations.UninstallOperation(applicationEntity.getUuid()));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a34ef878/eagle-security/eagle-security-maprfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/MapRFSAuditLogAppProviderTest.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-maprfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/MapRFSAuditLogAppProviderTest.java
b/eagle-security/eagle-security-maprfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/MapRFSAuditLogAppProviderTest.java
index 61d03f6..7474cf8 100644
--- a/eagle-security/eagle-security-maprfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/MapRFSAuditLogAppProviderTest.java
+++ b/eagle-security/eagle-security-maprfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/MapRFSAuditLogAppProviderTest.java
@@ -27,7 +27,7 @@ public class MapRFSAuditLogAppProviderTest extends ApplicationTestBase {
     ApplicationSimulator simulator;
 
     @Test
-    public void testStartAsManagedApplication(){
+    public void testStartAsManagedApplication() {
         simulator.start(MapRFSAuditLogAppProvider.class);
     }
 }
\ No newline at end of file


Mime
View raw message