http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDRTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDRTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDRTest.java index 1c788a3..bfc0d66 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDRTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDRTest.java @@ -30,6 +30,7 @@ import org.apache.falcon.regression.core.supportClasses.NotifyingAssert; import org.apache.falcon.regression.core.util.BundleUtil; import org.apache.falcon.regression.core.util.HiveAssert; import org.apache.falcon.regression.core.util.InstanceUtil; +import org.apache.falcon.regression.core.util.MatrixUtil; import org.apache.falcon.regression.core.util.OozieUtil; import org.apache.falcon.regression.core.util.TimeUtil; import org.apache.falcon.regression.testHelper.BaseTestClass; @@ -42,14 +43,12 @@ import org.apache.oozie.client.CoordinatorJob; import org.apache.oozie.client.OozieClient; import org.testng.Assert; import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.testng.asserts.SoftAssert; import java.io.IOException; import java.sql.Connection; -import java.sql.SQLException; import java.util.ArrayList; import java.util.List; @@ -76,6 +75,7 @@ public class HiveDRTest extends BaseTestClass { private final FileSystem clusterFS3 = serverFS.get(2); private final OozieClient clusterOC = serverOC.get(0); private final OozieClient clusterOC2 = serverOC.get(1); + private final OozieClient clusterOC3 = serverOC.get(2); private final String baseTestHDFSDir = cleanAndGetTestDir() + "/HiveDR/"; private HCatClient clusterHC; private HCatClient clusterHC2; @@ -83,8 +83,12 @@ public class HiveDRTest extends BaseTestClass { private Connection connection; private Connection connection2; - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception { + @DataProvider + public Object[][] getRecipeLocation() { + return MatrixUtil.crossProduct(RecipeExecLocation.values()); + } + + private void setUp(RecipeExecLocation recipeExecLocation) throws Exception { clusterHC = cluster.getClusterHelper().getHCatClient(); clusterHC2 = cluster2.getClusterHelper().getHCatClient(); bundles[0] = new Bundle(BundleUtil.readHCatBundle(), cluster); @@ -93,21 +97,17 @@ public class HiveDRTest extends BaseTestClass { bundles[1].generateUniqueBundle(this); final ClusterMerlin srcCluster = bundles[0].getClusterElement(); final ClusterMerlin tgtCluster = bundles[1].getClusterElement(); - Bundle.submitCluster(bundles[0]); - + String recipeDir = "HiveDrRecipe"; if (MerlinConstants.IS_SECURE) { - recipeMerlin = RecipeMerlin.readFromDir("HiveDrSecureRecipe", - FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) - .withRecipeCluster(srcCluster); - } else { - recipeMerlin = RecipeMerlin.readFromDir("HiveDrRecipe", - FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) - .withRecipeCluster(srcCluster); + recipeDir = "HiveDrSecureRecipe"; } + Bundle.submitCluster(recipeExecLocation.getRecipeBundle(bundles[0], bundles[1])); + recipeMerlin = RecipeMerlin.readFromDir(recipeDir, FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) + .withRecipeCluster(recipeExecLocation.getRecipeCluster(srcCluster, tgtCluster)); recipeMerlin.withSourceCluster(srcCluster) .withTargetCluster(tgtCluster) .withFrequency(new Frequency("5", Frequency.TimeUnit.minutes)) - .withValidity(TimeUtil.getTimeWrtSystemTime(-5), TimeUtil.getTimeWrtSystemTime(5)); + .withValidity(TimeUtil.getTimeWrtSystemTime(-5), TimeUtil.getTimeWrtSystemTime(15)); recipeMerlin.setUniqueName(this.getClass().getSimpleName()); connection = cluster.getClusterHelper().getHiveJdbcConnection(); @@ -121,8 +121,9 @@ public class HiveDRTest extends BaseTestClass { runSql(connection2, "use hdr_sdb1"); } - @Test - public void drPartition() throws Exception { + @Test(dataProvider = "getRecipeLocation") + public void drPartition(final RecipeExecLocation recipeExecLocation) throws Exception { + setUp(recipeExecLocation); final String tblName = "partitionDR"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -157,8 +158,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -167,6 +168,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drInsertOverwritePartition() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "drInsertOverwritePartition"; final String hlpTblName = "drInsertOverwritePartitionHelperTbl"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); @@ -200,8 +203,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -210,6 +213,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drTwoTablesOneRequest() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.TargetCluster; + setUp(recipeExecLocation); final String tblName = "firstTableDR"; final String tbl2Name = "secondTableDR"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName + ',' + tbl2Name); @@ -232,8 +237,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); final NotifyingAssert anAssert = new NotifyingAssert(true); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), @@ -246,6 +251,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drSerDeWithProperties() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "serdeTable"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -265,8 +272,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -276,6 +283,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drChangeColumn() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "tableForColumnChange"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command1 = recipeMerlin.getSubmissionCommand(); @@ -289,10 +298,8 @@ public class HiveDRTest extends BaseTestClass { runSql(connection, "ALTER TABLE " + tblName + " CHANGE id id STRING COMMENT 'some_comment'"); - - InstanceUtil.waitTillInstanceReachState(clusterOC, recipe1Name, 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); - + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipe1Name, 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -302,6 +309,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drTwoDstTablesTwoRequests() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.TargetCluster; + setUp(recipeExecLocation); final HCatClient clusterHC3 = cluster3.getClusterHelper().getHCatClient(); final Connection connection3 = cluster3.getClusterHelper().getHiveJdbcConnection(); runSql(connection3, "drop database if exists hdr_sdb1 cascade"); @@ -313,9 +322,12 @@ public class HiveDRTest extends BaseTestClass { final String recipe1Name = recipeMerlin.getName(); final List<String> command1 = recipeMerlin.getSubmissionCommand(); - final Bundle bundle = BundleUtil.readHCatBundle(); - bundle.generateUniqueBundle(this); - recipeMerlin.withTargetCluster(new Bundle(bundle, cluster3).getClusterElement()); + final Bundle bundle3 = new Bundle(BundleUtil.readHCatBundle(), cluster3); + bundle3.generateUniqueBundle(this); + bundle3.submitClusters(prism); + recipeMerlin.withTargetCluster(bundle3.getClusterElement()) + .withRecipeCluster(recipeExecLocation.getRecipeCluster( + bundles[0].getClusterElement(), bundle3.getClusterElement())); recipeMerlin.setUniqueName(this.getClass().getSimpleName()); final List<String> command2 = recipeMerlin.getSubmissionCommand(); @@ -334,10 +346,10 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command2), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipe1Name, 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipe2Name, 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipe1Name, 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC3), + recipe2Name, 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); final NotifyingAssert anAssert = new NotifyingAssert(true); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), @@ -349,6 +361,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drExternalToNonExternal() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "externalToNonExternal"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -362,8 +376,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); final NotifyingAssert anAssert = new NotifyingAssert(true); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), @@ -379,6 +393,8 @@ public class HiveDRTest extends BaseTestClass { @Test public void drExtPartitionedToNonExtPartitioned() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "extPartitionedToNonExtPartitioned"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -408,8 +424,8 @@ public class HiveDRTest extends BaseTestClass { runSql(connection, "alter table " + tblName + " change column data data_new string"); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), anAssert, false); @@ -428,6 +444,8 @@ public class HiveDRTest extends BaseTestClass { */ @Test public void drChangeCommentAndPropertyTest() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "myTable"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -458,8 +476,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -468,6 +486,7 @@ public class HiveDRTest extends BaseTestClass { @Test public void dataGeneration() throws Exception { + setUp(RecipeExecLocation.SourceCluster); runSql(connection, "use hdr_sdb1"); createVanillaTable(connection, "store_sales"); createSerDeTable(connection); @@ -498,6 +517,7 @@ public class HiveDRTest extends BaseTestClass { @Test(enabled = false) public void assertionTest() throws Exception { + setUp(RecipeExecLocation.SourceCluster); final SoftAssert anAssert = new SoftAssert(); HiveAssert.assertTableEqual( cluster, clusterHC.getTable("default", "hcatsmoke10546"), @@ -515,7 +535,8 @@ public class HiveDRTest extends BaseTestClass { * @throws IOException */ @Test - public void dynamicPartitionsTest() throws SQLException, IOException { + public void dynamicPartitionsTest() throws Exception { + setUp(RecipeExecLocation.SourceCluster); //create table with static partitions on first cluster createPartitionedTable(connection, false); @@ -535,6 +556,8 @@ public class HiveDRTest extends BaseTestClass { */ @Test public void drInsertDropReplaceDynamicPartition() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "dynamicPartitionDR"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); final List<String> command = recipeMerlin.getSubmissionCommand(); @@ -577,8 +600,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -592,6 +615,8 @@ public class HiveDRTest extends BaseTestClass { */ @Test public void drInsertOverwriteDynamicPartition() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String tblName = "drInsertOverwritePartition"; final String hlpTblName = "drInsertOverwritePartitionHelperTbl"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName); @@ -637,8 +662,8 @@ public class HiveDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(DB_NAME, tblName), cluster2, clusterHC2.getTable(DB_NAME, tblName), new NotifyingAssert(true) @@ -651,6 +676,7 @@ public class HiveDRTest extends BaseTestClass { */ @Test(dataProvider = "frequencyGenerator") public void differentRecipeFrequenciesTest(String frequency) throws Exception { + setUp(RecipeExecLocation.SourceCluster); LOGGER.info("Testing with frequency: " + frequency); String tblName = "myTable"; recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName)
http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDbDRTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDbDRTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDbDRTest.java index a64bd6d..5efd69f 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDbDRTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/HiveDbDRTest.java @@ -32,6 +32,7 @@ import org.apache.falcon.regression.core.util.Config; import org.apache.falcon.regression.core.util.HadoopUtil; import org.apache.falcon.regression.core.util.HiveAssert; import org.apache.falcon.regression.core.util.InstanceUtil; +import org.apache.falcon.regression.core.util.MatrixUtil; import org.apache.falcon.regression.core.util.TimeUtil; import org.apache.falcon.regression.testHelper.BaseTestClass; import org.apache.hadoop.fs.FileSystem; @@ -43,7 +44,6 @@ import org.apache.oozie.client.CoordinatorAction; import org.apache.oozie.client.OozieClient; import org.testng.Assert; import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -67,14 +67,19 @@ public class HiveDbDRTest extends BaseTestClass { private final FileSystem clusterFS = serverFS.get(0); private final FileSystem clusterFS2 = serverFS.get(1); private final OozieClient clusterOC = serverOC.get(0); + private final OozieClient clusterOC2 = serverOC.get(1); private HCatClient clusterHC; private HCatClient clusterHC2; private RecipeMerlin recipeMerlin; private Connection connection; private Connection connection2; - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception { + @DataProvider + public Object[][] getRecipeLocation() { + return MatrixUtil.crossProduct(RecipeExecLocation.values()); + } + + private void setUp(RecipeExecLocation recipeExecLocation) throws Exception { clusterHC = cluster.getClusterHelper().getHCatClient(); clusterHC2 = cluster2.getClusterHelper().getHCatClient(); bundles[0] = new Bundle(BundleUtil.readHCatBundle(), cluster); @@ -83,17 +88,14 @@ public class HiveDbDRTest extends BaseTestClass { bundles[1].generateUniqueBundle(this); final ClusterMerlin srcCluster = bundles[0].getClusterElement(); final ClusterMerlin tgtCluster = bundles[1].getClusterElement(); - Bundle.submitCluster(bundles[0]); + Bundle.submitCluster(recipeExecLocation.getRecipeBundle(bundles[0], bundles[1])); + String recipeDir = "HiveDrRecipe"; if (MerlinConstants.IS_SECURE) { - recipeMerlin = RecipeMerlin.readFromDir("HiveDrSecureRecipe", - FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) - .withRecipeCluster(srcCluster); - } else { - recipeMerlin = RecipeMerlin.readFromDir("HiveDrRecipe", - FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) - .withRecipeCluster(srcCluster); + recipeDir = "HiveDrSecureRecipe"; } + recipeMerlin = RecipeMerlin.readFromDir(recipeDir, FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY) + .withRecipeCluster(recipeExecLocation.getRecipeCluster(srcCluster, tgtCluster)); recipeMerlin.withSourceCluster(srcCluster) .withTargetCluster(tgtCluster) .withFrequency(new Frequency("5", Frequency.TimeUnit.minutes)) @@ -111,8 +113,9 @@ public class HiveDbDRTest extends BaseTestClass { runSql(conn, "use " + dbName); } - @Test - public void drDbDropDb() throws Exception { + @Test(dataProvider = "getRecipeLocation") + public void drDbDropDb(final RecipeExecLocation recipeExecLocation) throws Exception { + setUp(recipeExecLocation); final String dbName = "drDbDropDb"; setUpDb(dbName, connection); setUpDb(dbName, connection2); @@ -123,8 +126,8 @@ public class HiveDbDRTest extends BaseTestClass { runSql(connection, "drop database " + dbName); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); final List<String> dstDbs = runSql(connection2, "show databases"); Assert.assertFalse(dstDbs.contains(dbName), "dstDbs = " + dstDbs + " was not expected to " @@ -134,6 +137,8 @@ public class HiveDbDRTest extends BaseTestClass { @Test(dataProvider = "isDBReplication") public void drDbFailPass(Boolean isDBReplication) throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String dbName = "drDbFailPass"; final String tblName = "vanillaTable"; final String hiveWarehouseLocation = Config.getProperty("hive.warehouse.location", "/apps/hive/warehouse/"); @@ -153,15 +158,15 @@ public class HiveDbDRTest extends BaseTestClass { LOGGER.info("Setting " + clusterFS2.getUri() + dbPath + " to : " + noReadWritePerm); clusterFS2.setPermission(new Path(dbPath), FsPermission.valueOf(noReadWritePerm)); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.KILLED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.KILLED, EntityType.PROCESS); final String readWritePerm = "drwxr-xr-x"; LOGGER.info("Setting " + clusterFS2.getUri() + dbPath + " to : " + readWritePerm); clusterFS2.setPermission(new Path(dbPath), FsPermission.valueOf(readWritePerm)); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertTableEqual(cluster, clusterHC.getTable(dbName, tblName), cluster2, clusterHC2.getTable(dbName, tblName), new NotifyingAssert(true) @@ -170,6 +175,8 @@ public class HiveDbDRTest extends BaseTestClass { @Test public void drDbAddDropTable() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String dbName = "drDbAddDropTable"; final String tblToBeDropped = "table_to_be_dropped"; final String tblToBeDroppedAndAdded = "table_to_be_dropped_and_readded"; @@ -195,8 +202,8 @@ public class HiveDbDRTest extends BaseTestClass { Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); final NotifyingAssert anAssert = new NotifyingAssert(true); HiveAssert.assertDbEqual(cluster, clusterHC.getDatabase(dbName), @@ -205,16 +212,18 @@ public class HiveDbDRTest extends BaseTestClass { /* For second replication - a dropped tables is added back */ createVanillaTable(connection, tblToBeDroppedAndAdded); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 2, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 2, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); HiveAssert.assertDbEqual(cluster, clusterHC.getDatabase(dbName), cluster2, clusterHC2.getDatabase(dbName), anAssert); anAssert.assertAll(); } - @Test(enabled = false) + @Test public void drDbNonReplicatableTable() throws Exception { + final RecipeExecLocation recipeExecLocation = RecipeExecLocation.SourceCluster; + setUp(recipeExecLocation); final String dbName = "drDbNonReplicatableTable"; final String tblName = "vanillaTable"; final String tblView = "vanillaTableView"; @@ -237,8 +246,8 @@ public class HiveDbDRTest extends BaseTestClass { runSql(connection, "alter table " + tblOffline + " enable offline"); Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); - InstanceUtil.waitTillInstanceReachState(clusterOC, recipeMerlin.getName(), 1, - CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); + InstanceUtil.waitTillInstanceReachState(recipeExecLocation.getRecipeOC(clusterOC, clusterOC2), + recipeMerlin.getName(), 1, CoordinatorAction.Status.SUCCEEDED, EntityType.PROCESS); //vanilla table gets replicated, offline table & view are not replicated HiveAssert.assertTableEqual(cluster, clusterHC.getTable(dbName, tblName), http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/RecipeExecLocation.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/RecipeExecLocation.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/RecipeExecLocation.java new file mode 100644 index 0000000..a124082 --- /dev/null +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/hive/dr/RecipeExecLocation.java @@ -0,0 +1,63 @@ +/** + * 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 + * + * 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 org.apache.falcon.regression.hive.dr; + +import org.apache.falcon.regression.Entities.ClusterMerlin; +import org.apache.falcon.regression.core.bundle.Bundle; +import org.apache.oozie.client.OozieClient; + +/** + * Enum to represent location of recipe execution. + */ +enum RecipeExecLocation { + SourceCluster { + protected OozieClient getRecipeOC(OozieClient srcOC, OozieClient tgtOC) { + return srcOC; + } + protected ClusterMerlin getRecipeCluster(ClusterMerlin srcCM, ClusterMerlin tgtCM) { + return srcCM; + } + protected Bundle getRecipeBundle(Bundle srcBundle, Bundle tgtBundle) { + return srcBundle; + } + }, + TargetCluster { + protected OozieClient getRecipeOC(OozieClient srcOC, OozieClient tgtOC) { + return tgtOC; + } + protected ClusterMerlin getRecipeCluster(ClusterMerlin srcCM, ClusterMerlin tgtCM) { + return tgtCM; + } + protected Bundle getRecipeBundle(Bundle srcBundle, Bundle tgtBundle) { + return tgtBundle; + } + }; + + /** Get oozie client for the Oozie that is going to run the recipe. + * @param srcOC the oozie client for the source cluster + * @param tgtOC the oozie client for the target cluster + * @return oozie client for the Oozie that is going to run the recipe + */ + abstract OozieClient getRecipeOC(OozieClient srcOC, OozieClient tgtOC); + + abstract ClusterMerlin getRecipeCluster(ClusterMerlin srcCM, ClusterMerlin tgtCM); + + abstract Bundle getRecipeBundle(Bundle srcBundle, Bundle tgtBundle); + +} http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/ListProcessInstancesTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/ListProcessInstancesTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/ListProcessInstancesTest.java index be8a631..43bdd87 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/ListProcessInstancesTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/ListProcessInstancesTest.java @@ -40,6 +40,7 @@ import org.testng.asserts.SoftAssert; import java.io.IOException; import java.util.Date; +import java.util.UUID; /** * Test list instances api for process. @@ -58,21 +59,23 @@ public class ListProcessInstancesTest extends BaseTestClass { @BeforeClass(alwaysRun = true) public void setUp() throws IOException { - uploadDirToClusters(aggregateWorkflowDir, OSUtil.RESOURCES_OOZIE); - startTime = TimeUtil.getTimeWrtSystemTime(-55); - endTime = TimeUtil.getTimeWrtSystemTime(5); + startTime = TimeUtil.getTimeWrtSystemTime(-65); + //setting end time in past to make "now" be later then actual end time + endTime = TimeUtil.getTimeWrtSystemTime(-5); LOGGER.info("Time range is between : " + startTime + " and " + endTime); } @BeforeMethod(alwaysRun = true) public void prepareData() throws Exception { + uploadDirToClusters(aggregateWorkflowDir, OSUtil.RESOURCES_OOZIE); bundles[0] = BundleUtil.readELBundle(); bundles[0] = new Bundle(bundles[0], servers.get(0)); bundles[0].generateUniqueBundle(this); //prepare process bundles[0].setProcessWorkflow(aggregateWorkflowDir); bundles[0].setInputFeedDataPath(feedDataLocation); - bundles[0].setOutputFeedLocationData(baseTestHDFSDir + "/output" + MINUTE_DATE_PATTERN); + String suffix = UUID.randomUUID().toString(); + bundles[0].setOutputFeedLocationData(baseTestHDFSDir + "/output/" + suffix + MINUTE_DATE_PATTERN); bundles[0].setProcessValidity(startTime, endTime); bundles[0].setProcessConcurrency(3); bundles[0].submitAndScheduleProcess(); @@ -94,6 +97,9 @@ public class ListProcessInstancesTest extends BaseTestClass { */ @Test public void testProcessOrderBy() throws Exception { + //provide data for 4th and 5th instances (fyi: indexing starts from 0th instance) + OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, processName, 0, 3); + OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, processName, 0, 4); SoftAssert softAssert = new SoftAssert(); //orderBy startTime descending order InstancesResult r = prism.getProcessHelper().listInstances(processName, @@ -152,6 +158,7 @@ public class ListProcessInstancesTest extends BaseTestClass { } /** + * List process instances using orderBy - status, -startTime, -endTime params * List process instances using -offset and -numResults params expecting list of process * instances to start at the right offset and give expected number of instances. */ @@ -214,6 +221,10 @@ public class ListProcessInstancesTest extends BaseTestClass { */ @Test public void testProcessFilterBy() throws Exception { + //provide data for 4th and 5th instances (fyi: indexing starts from 0th instance) + OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, processName, 0, 3); + OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, processName, 0, 4); + //test with simple filters InstancesResult r = prism.getProcessHelper().listInstances(processName, "filterBy=STATUS:RUNNING", null); @@ -293,9 +304,13 @@ public class ListProcessInstancesTest extends BaseTestClass { + "&end=" + TimeUtil.addMinsToTime(startTime, 16), null); InstanceUtil.validateResponse(r, 1, 0, 0, 1, 0); - //only start, actual startTime (end is automatically set to start + frequency * 10) + //only start, actual startTime (end is automatically set to now - which is later then validity end time) r = prism.getProcessHelper().listInstances(processName, "start=" + startTime, null); - InstanceUtil.validateResponse(r, 10, 3, 0, 7, 0); + InstanceUtil.validateResponse(r, 10, 1, 0, 9, 0); + + //the same without start, end should be set to now + r = prism.getProcessHelper().listInstances(processName, "", null); + InstanceUtil.validateResponse(r, 10, 1, 0, 9, 0); //only start, greater then actual startTime r = prism.getProcessHelper().listInstances(processName, http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ClusterSetupTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ClusterSetupTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ClusterSetupTest.java index b0ddcf3..5efa5b2 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ClusterSetupTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ClusterSetupTest.java @@ -83,6 +83,7 @@ public class ClusterSetupTest extends BaseUITestClass{ @Test public void testDefaultScenario() throws URISyntaxException, AuthenticationException, InterruptedException, IOException { + Assert.assertFalse(clusterSetup.isXmlPreviewExpanded(), "Xml preview should be collapsed by default."); clusterSetup.fillForm(sourceCluster); clusterSetup.clickNext(); clusterSetup.clickPrevious(); @@ -93,6 +94,9 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.clickSave(); String alertText = clusterSetup.getActiveAlertText(); Assert.assertEquals(alertText, "falcon/default/Submit successful (cluster) " + sourceCluster.getName()); + //check the same via notifications bar + clusterSetup.getPageHeader().validateNotificationCountAndCheckLast(1, + "falcon/default/Submit successful (cluster) " + sourceCluster.getName()); ClusterMerlin definition = new ClusterMerlin(cluster.getClusterHelper() .getEntityDefinition(bundles[0].getClusterElement().toString()).getMessage()); //definition should be the same that the source @@ -106,11 +110,11 @@ public class ClusterSetupTest extends BaseUITestClass{ @Test public void testXmlPreview() { clusterSetup.fillForm(sourceCluster); - ClusterMerlin generalStepPreview = clusterSetup.getXmlPreview(); + ClusterMerlin generalStepPreview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(generalStepPreview); sourceCluster.assertEquals(generalStepPreview); clusterSetup.clickNext(); - ClusterMerlin summaryStepPreview = clusterSetup.getXmlPreview(); + ClusterMerlin summaryStepPreview = clusterSetup.getEntityFromXMLPreview(); sourceCluster.assertEquals(summaryStepPreview); generalStepPreview.assertEquals(summaryStepPreview); } @@ -145,7 +149,7 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.fillForm(sourceCluster); //check without extra location - ClusterMerlin preview = clusterSetup.getXmlPreview(); + ClusterMerlin preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); sourceCluster.assertEquals(preview); @@ -157,7 +161,7 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.clickAddLocation(); clusterSetup.fillAdditionalLocation(location); Assert.assertTrue(clusterSetup.checkElementByContent("input", path), "Location should be present."); - preview = clusterSetup.getXmlPreview(); + preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); //add location to source to compare equality sourceCluster.addLocation(ClusterLocationType.WORKING, path); @@ -166,7 +170,7 @@ public class ClusterSetupTest extends BaseUITestClass{ //delete location and check results clusterSetup.clickDeleteLocation(); Assert.assertFalse(clusterSetup.checkElementByContent("input", path), "Location should be absent."); - preview = clusterSetup.getXmlPreview(); + preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); //remove location from source to check equality int last = sourceCluster.getLocations().getLocations().size() - 1; @@ -183,7 +187,7 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.fillForm(sourceCluster); //check without extra tag - ClusterMerlin preview = clusterSetup.getXmlPreview(); + ClusterMerlin preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); sourceCluster.assertEquals(preview); @@ -192,7 +196,7 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.addTag("myTag2", "myValue2"); Assert.assertTrue(clusterSetup.checkElementByContent("input", "myTag2"), "Tag should be present"); Assert.assertTrue(clusterSetup.checkElementByContent("input", "myValue2"), "Tag should be present"); - preview = clusterSetup.getXmlPreview(); + preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); //add tag to source to compare equality sourceCluster.setTags("myTag1=myValue1,myTag2=myValue2"); @@ -202,7 +206,7 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.clickDeleteTag(); Assert.assertFalse(clusterSetup.checkElementByContent("input", "myTag2"), "Tag should be absent."); Assert.assertFalse(clusterSetup.checkElementByContent("input", "myValue2"), "Tag should be absent."); - preview = clusterSetup.getXmlPreview(); + preview = clusterSetup.getEntityFromXMLPreview(); cleanGeneralPreview(preview); //remove location from source to check equality sourceCluster.setTags("myTag1=myValue1"); @@ -254,11 +258,27 @@ public class ClusterSetupTest extends BaseUITestClass{ clusterSetup.clickNext(); clusterSetup.clickSave(); String alertMessage = clusterSetup.getActiveAlertText(); - Assert.assertEquals(alertMessage, + Assert.assertTrue(alertMessage.contains(String.format("Location %s for cluster %s must exist.", + nonExistent, sourceCluster.getName())), "Alert message should match to expected."); + //check the same through notification bar + clusterSetup.getPageHeader().validateNotificationCountAndCheckLast(1, String.format("Location %s for cluster %s must exist.", nonExistent, sourceCluster.getName())); } /** + * Validate alert lifetime. + */ + @Test + public void testValidateAlertLifeTime() throws IOException { + String nonExistent = "/non-existent-directory"; + sourceCluster.getLocation(ClusterLocationType.STAGING).setPath(nonExistent); + clusterSetup.fillForm(sourceCluster); + clusterSetup.clickNext(); + clusterSetup.clickSave(); + clusterSetup.validateAlertLifetime(); + } + + /** * Populate cluster with properties. Click Edit XML. Change cluster name and * description, add registry interface. Check that they were enabled and populated * in wizard. @@ -283,7 +303,7 @@ public class ClusterSetupTest extends BaseUITestClass{ sourceCluster.getInterfaces().getInterfaces().add(iFace); //populate it to xmlPreview - clusterSetup.setClusterXml(sourceCluster.toString()); + clusterSetup.setXmlPreview(sourceCluster.toString()); //check values on wizard registryEndpoint = clusterSetup.getInterfaceEndpoint(Interfacetype.REGISTRY); @@ -304,24 +324,24 @@ public class ClusterSetupTest extends BaseUITestClass{ @Test public void testEditXmlInvalidValues(){ clusterSetup.fillForm(sourceCluster); - ClusterMerlin initialPreview = clusterSetup.getXmlPreview(); + ClusterMerlin initialPreview = clusterSetup.getEntityFromXMLPreview(); //break xml String brokenXml = new ClusterMerlin(sourceCluster.toString()).toString(); brokenXml = brokenXml.substring(0, brokenXml.length() - 3); //enter it into xml preview form - clusterSetup.setClusterXml(brokenXml); + clusterSetup.setXmlPreview(brokenXml); //compare preview before and after changes - ClusterMerlin finalPreview = clusterSetup.getXmlPreview(); + ClusterMerlin finalPreview = clusterSetup.getEntityFromXMLPreview(); Assert.assertEquals(initialPreview, finalPreview, "Broken xml shouldn't be accepted."); //change properties to malformed sourceCluster.setName("abc123!@#"); //enter it into xml preview form - clusterSetup.setClusterXml(sourceCluster.toString()); + clusterSetup.setXmlPreview(sourceCluster.toString()); //check the value on a wizard Assert.assertEquals(clusterSetup.getName(), sourceCluster.getName(), "Malformed name should be accepted."); http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java index 47b1d19..e18fb47 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java @@ -123,6 +123,7 @@ public class FeedSetupTest extends BaseUITestClass{ */ @Test public void testWizardDefaultScenario() throws Exception { + Assert.assertFalse(feedWizardPage.isXmlPreviewExpanded(), "Xml preview should be collapsed by default."); feed.setTags(getRandomTags()); feed.setGroups("groups"); feed.setAvailabilityFlag("_SUCCESS"); @@ -201,7 +202,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the General Info Page feedWizardPage.setFeedGeneralInfo(feed); - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the General Info Page feed.assertGeneralProperties(feedFromXML); @@ -209,7 +210,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the Properties Info Page feedWizardPage.clickNext(); feedWizardPage.setFeedPropertiesInfo(feed); - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Properties Info Page feed.assertPropertiesInfo(feedFromXML); @@ -217,7 +218,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the Location Info Page feedWizardPage.clickNext(); feedWizardPage.setFeedLocationInfo(feed); - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Location Info Page feed.assertLocationInfo(feedFromXML); @@ -226,7 +227,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the Cluster Info Page feedWizardPage.clickNext(); feedWizardPage.setFeedClustersInfo(feed); - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Cluster Info Page @@ -253,15 +254,13 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.setFeedGroups(feed.getGroups()); // Get XML, and set tag and group back to null - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); feedFromXML.setTags(null); feedFromXML.setGroups(null); // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); String xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Assert that there is only one Tag on the Wizard window feedWizardPage.isTagsDisplayed(0, true); @@ -282,10 +281,8 @@ public class FeedSetupTest extends BaseUITestClass{ feedFromXML.setGroups("groups_new"); // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Assert that there are two Tags on the Wizard window feedWizardPage.isTagsDisplayed(0, true); @@ -340,7 +337,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the General Info Page feedWizardPage.setFeedGeneralInfo(feed); - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the General Info Page feed.assertGeneralProperties(feedFromXML); @@ -367,7 +364,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.isTagsDisplayed(1, true); // Get feed from XML Preview - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert Tag values in the XML Preview Assert.assertEquals(feedFromXML.getTags(), feed.getTags()); @@ -380,7 +377,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.isTagsDisplayed(1, false); // Get feed from XML Preview - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert that there are is only one Tag in the XML Preview Assert.assertEquals(feedFromXML.getTags(), "first=yes", "Unexpected Tags on the XML preview"); @@ -470,7 +467,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Set values on the Properties Info Page feedWizardPage.clickNext(); feedWizardPage.setFeedPropertiesInfo(feed); - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Properties Info Page feed.assertPropertiesInfo(feedFromXML); @@ -499,15 +496,13 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.setFeedLateArrivalCutOffUnit(feed.getLateArrival().getCutOff().getTimeUnit().toString()); // Get XML, and set Frequency and Late Arrival back to null - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); feedFromXML.setFrequency(null); feedFromXML.setLateArrival(null); // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); String xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Assert that the Frequency value is empty on the Wizard window Assert.assertEquals(feedWizardPage.getFeedFrequencyQuantityText(), "", @@ -523,10 +518,8 @@ public class FeedSetupTest extends BaseUITestClass{ feedFromXML.getLateArrival().setCutOff(new Frequency("1", Frequency.TimeUnit.days)); // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Assert that the Frequency values are correct on the Wizard window Assert.assertEquals(feedWizardPage.getFeedFrequencyQuantityText(), "5", @@ -595,7 +588,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.isPropertyDisplayed(1, true); // Get feed from XML Preview - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert Property values in the XML Preview Assert.assertEquals(feedFromXML.getProperties().getProperties().get(0).getName(), @@ -621,7 +614,7 @@ public class FeedSetupTest extends BaseUITestClass{ // Get feed from XML Preview - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert Property value in the XML Preview Assert.assertEquals(feedFromXML.getProperties().getProperties().get(0).getName(), @@ -741,7 +734,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.setFeedLocationInfo(feed); // Get feed from XML Preview - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Location Info Page feed.assertLocationInfo(feedFromXML); @@ -752,13 +745,11 @@ public class FeedSetupTest extends BaseUITestClass{ feedFromXML.getLocations().getLocations().get(2).setPath(baseTestHDFSDir + "/newFalcon/clicksMetaData"); // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); String xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Get feed from XML Preview - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values on the Location Info Page Assert.assertEquals(feedFromXML.getLocations().getLocations().get(0).getPath(), baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); @@ -877,7 +868,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.clickNext(); // Get feed from XML Preview - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Location Info Page feed.assertLocationInfo(feedFromXML); @@ -895,7 +886,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.clickNext(); // Get feed from XML Preview - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert the Table Uri value entered on the Location Info Page Assert.assertEquals(feedFromXML.getTable().getUri(), catalogUri, @@ -928,7 +919,7 @@ public class FeedSetupTest extends BaseUITestClass{ feedWizardPage.setFeedClustersInfo(feed); // Get feed from XML Preview - FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + FeedMerlin feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values on the Cluster Info Page feed.assertClusterInfo(feedFromXML); @@ -946,13 +937,11 @@ public class FeedSetupTest extends BaseUITestClass{ // Now click EditXML and set the updated XML here - feedWizardPage.clickEditXml(); String xmlToString = feedFromXML.toString(); - feedWizardPage.setFeedXml(xmlToString); - feedWizardPage.clickEditXml(); + feedWizardPage.setXmlPreview(xmlToString); // Get feed from XML Preview - feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + feedFromXML = feedWizardPage.getEntityFromXMLPreview(); // Assert all the values on the Location Info Page Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) .getLocations().getLocations().get(0).getPath(), http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/HomePageTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/HomePageTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/HomePageTest.java index 20864f6..46ace0f 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/HomePageTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/HomePageTest.java @@ -172,8 +172,8 @@ public class HomePageTest extends BaseUITestClass { alertText = homePage.getActiveAlertText(); Assert.assertEquals(alertText, "Invalid xml. File not uploaded", "XML file with invalid text was allowed to be uploaded"); - - + //check the same with notification bar + homePage.getPageHeader().validateNotificationCountAndCheckLast(2, "Invalid xml. File not uploaded"); } /** http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorSourceTargetOptionsTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorSourceTargetOptionsTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorSourceTargetOptionsTest.java index 552c15e..8bec758 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorSourceTargetOptionsTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorSourceTargetOptionsTest.java @@ -193,6 +193,8 @@ public class MirrorSourceTargetOptionsTest extends BaseUITestClass{ mirrorPage.save(); Assert.assertTrue(mirrorPage.getActiveAlertText().contains("should be before process end"), "Warning about wrong Validity should be present"); + //check the same through notification bar + mirrorPage.getPageHeader().validateNotificationCountAndCheckLast(1, "should be before process end"); } @AfterClass(alwaysRun = true) http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorTest.java index c54789b..e99202b 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/MirrorTest.java @@ -21,6 +21,7 @@ package org.apache.falcon.regression.searchUI; import org.apache.falcon.cli.FalconCLI; import org.apache.falcon.entity.v0.Frequency; import org.apache.falcon.entity.v0.cluster.ClusterLocationType; +import org.apache.falcon.entity.v0.cluster.Interfacetype; import org.apache.falcon.regression.Entities.ClusterMerlin; import org.apache.falcon.regression.Entities.ProcessMerlin; import org.apache.falcon.regression.Entities.RecipeMerlin; @@ -39,15 +40,18 @@ import org.apache.falcon.regression.ui.search.SearchPage; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.hive.hcatalog.api.HCatClient; import org.apache.log4j.Logger; import org.apache.oozie.client.OozieClient; +import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.IOException; +import java.net.URISyntaxException; import java.sql.Connection; import java.util.Arrays; @@ -75,6 +79,7 @@ public class MirrorTest extends BaseUITestClass { private Connection connection; private Connection connection2; private MirrorWizardPage mirrorPage; + /** * Submit one cluster, 2 feeds and 10 processes with 1 to 10 tags (1st process has 1 tag, * 2nd - two tags.. 10th has 10 tags). @@ -82,7 +87,6 @@ public class MirrorTest extends BaseUITestClass { * @throws IOException * @throws AuthenticationException * @throws InterruptedException - * @throws JAXBException */ @BeforeMethod(alwaysRun = true) public void setup() throws Exception { @@ -148,7 +152,7 @@ public class MirrorTest extends BaseUITestClass { hdfsRecipe.withSourceDir(hdfsSrcDir).withTargetDir(hdfsTgtDir); hdfsRecipe.setTags(Arrays.asList("key1=val1", "key2=val2", "key3=val3")); - mirrorPage.applyRecipe(hdfsRecipe); + mirrorPage.applyRecipe(hdfsRecipe, true); mirrorPage.next(); mirrorPage.save(); @@ -169,7 +173,7 @@ public class MirrorTest extends BaseUITestClass { recipeMerlin.withSourceDb(dbName); recipeMerlin.withSourceTable(tblName); recipeMerlin.setTags(Arrays.asList("key1=val1", "key2=val2", "key3=val3")); - mirrorPage.applyRecipe(recipeMerlin); + mirrorPage.applyRecipe(recipeMerlin, true); mirrorPage.next(); mirrorPage.save(); AssertUtil.assertSucceeded(prism.getProcessHelper().getStatus( @@ -186,6 +190,66 @@ public class MirrorTest extends BaseUITestClass { } /** + * If "send alerts to" is empty on HiveDR UI, default value for drNotificationReceivers property must be "NA". + */ + @Test + public void testSendAlertsDefaultValue() + throws InterruptedException, IOException, URISyntaxException, AuthenticationException { + recipeMerlin.withSourceDb(DB_NAME); + recipeMerlin.withSourceTable(TBL1_NAME); + mirrorPage.applyRecipe(recipeMerlin, false); + mirrorPage.next(); + mirrorPage.save(); + ProcessMerlin process = bundles[0].getProcessObject(); + process.setName(recipeMerlin.getName()); + process = new ProcessMerlin(cluster.getProcessHelper().getEntityDefinition(process.toString()).getMessage()); + String drNotificationReceivers = process.getProperty("drNotificationReceivers"); + Assert.assertTrue(drNotificationReceivers != null && drNotificationReceivers.equals("NA"), + "Default value for drNotificationReceivers should be NA."); + + /* particular check that on table replication scenario UI doesn't pick up thrift server + end point in place of Hive server2 end point*/ + String expectedUri = recipeMerlin.getTgtCluster().getInterfaceEndpoint(Interfacetype.REGISTRY) + .replace("thrift", "hive2").replace("9083", "10000"); + Assert.assertEquals(process.getProperty("targetHiveServer2Uri"), expectedUri, + "Hive server2 end point should be picked by UI."); + expectedUri = recipeMerlin.getSrcCluster().getInterfaceEndpoint(Interfacetype.REGISTRY) + .replace("thrift", "hive2").replace("9083", "10000"); + Assert.assertEquals(process.getProperty("sourceHiveServer2Uri"), expectedUri, + "Hive server2 end point should be picked by UI."); + } + + /** + * Test that Hive DR UI doesn't picks thrift server end point in place of Hive server2 end point. + * Test that specified HDFS target staging path on Hive DR UI, isn't getting assigned to "*". + */ + @Test + public void testHDFSTargetStagingPath() + throws URISyntaxException, AuthenticationException, InterruptedException, IOException { + recipeMerlin.withSourceDb(DB_NAME); + mirrorPage.applyRecipe(recipeMerlin, false); + mirrorPage.next(); + mirrorPage.save(); + ProcessMerlin process = bundles[0].getProcessObject(); + process.setName(recipeMerlin.getName()); + process = new ProcessMerlin(cluster.getProcessHelper().getEntityDefinition(process.toString()).getMessage()); + + // check that that Hive DR UI doesn't picks thrift server end point in place of Hive server2 end point + String expectedUri = recipeMerlin.getTgtCluster().getInterfaceEndpoint(Interfacetype.REGISTRY) + .replace("thrift", "hive2").replace("9083", "10000"); + Assert.assertEquals(process.getProperty("targetHiveServer2Uri"), expectedUri, + "Hive server2 end point should be picked by UI."); + expectedUri = recipeMerlin.getSrcCluster().getInterfaceEndpoint(Interfacetype.REGISTRY) + .replace("thrift", "hive2").replace("9083", "10000"); + Assert.assertEquals(process.getProperty("sourceHiveServer2Uri"), expectedUri, + "Hive server2 end point should be picked by UI."); + + //check that that specified HDFS target staging path on Hive DR UI, isn't getting assigned to "*" + Assert.assertFalse(process.getProperty("targetStagingPath").equals("*"), + "HDFS target staging path shouldn't be assigned to '*'."); + } + + /** * Test recipe with bad acls. * Set owner/group as invalid string (utf-8, special chars, number). * Check that user is not allowed to go to the next step and has been notified with an alert. @@ -197,7 +261,7 @@ public class MirrorTest extends BaseUITestClass { final String goodAclOwner = MerlinConstants.CURRENT_USER_NAME; final String goodAclGroup = MerlinConstants.CURRENT_USER_GROUP; final String goodAclPerms = "777"; - mirrorPage.applyRecipe(recipeMerlin); + mirrorPage.applyRecipe(recipeMerlin, true); NotifyingAssert notifyingAssert = new NotifyingAssert(true); for(String badAclOwner: new String[] {"utf8\u20ACchar", "speci@l", "123"}) { mirrorPage.setAclOwner(badAclOwner); @@ -253,7 +317,7 @@ public class MirrorTest extends BaseUITestClass { public void testHiveAdvancedInvalidStaging() { recipeMerlin.withSourceDb(DB_NAME); recipeMerlin.setTags(Arrays.asList("key1=val1", "key2=val2", "key3=val3")); - mirrorPage.applyRecipe(recipeMerlin); + mirrorPage.applyRecipe(recipeMerlin, true); NotifyingAssert notifyingAssert = new NotifyingAssert(true); final String goodSrcStaging = recipeMerlin.getSrcCluster().getLocation(ClusterLocationType.STAGING).getPath(); final String goodTgtStaging = recipeMerlin.getTgtCluster().getLocation(ClusterLocationType.STAGING).getPath(); @@ -297,7 +361,7 @@ public class MirrorTest extends BaseUITestClass { public void testHiveAdvancedStagingAcl() throws Exception { recipeMerlin.withSourceDb(DB_NAME); recipeMerlin.setTags(Arrays.asList("key1=val1", "key2=val2", "key3=val3")); - mirrorPage.applyRecipe(recipeMerlin); + mirrorPage.applyRecipe(recipeMerlin, true); NotifyingAssert notifyingAssert = new NotifyingAssert(true); final String goodSrcStaging = recipeMerlin.getSrcCluster().getLocation(ClusterLocationType.STAGING).getPath(); final String goodTgtStaging = recipeMerlin.getTgtCluster().getLocation(ClusterLocationType.STAGING).getPath(); http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ProcessSetupTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ProcessSetupTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ProcessSetupTest.java index 728646f..eae5137 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ProcessSetupTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/ProcessSetupTest.java @@ -153,6 +153,7 @@ public class ProcessSetupTest extends BaseUITestClass { */ @Test public void testGeneralStepDefaultScenario() throws Exception { + Assert.assertFalse(processWizardPage.isXmlPreviewExpanded(), "Xml preview should be collapsed by default."); processWizardPage.setProcessGeneralInfo(process); processWizardPage.clickNext(); @@ -172,7 +173,7 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.setProcessGeneralInfo(process); // Get process from XML Preview - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the General Info Page LOGGER.info(String.format("Comparing source process: %n%s%n and preview: %n%s%n.", process, processFromXML)); @@ -196,14 +197,12 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.setTags(process.getTags()); // Get XML, and set tag and group back to null - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); processFromXML.setTags(null); // Now click EditXML and set the updated XML here - processWizardPage.clickEditXml(); String xmlToString = processFromXML.toString(); - processWizardPage.setProcessXml(xmlToString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlToString); Thread.sleep(1000); // Assert that there is only one Tag on the Wizard window @@ -222,10 +221,8 @@ public class ProcessSetupTest extends BaseUITestClass { processFromXML.getWorkflow().setVersion("pig-0.13.0"); // Now click EditXML and set the updated XML here - processWizardPage.clickEditXml(); xmlToString = processFromXML.toString(); - processWizardPage.setProcessXml(xmlToString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlToString); // Assert that there are two Tags on the Wizard window processWizardPage.isTagsDisplayed(0, true); @@ -316,7 +313,7 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.setProcessPropertiesInfo(process); // Get process from XML Preview - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); // Assert all the values entered on the Properties Page LOGGER.info(String.format("Comparing source process: %n%s%n and preview: %n%s%n.", process, processFromXML)); @@ -343,15 +340,13 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.setMaxParallelInstances(5); // Get process from XML Preview - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); processFromXML.setFrequency(null); processFromXML.setParallel(1); // Now click EditXML and set the updated XML here - processWizardPage.clickEditXml(); String xmlToString = processFromXML.toString(); - processWizardPage.setProcessXml(xmlToString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlToString); // Assert Frequency and Parallel values Assert.assertEquals(processWizardPage.getFrequencyQuantityText(), "", @@ -360,17 +355,15 @@ public class ProcessSetupTest extends BaseUITestClass { "Unexpected Parallel on the Wizard window"); // Get process from XML Preview - processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + processFromXML = processWizardPage.getEntityFromXMLPreview(); // Set TimeZone and Order TimeZone tz = TimeZone.getTimeZone("GMT-08:00"); processFromXML.setTimezone(tz); processFromXML.setOrder(ExecutionType.LIFO); // Now click EditXML and set the updated XML here - processWizardPage.clickEditXml(); xmlToString = processFromXML.toString(); - processWizardPage.setProcessXml(xmlToString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlToString); // Assert TimeZone and Order Assert.assertEquals(processWizardPage.getOrderText(), "LIFO", @@ -511,7 +504,7 @@ public class ProcessSetupTest extends BaseUITestClass { // Add clusters processWizardPage.setClusters(process.getClusters()); - ProcessMerlin xmlPreview = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin xmlPreview = processWizardPage.getEntityFromXMLPreview(); //compare clusters LOGGER.info(String.format("Comparing clusters of process: %n%s%n and preview: %n%s%n.", process, xmlPreview)); @@ -519,7 +512,7 @@ public class ProcessSetupTest extends BaseUITestClass { //delete one cluster and repeat the check processWizardPage.deleteLastCluster(); - xmlPreview = processWizardPage.getProcessMerlinFromProcessXml(); + xmlPreview = processWizardPage.getEntityFromXMLPreview(); process.getClusters().getClusters().remove(1); //compare clusters @@ -553,7 +546,7 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.setClusters(process.getClusters()); //compare preview and source data - ProcessMerlin xmlPreview = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin xmlPreview = processWizardPage.getEntityFromXMLPreview(); LOGGER.info(String.format("Comparing clusters of process: %n%s%n and preview: %n%s%n.", process, xmlPreview)); ProcessMerlin.assertClustersEqual(process.getClusters().getClusters(), xmlPreview.getClusters().getClusters()); @@ -561,9 +554,7 @@ public class ProcessSetupTest extends BaseUITestClass { Date date = new Date(); xmlPreview.getClusters().getClusters().get(0).getValidity().setEnd(date); xmlPreview.getClusters().getClusters().get(0).setName(clusterMerlin.getName()); - processWizardPage.clickEditXml(); - processWizardPage.setProcessXml(xmlPreview.toString()); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlPreview.toString()); //check that validity end is changed on wizard String endUI = processWizardPage.getValidityEnd(); @@ -581,9 +572,7 @@ public class ProcessSetupTest extends BaseUITestClass { processCluster.setName(firstClusterName); processCluster.setValidity(xmlPreview.getClusters().getClusters().get(0).getValidity()); process.addProcessCluster(processCluster); - processWizardPage.clickEditXml(); - processWizardPage.setProcessXml(xmlPreview.toString()); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlPreview.toString()); //check that changes are reflected on wizard int finalCount = processWizardPage.getWizardClusterCount(); @@ -797,7 +786,7 @@ public class ProcessSetupTest extends BaseUITestClass { "Unexpected Input End on the Wizard window"); // Get process from XML Preview - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); // Assert Input values on the XML Preview LOGGER.info(String.format("Comparing source process: %n%s%n and preview: %n%s%n.", process, processFromXML)); @@ -808,10 +797,8 @@ public class ProcessSetupTest extends BaseUITestClass { processFromXML.setOutputs(process.getOutputs()); // Now click EditXML and set the updated XML here - processWizardPage.clickEditXml(); String xmlToString = processFromXML.toString(); - processWizardPage.setProcessXml(xmlToString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(xmlToString); // Assert Input Name and Output values on Wizard Assert.assertEquals(processWizardPage.getInputNameText(0), "newInputData", @@ -867,7 +854,7 @@ public class ProcessSetupTest extends BaseUITestClass { "Unexpected Input End on the Wizard window"); // Get process from XML Preview - ProcessMerlin processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin processFromXML = processWizardPage.getEntityFromXMLPreview(); // Assert Input values on the XML Preview LOGGER.info(String.format("Comparing source process: %n%s%n and preview: %n%s%n.", process, processFromXML)); @@ -894,7 +881,7 @@ public class ProcessSetupTest extends BaseUITestClass { "Unexpected Output Instance on the Wizard window"); // Get process from XML Preview - processFromXML = processWizardPage.getProcessMerlinFromProcessXml(); + processFromXML = processWizardPage.getEntityFromXMLPreview(); // Assert Output values on the XML Preview LOGGER.info(String.format("Comparing source process : %n%s%n and preview: %n%s%n.", process, processFromXML)); @@ -1009,7 +996,7 @@ public class ProcessSetupTest extends BaseUITestClass { //get process from summary and from xml and compare them ProcessMerlin summaryProcess = ProcessMerlin.getEmptyProcess(process); summaryProcess = processWizardPage.getProcessFromSummaryBox(summaryProcess); - ProcessMerlin previewProcess = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin previewProcess = processWizardPage.getEntityFromXMLPreview(); summaryProcess.assertEquals(previewProcess); //add input to preview cluster @@ -1022,9 +1009,7 @@ public class ProcessSetupTest extends BaseUITestClass { previewProcess.getInputs().getInputs().add(newInput); //push new process to xml preview - processWizardPage.clickEditXml(); - processWizardPage.setProcessXml(previewProcess.toString()); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(previewProcess.toString()); //get process from summary and check that new input is available summaryProcess = processWizardPage.getProcessFromSummaryBox(ProcessMerlin.getEmptyProcess(summaryProcess)); @@ -1062,17 +1047,15 @@ public class ProcessSetupTest extends BaseUITestClass { processWizardPage.clickNext(); //get process from xml preview - ProcessMerlin previewProcess1 = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin previewProcess1 = processWizardPage.getEntityFromXMLPreview(); String processString = previewProcess1.toString(); //damage the xml and populate it back to preview processString = processString.substring(0, processString.length() - 3); - processWizardPage.clickEditXml(); - processWizardPage.setProcessXml(processString); - processWizardPage.clickEditXml(); + processWizardPage.setXmlPreview(processString); //get xml preview and compare with initial state - ProcessMerlin previewProcess2 = processWizardPage.getProcessMerlinFromProcessXml(); + ProcessMerlin previewProcess2 = processWizardPage.getEntityFromXMLPreview(); previewProcess2.assertEquals(previewProcess1); } } http://git-wip-us.apache.org/repos/asf/falcon/blob/9e6d5a6c/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FalconClientTest.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FalconClientTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FalconClientTest.java index d11411b..73273f9 100644 --- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FalconClientTest.java +++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FalconClientTest.java @@ -25,6 +25,7 @@ import org.apache.falcon.regression.core.supportClasses.ExecResult; import org.apache.falcon.regression.core.util.AssertUtil; import org.apache.falcon.regression.core.util.BundleUtil; import org.apache.falcon.regression.core.util.HadoopUtil; +import org.apache.falcon.regression.core.util.KerberosHelper; import org.apache.falcon.regression.core.util.OSUtil; import org.apache.falcon.regression.testHelper.BaseTestClass; import org.apache.hadoop.fs.FileSystem; @@ -80,9 +81,13 @@ public class FalconClientTest extends BaseTestClass { * able to delete * @throws Exception */ - @Test(enabled = false) + @Test(enabled = true) public void badClusterDelete() throws Exception { bundles[0].submitClusters(prism); + //switch user + if (MerlinConstants.IS_SECURE) { + KerberosHelper.initUserWithKeytab(MerlinConstants.DIFFERENT_USER_NAME); + } final String clusterXml = bundles[0].getClusters().get(0); final ExecResult execResult = prism.getClusterHelper().clientDelete(clusterXml, MerlinConstants.DIFFERENT_USER_NAME);
