azkaban-aplcache
Changes
azkaban-common/build.gradle 2(+1 -1)
Details
azkaban-common/build.gradle 2(+1 -1)
diff --git a/azkaban-common/build.gradle b/azkaban-common/build.gradle
index 967fe24..35c9e0c 100644
--- a/azkaban-common/build.gradle
+++ b/azkaban-common/build.gradle
@@ -66,7 +66,7 @@ dependencies {
testRuntime deps.h2
- testCompile(project(':test').sourceSets.test.output)
+ testCompile project(':test')
testCompile project(':azkaban-db').sourceSets.test.output
}
diff --git a/azkaban-common/src/test/java/azkaban/executor/ExecutableFlowTest.java b/azkaban-common/src/test/java/azkaban/executor/ExecutableFlowTest.java
index b4ee1f1..cbca048 100644
--- a/azkaban-common/src/test/java/azkaban/executor/ExecutableFlowTest.java
+++ b/azkaban-common/src/test/java/azkaban/executor/ExecutableFlowTest.java
@@ -20,7 +20,7 @@ import azkaban.executor.ExecutionOptions.FailureAction;
import azkaban.flow.Flow;
import azkaban.project.DirectoryFlowLoader;
import azkaban.project.Project;
-import azkaban.test.executions.TestExecutions;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.utils.JSONUtils;
import azkaban.utils.Props;
import java.util.Arrays;
@@ -212,7 +212,7 @@ public class ExecutableFlowTest {
final Logger logger = Logger.getLogger(this.getClass());
final DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
- loader.loadProjectFlow(this.project, TestExecutions.getFlowDir("embedded"));
+ loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir("embedded"));
Assert.assertEquals(0, loader.getErrors().size());
this.project.setFlows(loader.getFlowMap());
diff --git a/azkaban-common/src/test/java/azkaban/executor/JdbcExecutorLoaderTest.java b/azkaban-common/src/test/java/azkaban/executor/JdbcExecutorLoaderTest.java
index d60cb34..1552742 100644
--- a/azkaban-common/src/test/java/azkaban/executor/JdbcExecutorLoaderTest.java
+++ b/azkaban-common/src/test/java/azkaban/executor/JdbcExecutorLoaderTest.java
@@ -20,6 +20,7 @@ import azkaban.database.DataSourceUtils;
import azkaban.executor.ExecutorLogEvent.EventType;
import azkaban.metrics.CommonMetrics;
import azkaban.metrics.MetricsManager;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.user.User;
import azkaban.utils.FileIOUtils.LogData;
import azkaban.utils.Pair;
@@ -50,9 +51,8 @@ import org.junit.Test;
public class JdbcExecutorLoaderTest {
- /* Directory with serialized description of test flows */
- private static final String UNIT_BASE_DIR =
- "../test/src/test/resources/azkaban/test/executions";
+ private static final String LOG_TEST_DIR_NAME = "logtest";
+
// @TODO remove this and turn into local host.
private static final String host = "localhost";
private static final int port = 3306;
@@ -298,7 +298,7 @@ public class JdbcExecutorLoaderTest {
final ExecutableFlow flow = createExecutableFlow(10, "exec1");
flow.setExecutionId(10);
- final File jobFile = new File(UNIT_BASE_DIR + "/exectest1", "job10.job");
+ final File jobFile = ExecutionsTestUtil.getFlowFile("exectest1", "job10.job");
final Props props = new Props(null, jobFile);
props.put("test", "test2");
final ExecutableNode oldNode = flow.getExecutableNode("job10");
@@ -944,7 +944,7 @@ public class JdbcExecutorLoaderTest {
@Ignore
@Test
public void testSmallUploadLog() throws ExecutorManagerException {
- final File logDir = new File(UNIT_BASE_DIR + "logtest");
+ final File logDir = ExecutionsTestUtil.getFlowDir(LOG_TEST_DIR_NAME);
final File[] smalllog =
{new File(logDir, "log1.log"), new File(logDir, "log2.log"),
new File(logDir, "log3.log")};
@@ -970,7 +970,7 @@ public class JdbcExecutorLoaderTest {
@Ignore
@Test
public void testLargeUploadLog() throws ExecutorManagerException {
- final File logDir = new File(UNIT_BASE_DIR + "logtest");
+ final File logDir = ExecutionsTestUtil.getFlowDir(LOG_TEST_DIR_NAME);
// Multiple of 255 for Henry the Eigth
final File[] largelog =
@@ -1016,7 +1016,7 @@ public class JdbcExecutorLoaderTest {
final ExecutorLoader loader = createLoader();
- final File logDir = new File(UNIT_BASE_DIR + "logtest");
+ final File logDir = ExecutionsTestUtil.getFlowDir(LOG_TEST_DIR_NAME);
// Multiple of 255 for Henry the Eigth
final File[] largelog =
diff --git a/azkaban-common/src/test/java/azkaban/project/DirectoryFlowLoaderTest.java b/azkaban-common/src/test/java/azkaban/project/DirectoryFlowLoaderTest.java
index f1e148c..b3057f6 100644
--- a/azkaban-common/src/test/java/azkaban/project/DirectoryFlowLoaderTest.java
+++ b/azkaban-common/src/test/java/azkaban/project/DirectoryFlowLoaderTest.java
@@ -16,7 +16,7 @@
package azkaban.project;
-import azkaban.test.executions.TestExecutions;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.utils.Props;
import java.net.URISyntaxException;
import org.apache.log4j.Logger;
@@ -38,7 +38,7 @@ public class DirectoryFlowLoaderTest {
final Logger logger = Logger.getLogger(this.getClass());
final DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
- loader.loadProjectFlow(this.project, TestExecutions.getFlowDir("exectest1"));
+ loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir("exectest1"));
logger.info(loader.getFlowMap().size());
}
@@ -47,7 +47,7 @@ public class DirectoryFlowLoaderTest {
final Logger logger = Logger.getLogger(this.getClass());
final DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
- loader.loadProjectFlow(this.project, TestExecutions.getFlowDir("embedded"));
+ loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir("embedded"));
Assert.assertEquals(0, loader.getErrors().size());
}
@@ -56,7 +56,7 @@ public class DirectoryFlowLoaderTest {
final Logger logger = Logger.getLogger(this.getClass());
final DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
- loader.loadProjectFlow(this.project, TestExecutions.getFlowDir("embedded_bad"));
+ loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir("embedded_bad"));
for (final String error : loader.getErrors()) {
System.out.println(error);
}
diff --git a/azkaban-common/src/test/java/azkaban/utils/EmailerTest.java b/azkaban-common/src/test/java/azkaban/utils/EmailerTest.java
index 8a05bc0..fa8f430 100644
--- a/azkaban-common/src/test/java/azkaban/utils/EmailerTest.java
+++ b/azkaban-common/src/test/java/azkaban/utils/EmailerTest.java
@@ -21,7 +21,7 @@ import azkaban.metrics.CommonMetrics;
import azkaban.metrics.MetricsManager;
import azkaban.project.DirectoryFlowLoader;
import azkaban.project.Project;
-import azkaban.test.executions.TestExecutions;
+import azkaban.test.executions.ExecutionsTestUtil;
import com.codahale.metrics.MetricRegistry;
import java.util.ArrayList;
import java.util.List;
@@ -55,7 +55,7 @@ public class EmailerTest {
this.props = createMailProperties();
final DirectoryFlowLoader loader = new DirectoryFlowLoader(this.props, logger);
- loader.loadProjectFlow(this.project, TestExecutions.getFlowDir("embedded"));
+ loader.loadProjectFlow(this.project, ExecutionsTestUtil.getFlowDir("embedded"));
Assert.assertEquals(0, loader.getErrors().size());
this.project.setFlows(loader.getFlowMap());
this.project.setVersion(123);
diff --git a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
index ecea38d..4c3db69 100644
--- a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
+++ b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
@@ -19,6 +19,7 @@ package azkaban.utils;
import azkaban.executor.ExecutableFlow;
import azkaban.flow.Flow;
import azkaban.project.Project;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.user.User;
import azkaban.user.UserManager;
import azkaban.user.XmlUserManager;
@@ -31,16 +32,8 @@ import java.util.HashMap;
*/
public class TestUtils {
- /* Base resource direcotyr for unit tests */
- private static final String UNIT_RESOURCE_DIR =
- "../test/src/test/resources/azkaban/test";
- /* Directory with serialized description of test flows */
- private static final String UNIT_EXECUTION_DIR =
- UNIT_RESOURCE_DIR + "/executions";
-
public static File getFlowDir(final String projectName, final String flow) {
- return new File(String.format("%s/%s/%s.flow", UNIT_EXECUTION_DIR, projectName,
- flow));
+ return ExecutionsTestUtil.getFlowFile(projectName, flow + ".flow");
}
public static User getTestUser() {
@@ -67,8 +60,8 @@ public class TestUtils {
/* Helper method to create an XmlUserManager from XML_FILE_PARAM file */
public static UserManager createTestXmlUserManager() {
final Props props = new Props();
- props.put(XmlUserManager.XML_FILE_PARAM, UNIT_RESOURCE_DIR
- + "/azkaban-users.xml");
+ props.put(XmlUserManager.XML_FILE_PARAM, ExecutionsTestUtil.getDataRootDir()
+ + "azkaban-users.xml");
final UserManager manager = new XmlUserManager(props);
return manager;
}
diff --git a/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest.java b/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest.java
index 6332159..dc573bd 100644
--- a/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest.java
+++ b/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest.java
@@ -36,6 +36,7 @@ import azkaban.jobtype.JobTypePluginSet;
import azkaban.project.Project;
import azkaban.project.ProjectLoader;
import azkaban.test.Utils;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.utils.JSONUtils;
import azkaban.utils.Props;
import java.io.File;
@@ -51,8 +52,7 @@ import org.mockito.MockitoAnnotations;
public class FlowRunnerTest extends FlowRunnerTestBase {
- private static final File TEST_DIR = new File(
- "../test/src/test/resources/azkaban/test/executions/exectest1");
+ private static final File TEST_DIR = ExecutionsTestUtil.getFlowDir("exectest1");
private File workingDir;
private JobTypeManager jobtypeManager;
diff --git a/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest2.java b/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest2.java
index 6d02612..00d3a09 100644
--- a/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest2.java
+++ b/azkaban-exec-server/src/test/java/azkaban/execapp/FlowRunnerTest2.java
@@ -36,6 +36,7 @@ import azkaban.jobtype.JobTypePluginSet;
import azkaban.project.Project;
import azkaban.project.ProjectLoader;
import azkaban.test.Utils;
+import azkaban.test.executions.ExecutionsTestUtil;
import azkaban.utils.Props;
import java.io.File;
import java.io.IOException;
@@ -95,8 +96,6 @@ import org.junit.Test;
*/
public class FlowRunnerTest2 extends FlowRunnerTestBase {
- private static final File TEST_DIR = new File(
- "../test/src/test/resources/azkaban/test/executions/embedded2");
private static int id = 101;
private final Logger logger = Logger.getLogger(FlowRunnerTest2.class);
private File workingDir;
@@ -126,7 +125,8 @@ public class FlowRunnerTest2 extends FlowRunnerTestBase {
JmxJobMBeanManager.getInstance().initialize(new Props());
this.flowMap = FlowRunnerTestUtil
- .prepareProject(this.project, TEST_DIR, this.logger, this.workingDir);
+ .prepareProject(this.project, ExecutionsTestUtil.getFlowDir("embedded2"), this.logger,
+ this.workingDir);
InteractiveTestJob.clearTestJobs();
}
diff --git a/test/src/test/java/azkaban/test/executions/ExecutionsTestUtilTest.java b/test/src/test/java/azkaban/test/executions/ExecutionsTestUtilTest.java
new file mode 100644
index 0000000..ea01530
--- /dev/null
+++ b/test/src/test/java/azkaban/test/executions/ExecutionsTestUtilTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.executions;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import org.junit.Test;
+
+public class ExecutionsTestUtilTest {
+
+ @Test
+ public void getFlowFile() throws Exception {
+ final String FLOW_NAME = "logtest";
+ final String FILE_NAME = "largeLog1.log";
+ final File testFile = ExecutionsTestUtil.getFlowFile(FLOW_NAME, FILE_NAME);
+ assertThat(testFile).exists();
+ assertThat(testFile).hasName(FILE_NAME);
+ }
+
+ @Test
+ public void getDataRootDir() throws Exception {
+ final String dataRootDir = ExecutionsTestUtil.getDataRootDir();
+ assertThat(dataRootDir).isEqualTo("../test/execution-test-data/");
+ final File rootDir = new File(dataRootDir);
+ assertThat(rootDir).exists();
+ }
+
+ @Test
+ public void getFlowDir() throws Exception {
+ final String FLOW_NAME = "embedded";
+ final File flowDir = ExecutionsTestUtil.getFlowDir(FLOW_NAME);
+ assertThat(flowDir).exists();
+ assertThat(flowDir).hasName(FLOW_NAME);
+ }
+
+}