You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2017/02/18 07:14:08 UTC

eagle git commit: [MINOR] Fix TestHdfsAuditLogApplication by support await RUNNING

Repository: eagle
Updated Branches:
  refs/heads/master 71522d956 -> db26c1cf1


[MINOR] Fix TestHdfsAuditLogApplication by support await RUNNING

Fix TestHdfsAuditLogApplication by supporting await RUNNING

Resolve Exception: App: HDFS_AUDIT_LOG_MONITOR_APP_TEST_SITE status is STOPPING, uninstall operation is not allowed

Author: Hao Chen <ha...@apache.org>

Closes #818 from haoch/FixTestHdfsAuditLogApplication.


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

Branch: refs/heads/master
Commit: db26c1cf140e2bd6bb2961de33cd57a3825800e3
Parents: 71522d9
Author: Hao Chen <ha...@apache.org>
Authored: Sat Feb 18 15:13:49 2017 +0800
Committer: Hao Chen <ha...@apache.org>
Committed: Sat Feb 18 15:13:49 2017 +0800

----------------------------------------------------------------------
 .../eagle/app/test/ApplicationTestBase.java     | 134 +++++++++++--------
 .../auditlog/TestHdfsAuditLogApplication.java   |   4 +-
 2 files changed, 76 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/db26c1cf/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java
index 52b8e79..e93df64 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java
@@ -1,60 +1,76 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.app.test;
-
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.eagle.metadata.model.ApplicationEntity;
-import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
-import org.junit.Assert;
-import org.junit.Before;
-
-public class ApplicationTestBase {
-    private Injector injector;
-
-
-    @Inject
-    ApplicationStatusUpdateService statusUpdateService;
-
-    @Before
-    public void setUp() {
-        injector = Guice.createInjector(new ApplicationTestGuiceModule());
-        injector.injectMembers(this);
-    }
-
-    protected Injector injector() {
-        return injector;
-    }
-
-    protected void awaitApplicationStop(ApplicationEntity applicationEntity) throws InterruptedException {
-        int attempt = 0;
-        while (attempt < 10) {
-            attempt ++;
-            if (applicationEntity.getStatus() == ApplicationEntity.Status.STOPPED
-                    || applicationEntity.getStatus() == ApplicationEntity.Status.INITIALIZED) {
-                break;
-            } else {
-                statusUpdateService.updateApplicationEntityStatus(applicationEntity);
-                Thread.sleep(1000);
-            }
-        }
-        if (attempt > 10) {
-            Assert.fail("Failed to wait for application to STOPPED after 10 attempts");
-        }
-    }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.app.test;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import org.apache.eagle.metadata.model.ApplicationEntity;
+import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
+import org.junit.Assert;
+import org.junit.Before;
+
+public class ApplicationTestBase {
+    private Injector injector;
+
+
+    @Inject
+    ApplicationStatusUpdateService statusUpdateService;
+
+    @Before
+    public void setUp() {
+        injector = Guice.createInjector(new ApplicationTestGuiceModule());
+        injector.injectMembers(this);
+    }
+
+    protected Injector injector() {
+        return injector;
+    }
+
+    protected void awaitApplicationStop(ApplicationEntity applicationEntity) throws InterruptedException {
+        int attempt = 0;
+        while (attempt < 30) {
+            attempt ++;
+            if (applicationEntity.getStatus() == ApplicationEntity.Status.STOPPED
+                    || applicationEntity.getStatus() == ApplicationEntity.Status.INITIALIZED) {
+                break;
+            } else {
+                statusUpdateService.updateApplicationEntityStatus(applicationEntity);
+                Thread.sleep(1000);
+            }
+        }
+        if (attempt >= 30) {
+            Assert.fail("Failed to wait for application to STOPPED after 10 attempts");
+        }
+    }
+
+    protected void awaitApplicationStatus(ApplicationEntity applicationEntity, ApplicationEntity.Status status) throws InterruptedException {
+        int attempt = 0;
+        while (attempt < 30) {
+            attempt ++;
+            if (applicationEntity.getStatus() == status) {
+                break;
+            } else {
+                statusUpdateService.updateApplicationEntityStatus(applicationEntity);
+                Thread.sleep(1000);
+            }
+        }
+        if (attempt >= 30) {
+            Assert.fail("Failed to wait for application to STOPPED after 10 attempts");
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/eagle/blob/db26c1cf/eagle-security/eagle-security-hdfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/TestHdfsAuditLogApplication.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-hdfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/TestHdfsAuditLogApplication.java b/eagle-security/eagle-security-hdfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/TestHdfsAuditLogApplication.java
index 5e76fd8..67f2825 100644
--- a/eagle-security/eagle-security-hdfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/TestHdfsAuditLogApplication.java
+++ b/eagle-security/eagle-security-hdfs-auditlog/src/test/java/org/apache/eagle/security/auditlog/TestHdfsAuditLogApplication.java
@@ -38,8 +38,6 @@ public class TestHdfsAuditLogApplication extends ApplicationTestBase {
     private SiteResource siteResource;
     @Inject
     private ApplicationResource applicationResource;
-    @Inject
-    ApplicationStatusUpdateService statusUpdateService;
 
     @Test
     public void testHdfsAuditLogApplication() throws InterruptedException {
@@ -57,7 +55,7 @@ public class TestHdfsAuditLogApplication extends ApplicationTestBase {
         ApplicationEntity applicationEntity = applicationResource.installApplication(installOperation).getData();
         // Start application
         applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
-        statusUpdateService.updateApplicationEntityStatus(applicationEntity);
+        awaitApplicationStatus(applicationEntity, ApplicationEntity.Status.RUNNING);
         // Stop application
         applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
         awaitApplicationStop(applicationEntity);