azkaban-developers

Move TestUtils#await to the 'test' module (#1474) This allows

9/18/2017 2:20:14 PM

Details

diff --git a/azkaban-common/src/test/java/azkaban/executor/ExecutorManagerTest.java b/azkaban-common/src/test/java/azkaban/executor/ExecutorManagerTest.java
index 666dfc3..086c76f 100644
--- a/azkaban-common/src/test/java/azkaban/executor/ExecutorManagerTest.java
+++ b/azkaban-common/src/test/java/azkaban/executor/ExecutorManagerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 LinkedIn Corp.
+ * Copyright 2017 LinkedIn Corp.
  *
  * Licensed 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
@@ -388,7 +388,7 @@ public class ExecutorManagerTest {
   }
 
   private ExecutableFlow waitFlowFinished(final ExecutableFlow flow) throws Exception {
-    TestUtils.await().untilAsserted(() -> assertThat(getFlowStatus(flow))
+    azkaban.test.TestUtils.await().untilAsserted(() -> assertThat(getFlowStatus(flow))
         .matches(Status::isStatusFinished, "isStatusFinished"));
     return fetchFlow(flow);
   }
diff --git a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
index aa66d9a..6aae322 100644
--- a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
+++ b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 LinkedIn Corp.
+ * Copyright 2017 LinkedIn Corp.
  *
  * Licensed 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
@@ -26,9 +26,6 @@ import azkaban.user.XmlUserManager;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.concurrent.TimeUnit;
-import org.awaitility.Awaitility;
-import org.awaitility.core.ConditionFactory;
 
 /**
  * Commonly used utils method for unit/integration tests
@@ -69,12 +66,4 @@ public class TestUtils {
     return manager;
   }
 
-  /**
-   * Wait for 10 seconds, max. Poll every 10ms.
-   */
-  public static ConditionFactory await() {
-    return Awaitility.await().atMost(10L, TimeUnit.SECONDS)
-        .pollInterval(10L, TimeUnit.MILLISECONDS);
-  }
-
 }
diff --git a/azkaban-exec-server/src/test/java/azkaban/execapp/JobRunnerTest.java b/azkaban-exec-server/src/test/java/azkaban/execapp/JobRunnerTest.java
index 217d0a5..ea46cef 100644
--- a/azkaban-exec-server/src/test/java/azkaban/execapp/JobRunnerTest.java
+++ b/azkaban-exec-server/src/test/java/azkaban/execapp/JobRunnerTest.java
@@ -31,7 +31,6 @@ import azkaban.jobtype.JobTypeManager;
 import azkaban.jobtype.JobTypePluginSet;
 import azkaban.spi.EventType;
 import azkaban.utils.Props;
-import azkaban.utils.TestUtils;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
@@ -315,7 +314,7 @@ public class JobRunnerTest {
     Assert.assertTrue(logFile.exists());
 
     // wait so that there's time to make the "DB update" for KILLED status
-    TestUtils.await().untilAsserted(
+    azkaban.test.TestUtils.await().untilAsserted(
         () -> assertThat(loader.getNodeUpdateCount("testJob")).isEqualTo(2));
     eventCollector.assertEvents(EventType.JOB_FINISHED);
   }

test/build.gradle 21(+21 -0)

diff --git a/test/build.gradle b/test/build.gradle
index 305985c..784c371 100644
--- a/test/build.gradle
+++ b/test/build.gradle
@@ -1,3 +1,24 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
 jar {
     baseName = 'azkaban-test'
 }
+
+dependencies {
+    compile deps.awaitility
+    compile deps.assertj
+}
diff --git a/test/src/main/java/azkaban/test/TestUtils.java b/test/src/main/java/azkaban/test/TestUtils.java
new file mode 100644
index 0000000..823c695
--- /dev/null
+++ b/test/src/main/java/azkaban/test/TestUtils.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 azkaban.test;
+
+import java.util.concurrent.TimeUnit;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
+
+/**
+ * Common test utility methods.
+ */
+public class TestUtils {
+
+
+  /**
+   * Wait for 10 seconds, max. Poll every 10ms.
+   */
+  public static ConditionFactory await() {
+    return Awaitility.await().atMost(10L, TimeUnit.SECONDS)
+        .pollInterval(10L, TimeUnit.MILLISECONDS);
+  }
+}