/** * Run recipe with different frequencies. Submission should go through. Check frequency of the * launched oozie job */ @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) .withFrequency(new Frequency(frequency)); runSql(connection, "create table " + tblName + "(comment string)"); final List<String> command = recipeMerlin.getSubmissionCommand(); Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed."); LOGGER.info("Submission went through."); InstanceUtil.waitTillInstanceReachState( clusterOC, recipeMerlin.getName(), 1, CoordinatorAction.Status.RUNNING, EntityType.PROCESS); String filter = "name=FALCON_PROCESS_" + recipeMerlin.getName(); List<BundleJob> bundleJobs = OozieUtil.getBundles(clusterOC, filter, 0, 10); List<String> bundleIds = OozieUtil.getBundleIds(bundleJobs); String bundleId = OozieUtil.getMaxId(bundleIds); List<CoordinatorJob> coords = clusterOC.getBundleJobInfo(bundleId).getCoordinators(); List<String> cIds = new ArrayList<String>(); for (CoordinatorJob coord : coords) { cIds.add(coord.getId()); } String coordId = OozieUtil.getMinId(cIds); CoordinatorJob job = clusterOC.getCoordJobInfo(coordId); CoordinatorJob.Timeunit timeUnit = job.getTimeUnit(); String freq = job.getFrequency(); LOGGER.info("Frequency of running job: " + timeUnit + " " + freq); Assert.assertTrue( frequency.contains(timeUnit.name().toLowerCase().replace("_", "")) && frequency.contains(freq), "Running job has different frequency."); }
/* * Retrieves replication coordinator instances. * @param client target oozie client * @param fName feed name */ private List<CoordinatorAction> getReplicationInstances(OozieClient client, String fName) throws OozieClientException { String filter = "name=FALCON_FEED_" + fName; List<BundleJob> bundleJobs = OozieUtil.getBundles(client, filter, 0, 10); Assert.assertNotEquals(bundleJobs.size(), 0, "Could not retrieve bundles"); List<String> bundleIds = OozieUtil.getBundleIds(bundleJobs); String bundleId = OozieUtil.getMaxId(bundleIds); LOGGER.info(String.format("Using bundle %s", bundleId)); List<CoordinatorJob> coords = client.getBundleJobInfo(bundleId).getCoordinators(); String coordId = null; for (CoordinatorJob coord : coords) { if (coord.getAppName().contains("FEED_REPLICATION")) { coordId = coord.getId(); break; } } LOGGER.info(String.format("Using coordinator id: %s", coordId)); Assert.assertNotNull(coordId, "Replication coordinator not found."); CoordinatorJob coordinatorJob = client.getCoordJobInfo(coordId); return coordinatorJob.getActions(); }