Repository: falcon Updated Branches: refs/heads/master 701347aa1 -> 05ee82e67
FALCON-1202: Feed Wizard multiple tests contributed by Namit Maheshwari Project: http://git-wip-us.apache.org/repos/asf/falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/05ee82e6 Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/05ee82e6 Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/05ee82e6 Branch: refs/heads/master Commit: 05ee82e677587fad3cc3f1cddbde6405ded1bcef Parents: 701347a Author: Raghav Kumar Gautam <[email protected]> Authored: Tue May 26 18:31:41 2015 -0700 Committer: Raghav Kumar Gautam <[email protected]> Committed: Tue May 26 18:32:48 2015 -0700 ---------------------------------------------------------------------- falcon-regression/CHANGES.txt | 2 + .../falcon/regression/Entities/FeedMerlin.java | 151 +++ .../ui/search/AbstractSearchPage.java | 15 + .../regression/ui/search/FeedWizardPage.java | 311 ++++++- .../regression/searchUI/FeedSetupTest.java | 913 ++++++++++++++++++- 5 files changed, 1367 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/falcon/blob/05ee82e6/falcon-regression/CHANGES.txt ---------------------------------------------------------------------- diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt index b64f11e..85fef51 100644 --- a/falcon-regression/CHANGES.txt +++ b/falcon-regression/CHANGES.txt @@ -5,6 +5,8 @@ Trunk (Unreleased) INCOMPATIBLE CHANGES NEW FEATURES + FALCON-1222 Feed Wizard multiple tests (Namit Maheshwari) + FALCON-1229 Tests for instance page on SearchUI (Ruslan Ostafiychuk) FALCON-1216 Cluster setup wizard multiple tests (Paul Isaychuk via Ruslan Ostafiychuk) http://git-wip-us.apache.org/repos/asf/falcon/blob/05ee82e6/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/Entities/FeedMerlin.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/Entities/FeedMerlin.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/Entities/FeedMerlin.java index 91ba8a1..cf25802 100644 --- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/Entities/FeedMerlin.java +++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/Entities/FeedMerlin.java @@ -37,7 +37,11 @@ import org.apache.falcon.entity.v0.feed.Retention; import org.apache.falcon.entity.v0.feed.Validity; import org.apache.falcon.entity.v0.feed.Sla; import org.apache.falcon.regression.core.util.TimeUtil; +import org.apache.falcon.regression.core.util.Util; import org.testng.Assert; +import org.apache.log4j.Logger; +import org.testng.asserts.SoftAssert; + import javax.xml.bind.JAXBException; import java.io.StringWriter; @@ -48,6 +52,7 @@ import java.util.Map; /** Class for representing a feed xml. */ public class FeedMerlin extends Feed { + private static final Logger LOGGER = Logger.getLogger(FeedMerlin.class); public FeedMerlin(String feedData) { this((Feed) TestEntityUtil.fromString(EntityType.FEED, feedData)); @@ -389,4 +394,150 @@ public class FeedMerlin extends Feed { return EntityType.FEED; } + public void assertGeneralProperties(FeedMerlin newFeed){ + + LOGGER.info(String.format("Comparing General Properties: source: %n%s%n and feed: %n%n%s", + Util.prettyPrintXml(toString()), Util.prettyPrintXml(newFeed.toString()))); + + SoftAssert softAssert = new SoftAssert(); + + // Assert all the the General Properties + softAssert.assertEquals(newFeed.getName(), getName(), + "Feed Name is different"); + softAssert.assertEquals(newFeed.getDescription(), getDescription(), + "Feed Description is different"); + softAssert.assertEquals(newFeed.getTags(), getTags(), + "Feed Tags is different"); + softAssert.assertEquals(newFeed.getGroups(), getGroups(), + "Feed Groups is different"); + softAssert.assertEquals(newFeed.getACL().getOwner(), getACL().getOwner(), + "Feed ACL Owner is different"); + softAssert.assertEquals(newFeed.getACL().getGroup(), getACL().getGroup(), + "Feed ACL Group is different"); + softAssert.assertEquals(newFeed.getACL().getPermission(), getACL().getPermission(), + "Feed ACL Permission is different"); + softAssert.assertEquals(newFeed.getSchema().getLocation(), getSchema().getLocation(), + "Feed Schema Location is different"); + softAssert.assertEquals(newFeed.getSchema().getProvider(), getSchema().getProvider(), + "Feed Schema Provider is different"); + softAssert.assertAll(); + + } + + public void assertPropertiesInfo(FeedMerlin newFeed){ + + LOGGER.info(String.format("Comparing Properties Info: source: %n%s%n and feed: %n%n%s", + Util.prettyPrintXml(toString()), Util.prettyPrintXml(newFeed.toString()))); + + SoftAssert softAssert = new SoftAssert(); + + // Assert all the Properties Info + softAssert.assertEquals(newFeed.getFrequency().getFrequency(), + getFrequency().getFrequency(), + "Feed Frequency is different"); + softAssert.assertEquals(newFeed.getFrequency().getTimeUnit().toString(), + getFrequency().getTimeUnit().toString(), + "Feed Frequency Unit is different"); + softAssert.assertEquals(newFeed.getLateArrival().getCutOff().getFrequencyAsInt(), + getLateArrival().getCutOff().getFrequencyAsInt(), + "Feed CutOff is different"); + softAssert.assertEquals(newFeed.getLateArrival().getCutOff().getTimeUnit(), + getLateArrival().getCutOff().getTimeUnit(), + "Feed CutOff Unit is different"); + softAssert.assertEquals(newFeed.getAvailabilityFlag(), + getAvailabilityFlag(), + "Feed Availability Flag is different"); + softAssert.assertEquals(newFeed.getProperties().getProperties().get(5).getName(), + getProperties().getProperties().get(0).getName(), + "Feed Property1 Name is different"); + softAssert.assertEquals(newFeed.getProperties().getProperties().get(5).getValue(), + getProperties().getProperties().get(0).getValue(), + "Feed Property1 Value is different"); + softAssert.assertEquals(newFeed.getProperties().getProperties().get(6).getName(), + getProperties().getProperties().get(1).getName(), + "Feed Property2 Name is different"); + softAssert.assertEquals(newFeed.getProperties().getProperties().get(6).getValue(), + getProperties().getProperties().get(1).getValue(), + "Feed Property2 Value is different"); + + softAssert.assertAll(); + } + + public void assertLocationInfo(FeedMerlin newFeed){ + + LOGGER.info(String.format("Comparing Location Info: source: %n%s%n and feed: %n%n%s", + Util.prettyPrintXml(toString()), Util.prettyPrintXml(newFeed.toString()))); + + SoftAssert softAssert = new SoftAssert(); + + // Assert all the Location Properties + softAssert.assertEquals(newFeed.getLocations().getLocations().get(0).getPath(), + getLocations().getLocations().get(0).getPath(), + "Feed Location Data Path is different"); + softAssert.assertEquals(newFeed.getLocations().getLocations().get(1).getPath(), + getLocations().getLocations().get(1).getPath(), + "Feed Location Stats Path is different"); + softAssert.assertEquals(newFeed.getLocations().getLocations().get(2).getPath(), + getLocations().getLocations().get(2).getPath(), + "Feed Location Meta Path is different"); + + softAssert.assertAll(); + + } + + public void assertClusterInfo(FeedMerlin newFeed){ + + LOGGER.info(String.format("Comparing Feed Cluster Info: source: %n%s%n and feed: %n%n%s", + Util.prettyPrintXml(toString()), Util.prettyPrintXml(newFeed.toString()))); + + SoftAssert softAssert = new SoftAssert(); + + // Assert all the Cluster Properties + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getName(), + getClusters().getClusters().get(0).getName(), + "Feed Cluster Name is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getLocations().getLocations().get(0).getPath(), + getLocations().getLocations().get(0).getPath(), + "Feed Cluster Data Path is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getLocations().getLocations().get(1).getPath(), + getLocations().getLocations().get(1).getPath(), + "Feed Cluster Stats Path is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getLocations().getLocations().get(2).getPath(), + getLocations().getLocations().get(2).getPath(), + "Feed Cluster Meta Path is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getValidity().getStart(), + getClusters().getClusters().get(0).getValidity().getStart(), + "Feed Cluster Start Date is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getValidity().getEnd(), + getClusters().getClusters().get(0).getValidity().getEnd(), + "Feed Cluster End Date is different"); + // Asserting on hardcoded value of 99, due to UI bug which only support till two digits. + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getRetention().getLimit().getFrequency(), "99", + "Feed Retention is different"); + softAssert.assertEquals(newFeed.getClusters().getClusters().get(0) + .getRetention().getLimit().getTimeUnit().name(), + getClusters().getClusters().get(0).getRetention().getLimit().getTimeUnit().name(), + "Feed Retention Unit is different"); + + softAssert.assertAll(); + + } + + public void assertEquals(FeedMerlin newFeed) { + + assertGeneralProperties(newFeed); + assertPropertiesInfo(newFeed); + assertLocationInfo(newFeed); + assertClusterInfo(newFeed); + } + + + } http://git-wip-us.apache.org/repos/asf/falcon/blob/05ee82e6/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java index 2778dcc..0c054e4 100644 --- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java +++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java @@ -28,6 +28,10 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.Select; + +import java.util.ArrayList; +import java.util.List; import java.util.List; @@ -70,6 +74,17 @@ public abstract class AbstractSearchPage extends Page { } + // Utility method to get Dropdown Values + public List<String> getDropdownValues(Select element){ + List<WebElement> allOptions = element.getOptions(); + List<String> values = new ArrayList<>(); + for (WebElement option:allOptions){ + values.add(option.getText()); + } + return values; + } + + protected void waitForAngularToFinish() { final String javaScript = "return (window.angular != null) && " + "(angular.element(document).injector() != null) && " http://git-wip-us.apache.org/repos/asf/falcon/blob/05ee82e6/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java ---------------------------------------------------------------------- diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java index 6eed4ce..9b68c95 100644 --- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java +++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java @@ -20,19 +20,24 @@ package org.apache.falcon.regression.ui.search; import org.apache.falcon.regression.Entities.FeedMerlin; import org.apache.falcon.regression.core.util.UIAssert; +import org.apache.log4j.Logger; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.ui.Select; +import org.testng.Assert; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; /** Page object of the Feed creation page. */ public class FeedWizardPage extends AbstractSearchPage { + private static final Logger LOGGER = Logger.getLogger(FeedWizardPage.class); + @FindBys({ @FindBy(className = "mainUIView"), @FindBy(className = "feedForm") @@ -47,20 +52,48 @@ public class FeedWizardPage extends AbstractSearchPage { private WebElement nextButton; @FindBys({ + @FindBy(className = "mainUIView"), + @FindBy(className = "feedForm"), + @FindBy(className = "prevBtn") + }) + private WebElement previousButton; + + @FindBys({ @FindBy(xpath = "//button[contains(.,'add tag')]") }) private WebElement addTagButton; @FindBys({ + @FindBy(xpath = "//button[contains(.,'delete')]") + }) + private WebElement deleteButton; + + @FindBys({ @FindBy(xpath = "//button[contains(.,'add property')]") }) private WebElement addPropertyButton; @FindBys({ + @FindBy(xpath = "//button[contains(.,'Catalog Storage')]") + }) + private WebElement catalogStorageButton; + + @FindBys({ @FindBy(id = "feed.step5") }) private WebElement saveFeedButton; + @FindBys({ + @FindBy(id = "feed.editXML") + }) + private WebElement editXmlButton; + + @FindBy(xpath = "//a[contains(.,'Cancel')]") + private WebElement cancelButton; + + @FindBy(xpath = "//textarea[@ng-model='prettyXml']") + private WebElement feedXml; + public FeedWizardPage(WebDriver driver) { super(driver); } @@ -104,8 +137,8 @@ public class FeedWizardPage extends AbstractSearchPage { private WebElement getFeedFrequencyQuantity() { return feedBox.findElement(By.xpath("//input[@ng-model='feed.frequency.quantity']")); } - private WebElement getFeedFrequencyUnit() { - return feedBox.findElement(By.xpath("//select[@ng-model='feed.frequency.unit']")); + private Select getFeedFrequencyUnit() { + return new Select(feedBox.findElement(By.xpath("//select[@ng-model='feed.frequency.unit']"))); } private WebElement getFeedLateArrivalCheckBox() { return feedBox.findElement(By.xpath("//input[@ng-model='feed.lateArrival.active']")); @@ -113,8 +146,8 @@ public class FeedWizardPage extends AbstractSearchPage { private WebElement getFeedLateArrivalCutOffQuantity() { return feedBox.findElement(By.xpath("//input[@ng-model='feed.lateArrival.cutOff.quantity']")); } - private WebElement getFeedLateArrivalCutOffUnit() { - return feedBox.findElement(By.xpath("//select[@ng-model='feed.lateArrival.cutOff.unit']")); + private Select getFeedLateArrivalCutOffUnit() { + return new Select(feedBox.findElement(By.xpath("//select[@ng-model='feed.lateArrival.cutOff.unit']"))); } private WebElement getFeedAvailabilityFlag() { return feedBox.findElement(By.xpath("//input[@ng-model='feed.availabilityFlag']")); @@ -122,6 +155,36 @@ public class FeedWizardPage extends AbstractSearchPage { private Select getFeedTimeZone() { return new Select(feedBox.findElement(By.xpath("//time-zone-select[@ng-model='feed.timezone']/select"))); } + + private WebElement getQueueName() { + return feedBox.findElement(By.xpath("//label[.='queueName']/following-sibling::div/input")); + } + + private Select getJobPriority() { + return new Select(feedBox.findElement(By.xpath("//label[.='jobPriority']/following-sibling::div/select"))); + } + + private WebElement getTimeoutQuantity() { + return feedBox.findElement(By.xpath("//label[.='timeout']/following-sibling::div/input")); + } + + private Select getTimeoutUnit() { + return new Select(feedBox.findElement(By.xpath("//label[.='timeout']/following-sibling::div/select"))); + } + + private WebElement getParallel() { + return feedBox.findElement(By.xpath("//label[.='parallel']/following-sibling::div/input")); + } + + private WebElement getMaxMaps() { + return feedBox.findElement(By.xpath("//label[.='maxMaps']/following-sibling::div/input")); + } + + private WebElement getMapBandwidthKB() { + return feedBox.findElement( + By.xpath("//label[.='mapBandwidthKB']/following-sibling::div/input")); + } + private WebElement getFeedPropertyKey(int index) { return feedBox.findElements(By.xpath("//input[@ng-model='property.key']")).get(index); } @@ -134,6 +197,11 @@ public class FeedWizardPage extends AbstractSearchPage { return feedBox.findElements(By.xpath("//input[@ng-model='location.path']")).get(index); } + private WebElement getFeedCatalogTableUri() { + return feedBox.findElement( + By.xpath("//input[@ng-model='feed.storage.catalog.catalogTable.uri']")); + } + private Select getFeedClusterSource() { return new Select(feedBox.findElement(By.id("clusterNameSelect"))); } @@ -142,8 +210,8 @@ public class FeedWizardPage extends AbstractSearchPage { return feedBox.findElement(By.xpath("//input[@ng-model='cluster.retention.quantity']")); } - private WebElement getFeedClusterRetentionUnit() { - return feedBox.findElement(By.xpath("//select[@ng-model='cluster.retention.unit']")); + private Select getFeedClusterRetentionUnit() { + return new Select(feedBox.findElement(By.xpath("//select[@ng-model='cluster.retention.unit']"))); } private WebElement getFeedClusterValidityStartDate() { @@ -166,6 +234,106 @@ public class FeedWizardPage extends AbstractSearchPage { return feedBox.findElement(By.xpath("//input[@ng-model='cluster.validity.end.date']")); } + public List<String> getFeedFrequencyUnitValues(){ + return getDropdownValues(getFeedFrequencyUnit()); + } + + public List<String> getFeedLateArrivalCutOffUnitValues(){ + return getDropdownValues(getFeedLateArrivalCutOffUnit()); + } + + public List<String> getFeedClusterSourceValues(){ + return getDropdownValues(getFeedClusterSource()); + } + + public List<String> getFeedClusterRetentionUnitValues(){ + return getDropdownValues(getFeedClusterRetentionUnit()); + } + + public List<String> getJobPriorityValues(){ + return getDropdownValues(getJobPriority()); + } + + public List<String> getTimeoutUnitValues(){ + return getDropdownValues(getTimeoutUnit()); + } + + public void isFeedFrequencyDisplayed(boolean isDisplayed) { + if (isDisplayed){ + UIAssert.assertDisplayed(getFeedFrequencyQuantity(), "Frequency Quantity"); + }else { + try{ + getFeedFrequencyQuantity(); + Assert.fail("Frequency Quantity found"); + } catch (Exception ex){ + LOGGER.info("Frequency Quantity not found"); + } + } + } + + public void isFeedDataPathDisplayed(boolean isDisplayed) { + if (isDisplayed){ + UIAssert.assertDisplayed(getFeedPath(0), "Feed Data Path"); + }else { + try{ + getFeedPath(0); + Assert.fail("Feed Data Path found"); + } catch (Exception ex){ + LOGGER.info("Feed Data Path not found"); + } + } + } + + public void isFeedClusterRetentionDisplayed(boolean isDisplayed) { + if (isDisplayed){ + UIAssert.assertDisplayed(getFeedClusterRetentionLimit(), "Cluster Retention Limit"); + }else { + try{ + getFeedClusterRetentionLimit(); + Assert.fail("Cluster Retention Limit found"); + } catch (Exception ex){ + LOGGER.info("Cluster Retention Limit not found"); + } + } + } + + public void isSaveFeedButtonDisplayed(boolean isDisplayed) { + if (isDisplayed){ + UIAssert.assertDisplayed(saveFeedButton, "Save Button"); + }else { + try{ + getSaveFeedButton(); + Assert.fail("Save Button found"); + } catch (Exception ex){ + LOGGER.info("Save Button not found"); + } + } + } + + private WebElement getSaveFeedButton(){ + return saveFeedButton; + } + + public void clickNext(){ + nextButton.click(); + } + + public void clickPrevious(){ + previousButton.click(); + } + + public void clickCancel(){ + cancelButton.click(); + } + + public void clickEditXml(){ + editXmlButton.click(); + } + + public void clickCatalogStorageButton(){ + catalogStorageButton.click(); + } + public void setFeedName(String name){ sendKeysSlowly(getFeedName(), name); } @@ -178,6 +346,7 @@ public class FeedWizardPage extends AbstractSearchPage { public void setFeedTagValue(int index, String tagValue){ getFeedTagValue(index).sendKeys(tagValue); } + // Tags are in the format, "first=yes","second=yes","third=yes". Need a separate method to handle this public void setFeedTags(String tagsStr){ if (tagsStr == null){ @@ -194,9 +363,91 @@ public class FeedWizardPage extends AbstractSearchPage { } } + public void isTagsDisplayed(int index, boolean isDisplayed){ + if (isDisplayed){ + UIAssert.assertDisplayed(getFeedTagKey(index), "Tag Key Index - " + index); + UIAssert.assertDisplayed(getFeedTagValue(index), "Tag Value Index - " + index); + }else{ + try{ + getFeedTagKey(index); + Assert.fail("Tag Key Index - " + index + " found"); + } catch (Exception ex){ + LOGGER.info("Tag Key Index - " + index + " not found"); + } + try{ + getFeedTagValue(index); + Assert.fail("Tag Key Value - " + index + " found"); + } catch (Exception ex){ + LOGGER.info("Tag Key Value - " + index + " not found"); + } + } + } + + public String getFeedTagKeyText(int index){ + return getFeedTagKey(index).getAttribute("value"); + } + + public String getFeedTagValueText(int index){ + return getFeedTagValue(index).getAttribute("value"); + } + + public String getFeedGroupsText(){ + return getFeedGroups().getAttribute("value"); + } + + public String getFeedFrequencyQuantityText(){ + return getFeedFrequencyQuantity().getAttribute("value"); + } + + public String getFeedLateArrivalCutOffQuantityText(){ + return getFeedLateArrivalCutOffQuantity().getAttribute("value"); + } + + public String getFeedPathText(int index){ + return getFeedPath(index).getAttribute("value"); + } + + public String getFeedClusterRetentionLimitText(){ + return getFeedClusterRetentionLimit().getAttribute("value"); + } + + public String getFeedClusterRetentionUnitText(){ + return getFeedClusterRetentionUnit().getFirstSelectedOption().getText(); + } + + public void addProperty(){ + addPropertyButton.click(); + } + + public void isPropertyDisplayed(int index, boolean isDisplayed){ + if (isDisplayed){ + UIAssert.assertDisplayed(getFeedPropertyKey(index), "Property Key Index - " + index); + UIAssert.assertDisplayed(getFeedPropertyValue(index), "Property Value Index - " + index); + }else{ + try{ + getFeedTagKey(index); + Assert.fail("Property Key Index - " + index + " found"); + } catch (Exception ex){ + LOGGER.info("Property Key Index - " + index + " not found"); + } + try{ + getFeedTagValue(index); + Assert.fail("Property Key Value - " + index + " found"); + } catch (Exception ex){ + LOGGER.info("Property Key Value - " + index + " not found"); + } + } + } + + + public void deleteTagOrProperty(){ + deleteButton.click(); + } + public void setFeedGroups(String feedGroups){ getFeedGroups().sendKeys(feedGroups); } + public void setFeedACLOwner(String feedACLOwner){ getFeedACLOwner().clear(); getFeedACLOwner().sendKeys(feedACLOwner); @@ -220,8 +471,9 @@ public class FeedWizardPage extends AbstractSearchPage { getFeedFrequencyQuantity().sendKeys(frequencyQuantity); } public void setFeedFrequencyUnit(String frequencyUnit){ - getFeedFrequencyUnit().sendKeys(frequencyUnit); + getFeedFrequencyUnit().selectByVisibleText(frequencyUnit); } + public void setFeedLateArrivalCheckBox(){ getFeedLateArrivalCheckBox().click(); } @@ -229,7 +481,7 @@ public class FeedWizardPage extends AbstractSearchPage { getFeedLateArrivalCutOffQuantity().sendKeys(Integer.toString(lateArrivalCutOffQuantity)); } public void setFeedLateArrivalCutOffUnit(String lateArrivalCutOffUnit){ - getFeedLateArrivalCutOffUnit().sendKeys(lateArrivalCutOffUnit); + getFeedLateArrivalCutOffUnit().selectByVisibleText(lateArrivalCutOffUnit); } public void setFeedAvailabilityFlag(String availabilityFlag){ getFeedAvailabilityFlag().sendKeys(availabilityFlag); @@ -238,6 +490,32 @@ public class FeedWizardPage extends AbstractSearchPage { String timeZone = "GMT+00:00"; getFeedTimeZone().selectByValue(timeZone); } + public void setQueueName(String queueName){ + getQueueName().clear(); + getQueueName().sendKeys(queueName); + } + public void setJobPriority(String jobPriority) { + getJobPriority().selectByVisibleText(jobPriority); + } + public void setTimeoutQuantity(String timeoutQuantity){ + getTimeoutQuantity().clear(); + getTimeoutQuantity().sendKeys(timeoutQuantity); + } + public void setTimeoutUnit(String timeoutUnit) { + getTimeoutUnit().selectByVisibleText(timeoutUnit); + } + public void setParallel(String parallel){ + getParallel().clear(); + getParallel().sendKeys(parallel); + } + public void setMaxMaps(String maxMaps){ + getMaxMaps().clear(); + getMaxMaps().sendKeys(maxMaps); + } + public void setMapBandwidthKB(String mapBandwidthKB){ + getMapBandwidthKB().clear(); + getMapBandwidthKB().sendKeys(mapBandwidthKB); + } public void setFeedPropertyKey(int index, String propertyKey){ getFeedPropertyKey(index).sendKeys(propertyKey); } @@ -246,9 +524,14 @@ public class FeedWizardPage extends AbstractSearchPage { } public void setFeedPath(int index, String path){ + getFeedPath(index).clear(); getFeedPath(index).sendKeys(path); } + public void setFeedCatalogTableUri(String catalogTableUri){ + getFeedCatalogTableUri().sendKeys(catalogTableUri); + } + public void setFeedClusterSource(String clusterSource){ getFeedClusterSource().selectByVisibleText(clusterSource); } @@ -259,7 +542,7 @@ public class FeedWizardPage extends AbstractSearchPage { } public void setFeedClusterRetentionUnit(String clusterRetentionUnit){ - getFeedClusterRetentionUnit().sendKeys(clusterRetentionUnit); + getFeedClusterRetentionUnit().selectByVisibleText(clusterRetentionUnit); } public void setFeedClusterValidityStartDate(String clusterValidityStartDate){ @@ -360,4 +643,14 @@ public class FeedWizardPage extends AbstractSearchPage { saveFeedButton.click(); } + public FeedMerlin getFeedMerlinFromFeedXml() throws Exception{ + waitForAngularToFinish(); + return FeedMerlin.fromString(feedXml.getAttribute("value")); + } + + public void setFeedXml(String xml) throws Exception{ + feedXml.clear(); + feedXml.sendKeys(xml); + } + } http://git-wip-us.apache.org/repos/asf/falcon/blob/05ee82e6/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 8920f41..c09cfad 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 @@ -19,6 +19,9 @@ package org.apache.falcon.regression.searchUI; import org.apache.commons.lang.StringUtils; +import org.apache.falcon.entity.v0.Frequency; +import org.apache.falcon.entity.v0.feed.LateArrival; +import org.apache.falcon.regression.Entities.ClusterMerlin; import org.apache.falcon.regression.Entities.FeedMerlin; import org.apache.falcon.regression.core.bundle.Bundle; import org.apache.falcon.regression.core.helpers.ColoHelper; @@ -31,12 +34,15 @@ import org.apache.falcon.regression.ui.search.LoginPage; import org.apache.falcon.regression.ui.search.SearchPage; import org.apache.hadoop.fs.FileSystem; import org.apache.log4j.Logger; +import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Random; @@ -53,7 +59,12 @@ public class FeedSetupTest extends BaseUITestClass{ private String aggregateWorkflowDir = baseTestHDFSDir + "/aggregator"; private String feedInputPath = baseTestHDFSDir + "/input" + MINUTE_DATE_PATTERN; private FeedMerlin feed; - private String[] tags = {"first=yes", "second=yes", "third=yes", "wrong=no"}; + private ClusterMerlin clusterFromBundle; + private final String[] tags = {"first=yes", "second=yes", "third=yes", "wrong=no"}; + private final List<String> timeUnits = new ArrayList<>(Arrays.asList("minutes", "hours", "days", "months")); + private final List<String> jobPriorities = new ArrayList<>(Arrays.asList("-Select job-", + "Very high", "High", "Normal", "Low", "Very Low")); + private final String catalogUri = "catalog:default:test_input_table#dt=${YEAR}-${MONTH}-${DAY}-${HOUR}-${MINUTE}"; private String getRandomTags() { List<String> tagsList = new ArrayList<>(); @@ -67,6 +78,9 @@ public class FeedSetupTest extends BaseUITestClass{ if (r.nextInt(2) == 0) { tagsList.add(tags[2]); } + if (tagsList.isEmpty()){ + return null; + } return StringUtils.join(tagsList, ','); } @@ -81,6 +95,7 @@ public class FeedSetupTest extends BaseUITestClass{ bundle.setInputFeedDataPath(feedInputPath); bundle.submitClusters(prism); feed = FeedMerlin.fromString(bundle.getInputFeedFromBundle()); + clusterFromBundle = bundle.getClusterElement(); } @AfterMethod(alwaysRun = true) @@ -89,35 +104,901 @@ public class FeedSetupTest extends BaseUITestClass{ closeBrowser(); } - /* - Check that buttons (logout, entities, uploadXml, help, Falcon) are present, and - names are correct. Check the user name on header. "Create an entity"/ - "upload an entity" headers. Check that each button navigates user to correct page + /** + * Check that buttons (logout, entities, uploadXml, help, Falcon) are present, and names are + * correct. + * Check the user name on header. + * Create an entity / upload an entity headers. Check that each button navigates user to + * correct page + * @throws Exception */ @Test public void testHeader() throws Exception { feedWizardPage.getPageHeader().checkHeader(); } - /* - Run full feed creation scenario. + /** + * Run full feed creation scenario. + * @throws Exception */ @Test public void testWizardDefaultScenario() throws Exception { - // Set few values in feed, if they are null (Currently null in the FeedMerlin) - if (feed.getTags() == null){ - feed.setTags(getRandomTags()); - } - if (feed.getGroups() == null){ - feed.setGroups("groups"); + feed.setTags(getRandomTags()); + feed.setGroups("groups"); + feed.setAvailabilityFlag("_SUCCESS"); + feedWizardPage.setFeed(feed); + //Check the response to validate if the feed creation went successfully + ServiceResponse response = prism.getFeedHelper().getEntityDefinition(feed.toString()); + AssertUtil.assertSucceeded(response); + } + + /** + * Click Cancel on each page. Check that user was navigated to Home page. + * @throws Exception + */ + @Test + public void testWizardCancel() throws Exception { + // Step 1 - Check cancel on the first page - General Info Page + feedWizardPage.clickCancel(); + searchPage.checkPage(); + + // Step 2 - Check cancel on the second page - Properties Info Page + feedWizardPage = searchPage.getPageHeader().doCreateFeed(); + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.clickCancel(); + searchPage.checkPage(); + + // Step 3 - Check cancel on the third page - Location Info Page + feedWizardPage = searchPage.getPageHeader().doCreateFeed(); + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.clickCancel(); + searchPage.checkPage(); + + // Step 4 - Check cancel on the fourth page - Cluster Info Page + feedWizardPage = searchPage.getPageHeader().doCreateFeed(); + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.clickCancel(); + searchPage.checkPage(); + + // Step 5 - Check cancel on the fifth page - Summary Page + feedWizardPage = searchPage.getPageHeader().doCreateFeed(); + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.setFeedClustersInfo(feed); + feedWizardPage.clickNext(); + feedWizardPage.clickCancel(); + searchPage.checkPage(); + + } + + /** + * Check that XML Preview reflects changes correctly. + * @throws Exception + */ + @Test + public void testWizardXmlPreview() throws Exception{ + + feed.setTags(getRandomTags()); + feed.setGroups("groups"); + feed.setAvailabilityFlag("_SUCCESS"); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the General Info Page + feed.assertGeneralProperties(feedFromXML); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the Properties Info Page + feed.assertPropertiesInfo(feedFromXML); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the Location Info Page + feed.assertLocationInfo(feedFromXML); + + + // Set values on the Cluster Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedClustersInfo(feed); + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + + // Assert all the values entered on the Cluster Info Page + feed.assertClusterInfo(feedFromXML); + + } + + /** + * Add few properties to the feed (tag, group). + * Click edit XML. Remove both properties from XML. + * Check that properties were removed from matching fields. + * Now click Edit XML again. Add new tag, group to the XML. + * Check that changes have been reflected on wizard page. + * @throws Exception + */ + @Test + public void testGeneralStepEditXml() throws Exception{ + + feed.setTags("first=yes,second=yes"); + feed.setGroups("groups"); + + // Set tag and group on the Wizard + feedWizardPage.setFeedTags(feed.getTags()); + feedWizardPage.setFeedGroups(feed.getGroups()); + + // Get XML, and set tag and group back to null + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + 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(); + + // Assert that there is only one Tag on the Wizard window + feedWizardPage.isTagsDisplayed(0, true); + feedWizardPage.isTagsDisplayed(1, false); + + // Assert that the Tag value is empty on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedTagKeyText(0), "", + "Tag Key Should be empty on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedTagValueText(0), "", + "Tag Value Should be empty on the Wizard window"); + + // Assert that the Group value is empty on the Wizard window now + Assert.assertEquals(feedWizardPage.getFeedGroupsText(), "", + "Group Should be empty on the Wizard window"); + + // Set Tag and Group values + feedFromXML.setTags("third=yes,fourth=no"); + feedFromXML.setGroups("groups_new"); + + // Now click EditXML and set the updated XML here + feedWizardPage.clickEditXml(); + xmlToString = feedFromXML.toString(); + feedWizardPage.setFeedXml(xmlToString); + feedWizardPage.clickEditXml(); + + // Assert that there are two Tags on the Wizard window + feedWizardPage.isTagsDisplayed(0, true); + feedWizardPage.isTagsDisplayed(1, true); + + // Assert that the Tag values are correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedTagKeyText(0), "third", + "Unexpected Tag1 Key on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedTagValueText(0), "yes", + "Unexpected Tag1 Value on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedTagKeyText(1), "fourth", + "Unexpected Tag2 Key on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedTagValueText(1), "no", + "Unexpected Tag2 Value on the Wizard window"); + + // Assert that the Group value is correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedGroupsText(), "groups_new", + "Unexpected Group on the Wizard window"); + + } + + /** + * Populate fields with valid values (name, description, tag, groups, ACL, schema). + * Check that user can go to the next step (click next)" + * @throws Exception + */ + @Test + public void testGeneralStepDefaultScenario() throws Exception{ + + feed.setTags(getRandomTags()); + feed.setGroups("groups"); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + + // Assert on the click of next, the Page moves to the next page + feedWizardPage.isFeedFrequencyDisplayed(true); + + } + + /** + * Populate fields with valid values (name, description, tag, groups, ACL, schema)\ + * Check that they are reflected on XML preview. + * @throws Exception + */ + @Test + public void testGeneralStepXmlPreview() throws Exception{ + + feed.setTags(getRandomTags()); + feed.setGroups("groups"); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the General Info Page + feed.assertGeneralProperties(feedFromXML); + + } + + /** + * Add two tags to the feed. Check that they are present. + * Check XML preview has it. + * Delete one tag. Check that it has been removed from wizard window as well as from XML preview. + * @throws Exception + */ + @Test + public void testGeneralStepAddRemoveTag() throws Exception{ + + // Set Tags in feed + feed.setTags("first=yes,second=yes"); + + // Set Tag on the General Info Page + feedWizardPage.setFeedTags(feed.getTags()); + + // Assert two tags are present on the Wizard window + feedWizardPage.isTagsDisplayed(0, true); + feedWizardPage.isTagsDisplayed(1, true); + + // Get feed from XML Preview + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert Tag values in the XML Preview + Assert.assertEquals(feedFromXML.getTags(), feed.getTags()); + + // Delete the Tag + feedWizardPage.deleteTagOrProperty(); + + // Assert that there is only one Tag on the Wizard window + feedWizardPage.isTagsDisplayed(0, true); + feedWizardPage.isTagsDisplayed(1, false); + + // Get feed from XML Preview + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + // Assert that there are is only one Tag in the XML Preview + Assert.assertEquals(feedFromXML.getTags(), "first=yes", + "Unexpected Tags on the XML preview"); + + } + + + /** + * Make sure that optional fields are actually optional i.e. keep blank for the + * optional fields for this test user should be able to go to next step. + * @throws Exception + */ + @Test + public void testGeneralStepBlankOptionalFields() throws Exception{ + + // Only setting the required fields + feedWizardPage.setFeedName(feed.getName()); + feedWizardPage.setFeedACLOwner(feed.getACL().getOwner()); + feedWizardPage.setFeedACLGroup(feed.getACL().getGroup()); + feedWizardPage.setFeedACLPermissions(feed.getACL().getPermission()); + feedWizardPage.setFeedSchemaLocation(feed.getSchema().getLocation()); + feedWizardPage.setFeedSchemaProvider(feed.getSchema().getProvider()); + feedWizardPage.clickNext(); + + // Assert that user is able to go to next page using only required fields + feedWizardPage.isFeedFrequencyDisplayed(true); + } + + /** + * Populate all fields with valid values (frequency, parallel...). + * Check that user can go to the next step. + * @throws Exception + */ + @Test + public void testTimingStepDefaultScenario() throws Exception{ + + feed.setAvailabilityFlag("_SUCCESS"); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedFrequencyQuantity(feed.getFrequency().getFrequency()); + feedWizardPage.setFeedFrequencyUnit(feed.getFrequency().getTimeUnit().toString()); + feedWizardPage.setFeedLateArrivalCheckBox(); + feedWizardPage.setFeedLateArrivalCutOffQuantity( + feed.getLateArrival().getCutOff().getFrequencyAsInt()); + feedWizardPage.setFeedLateArrivalCutOffUnit( + feed.getLateArrival().getCutOff().getTimeUnit().toString()); + feedWizardPage.setFeedAvailabilityFlag(feed.getAvailabilityFlag()); + feedWizardPage.setFeedTimeZone(); + feedWizardPage.setQueueName("Default"); + feedWizardPage.setJobPriority("High"); + feedWizardPage.setTimeoutQuantity("30"); + feedWizardPage.setTimeoutUnit("minutes"); + feedWizardPage.setParallel("4"); + feedWizardPage.setMaxMaps("7"); + feedWizardPage.setMapBandwidthKB("2048"); + feedWizardPage.setFeedPropertyKey(0, feed.getProperties().getProperties().get(0).getName()); + feedWizardPage.setFeedPropertyValue(0, + feed.getProperties().getProperties().get(0).getValue()); + feedWizardPage.addProperty(); + feedWizardPage.setFeedPropertyKey(1, feed.getProperties().getProperties().get(1).getName()); + feedWizardPage.setFeedPropertyValue(1, + feed.getProperties().getProperties().get(1).getValue()); + + feedWizardPage.clickNext(); + + // Assert user is able to go on the next page + feedWizardPage.isFeedDataPathDisplayed(true); + + } + + /** + * Populate fields with valid values (frequency, late arrival, availability flag, so on) + * Check that they are reflected on XML preview. + * @throws Exception + */ + @Test + public void testTimingStepXmlPreview() throws Exception{ + + feed.setAvailabilityFlag("_SUCCESS"); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the Properties Info Page + feed.assertPropertiesInfo(feedFromXML); + + } + + /** + * Add some properties to the feed (frequency, late arrival). + * Click edit XML. Remove both properties from XML. + * Check that properties were removed from matching fields. + * Now click Edit XML again. Add new properties to the XML. + * Check that changes have been reflected on wizard page. + * @throws Exception + */ + @Test + public void testTimingStepEditXml() throws Exception{ + + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + + // Set Frequency and Late Arrival on the Wizard + feedWizardPage.setFeedFrequencyQuantity(feed.getFrequency().getFrequency()); + feedWizardPage.setFeedFrequencyUnit(feed.getFrequency().getTimeUnit().toString()); + feedWizardPage.setFeedLateArrivalCheckBox(); + feedWizardPage.setFeedLateArrivalCutOffQuantity(feed.getLateArrival().getCutOff().getFrequencyAsInt()); + feedWizardPage.setFeedLateArrivalCutOffUnit(feed.getLateArrival().getCutOff().getTimeUnit().toString()); + + // Get XML, and set Frequency and Late Arrival back to null + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + 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(); + + // Assert that the Frequency value is empty on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedFrequencyQuantityText(), "", + "Frequency Quantity Should be empty on the Wizard window"); + + // Assert that the Late Arrival value is empty on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedLateArrivalCutOffQuantityText(), "", + "CutOff Quantity Should be empty on the Wizard window"); + + // Set Frequency and Late Arrival values + feedFromXML.setFrequency(new Frequency("5", Frequency.TimeUnit.minutes)); + feedFromXML.setLateArrival(new LateArrival()); + 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(); + + // Assert that the Frequency values are correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedFrequencyQuantityText(), "5", + "Unexpected Frequency on the XML preview"); + + // Assert that the Late Arrival value is correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedLateArrivalCutOffQuantityText(), "1", + "Unexpected CutOff on the XML preview"); + + } + + /** + * Check that frequency, late arrival and timeout drop downs contain correct items (timeunits). + * Check that jobPriority dropDown contains valid priorities. + * @throws Exception + */ + @Test + public void testTimingStepDropDownLists() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + + List<String> dropdownValues = feedWizardPage.getFeedFrequencyUnitValues(); + Assert.assertEquals(timeUnits, dropdownValues, "Frequency Unit Values Are Not Equal"); + + dropdownValues = feedWizardPage.getFeedLateArrivalCutOffUnitValues(); + Assert.assertEquals(timeUnits, dropdownValues, "Late Arrival Unit Values Are Not Equal"); + + dropdownValues = feedWizardPage.getJobPriorityValues(); + Assert.assertEquals(jobPriorities, dropdownValues, "Job Priority Unit Values Are Not Equal"); + + dropdownValues = feedWizardPage.getTimeoutUnitValues(); + Assert.assertEquals(timeUnits, dropdownValues, "Timeout Unit Values Are Not Equal"); + } + + + /** + * Add two properties to the feed. Check that they are present (as separate element) on the + * page. + * Check XML preview has it. Delete one property. Check that it has been removed from wizard + * window as well as from XML preview. + * @throws Exception + */ + @Test + public void testTimingStepAddDeleteProperties() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + feedWizardPage.clickNext(); + // Set first property + feedWizardPage.setFeedPropertyKey(0, feed.getProperties().getProperties().get(0).getName()); + feedWizardPage.setFeedPropertyValue(0, + feed.getProperties().getProperties().get(0).getValue()); + // Click add property button + feedWizardPage.addProperty(); + // Set second property + feedWizardPage.setFeedPropertyKey(1, feed.getProperties().getProperties().get(1).getName()); + feedWizardPage.setFeedPropertyValue(1, + feed.getProperties().getProperties().get(1).getValue()); + + // Assert two Properties are present on the Wizard window + feedWizardPage.isPropertyDisplayed(0, true); + feedWizardPage.isPropertyDisplayed(1, true); + + // Get feed from XML Preview + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert Property values in the XML Preview + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(5).getName(), + feed.getProperties().getProperties().get(0).getName(), + "Unexpected Property1 Name on the XML preview"); + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(5).getValue(), + feed.getProperties().getProperties().get(0).getValue(), + "Unexpected Property1 Value on the XML preview"); + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(6).getName(), + feed.getProperties().getProperties().get(1).getName(), + "Unexpected Property2 Name on the XML preview"); + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(6).getValue(), + feed.getProperties().getProperties().get(1).getValue(), + "Unexpected Property2 Value on the XML preview"); + + + // Delete one Property + feedWizardPage.deleteTagOrProperty(); + + // Assert only one Property is present on the Wizard window + feedWizardPage.isPropertyDisplayed(0, true); + feedWizardPage.isPropertyDisplayed(1, false); + + + // Get feed from XML Preview + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert Property value in the XML Preview + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(5).getName(), + feed.getProperties().getProperties().get(0).getName(), + "Unexpected Property1 Name on the XML preview"); + Assert.assertEquals(feedFromXML.getProperties().getProperties().get(5).getValue(), + feed.getProperties().getProperties().get(0).getValue(), + "Unexpected Property1 Value on the XML preview"); + try{ + feedFromXML.getProperties().getProperties().get(6); + Assert.fail("Second Property found in the XML Preview"); + } catch (Exception ex){ + LOGGER.info("Second Property not found in the XML Preview"); } - if (feed.getAvailabilityFlag() == null){ - feed.setAvailabilityFlag("_SUCCESS"); + + } + + + /** + * Populate locations with valid values. + * Check that user can go to the next step. + * @throws Exception + */ + @Test + public void testLocationStepValidValuesFS() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + feedWizardPage.clickNext(); + // Assert user is able to go on the next page + feedWizardPage.isFeedClusterRetentionDisplayed(true); + + } + + /** + * Select Catalog Storage and populate it with valid value. + * Check that user is allowed to go to the next step. + * @throws Exception + */ + @Test + public void testLocationStepValidCatalogStorage() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Select Catalog Storage and Set Table Uri on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.clickCatalogStorageButton(); + feedWizardPage.setFeedCatalogTableUri(catalogUri); + + feedWizardPage.clickNext(); + + // Assert user is able to go to the next Page + feedWizardPage.isFeedClusterRetentionDisplayed(true); + } + + /** + * Populate locations fields with values as well as Catalog table uri. + * Check that user is not allowed to go to the next step and is notified with an appropriate alert. + * @throws Exception + */ + @Test + public void testLocationStepBothLocationsAndTableUri() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + // Select Catalog Storage and Set Table Uri on the Location Info Page + feedWizardPage.clickCatalogStorageButton(); + feedWizardPage.setFeedCatalogTableUri(catalogUri); + + feedWizardPage.clickNext(); + + // Assert user should not be able to go to the next Page + feedWizardPage.isFeedClusterRetentionDisplayed(false); + + } + + /** + * Populate locations with valid values and check that they are reflected on XML preview. + * Click edit XML. Change locations. Check that changes are reflected on XML as well as on wizard page. + * @throws Exception + */ + @Test + public void testLocationStepEditXml() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + // Get feed from XML Preview + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the Location Info Page + feed.assertLocationInfo(feedFromXML); + // Set new Location Paths + feedFromXML.getLocations().getLocations().get(0).setPath( + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); + feedFromXML.getLocations().getLocations().get(1).setPath(baseTestHDFSDir + "/newFalcon/clicksStats"); + 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(); + + // Get feed from XML Preview + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + // Assert all the values on the Location Info Page + Assert.assertEquals(feedFromXML.getLocations().getLocations().get(0).getPath(), + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); + Assert.assertEquals(feedFromXML.getLocations().getLocations().get(1).getPath(), + baseTestHDFSDir + "/newFalcon/clicksStats"); + Assert.assertEquals(feedFromXML.getLocations().getLocations().get(2).getPath(), + baseTestHDFSDir + "/newFalcon/clicksMetaData"); + + // Assert that the Location Path values are correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedPathText(0), + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}", + "Unexpected Cluster Data Location on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedPathText(1), + baseTestHDFSDir + "/newFalcon/clicksStats", + "Unexpected Cluster Stats Location on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedPathText(2), + baseTestHDFSDir +"/newFalcon/clicksMetaData", + "Unexpected Cluster Meta Location on the Wizard window"); + + + } + + /** + * Populate each field with correct values (cluster, validity ...). + * Check that user can go to the next step. + * @throws Exception + */ + @Test + public void testClustersStepDefaultScenario() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + // Set values on the Cluster Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedClustersInfo(feed); + + feedWizardPage.clickNext(); + + // Assert user is able to go to the next Page + feedWizardPage.isSaveFeedButtonDisplayed(true); + } + + /** + * Submit few clusters. Check that cluster list contains all clusters. + * Check that retention drop down lists contains valid time units. + * @throws Exception + */ + @Test + public void testClustersStepDropDownLists() throws Exception{ + + List<String> allClusters = new ArrayList<>(); + // Add four more clusters + for (int i=0; i< 4; i++){ + ClusterMerlin newCluster = new ClusterMerlin(clusterFromBundle.toString()); + newCluster.setName(clusterFromBundle.getName() + "-" + i); + AssertUtil.assertSucceeded(prism.getClusterHelper().submitEntity(newCluster.toString())); + allClusters.add(newCluster.getName()); } + // Also add base cluster and -Select cluster- to allCluster array + allClusters.add(feed.getClusters().getClusters().get(0).getName()); + allClusters.add("-Select cluster-"); + Collections.sort(allClusters); + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + feedWizardPage.clickNext(); + // Assert cluster source drop down contains all the clusters + List<String> dropdownValues = feedWizardPage.getFeedClusterSourceValues(); + Collections.sort(dropdownValues); + Assert.assertEquals(allClusters, dropdownValues, + "Cluster Source Values Are Not Equal"); + + // Assert retention drop down time units + dropdownValues = feedWizardPage.getFeedClusterRetentionUnitValues(); + Assert.assertEquals(timeUnits, dropdownValues, "Retention Unit Values Are Not Equal"); + + } + + /** + * Populate FS locations on previous step. Don't populate any values on the current step. + * Go to the next one. Check that XML preview has locations provided on Location step. + * Repeat the same for Catalog URI. + * @throws Exception + */ + @Test + public void testClustersStepDefaultLocations() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + feedWizardPage.clickNext(); + // Get feed from XML Preview + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values entered on the Location Info Page + feed.assertLocationInfo(feedFromXML); + + feedWizardPage.clickPrevious(); + // Clear all the Location Info + feedWizardPage.setFeedPath(0, ""); + feedWizardPage.setFeedPath(1, ""); + feedWizardPage.setFeedPath(2, ""); + + // Select Catalog Storage and Set Table Uri on the Location Info Page + feedWizardPage.clickCatalogStorageButton(); + feedWizardPage.setFeedCatalogTableUri(catalogUri); + + feedWizardPage.clickNext(); + + // Get feed from XML Preview + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert the Table Uri value entered on the Location Info Page + Assert.assertEquals(feedFromXML.getTable().getUri(), catalogUri, + "Unexpected Cluster URI on the XML preview"); + + } + + /** + * Populate all fields with valid values and check that they are reflected on XML preview. + * Click edit XML. Change retention and locations. + * Check that changes are reflected on XML as well as on wizard page. + * @throws Exception + */ + @Test + public void testClusterStepEditXml() throws Exception{ + + // Set values on the General Info Page + feedWizardPage.setFeedGeneralInfo(feed); + + // Set values on the Properties Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedPropertiesInfo(feed); + + // Set values on the Location Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedLocationInfo(feed); + + // Set values on the Cluster Info Page + feedWizardPage.clickNext(); + feedWizardPage.setFeedClustersInfo(feed); + + // Get feed from XML Preview + FeedMerlin feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + + // Assert all the values on the Cluster Info Page + feed.assertClusterInfo(feedFromXML); + + + // Set new Location and Retention + feedFromXML.getClusters().getClusters().get(0).getLocations().getLocations().get(0).setPath( + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}"); + feedFromXML.getClusters().getClusters().get(0).getLocations().getLocations().get(1).setPath( + baseTestHDFSDir + "/newFalcon/clicksStats"); + feedFromXML.getClusters().getClusters().get(0).getLocations().getLocations().get(2).setPath( + baseTestHDFSDir + "/newFalcon/clicksMetaData"); + feedFromXML.getClusters().getClusters().get(0).getRetention(). + setLimit(new Frequency("60", Frequency.TimeUnit.minutes)); + + + // Now click EditXML and set the updated XML here + feedWizardPage.clickEditXml(); + String xmlToString = feedFromXML.toString(); + feedWizardPage.setFeedXml(xmlToString); + feedWizardPage.clickEditXml(); + + // Get feed from XML Preview + feedFromXML = feedWizardPage.getFeedMerlinFromFeedXml(); + // Assert all the values on the Location Info Page + Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) + .getLocations().getLocations().get(0).getPath(), + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}", + "Unexpected Cluster Data Path on the XML preview"); + Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) + .getLocations().getLocations().get(1).getPath(), + baseTestHDFSDir + "/newFalcon/clicksStats", + "Unexpected Cluster Stats Path on the XML preview"); + Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) + .getLocations().getLocations().get(2).getPath(), + baseTestHDFSDir + "/newFalcon/clicksMetaData", + "Unexpected Cluster Meta Path on the XML preview"); + Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) + .getRetention().getLimit().getFrequency(), "60", + "Unexpected Retention on the XML preview"); + Assert.assertEquals(feedFromXML.getClusters().getClusters().get(0) + .getRetention().getLimit().getTimeUnit().name(), "minutes", + "Unexpected Retention Unit on the XML preview"); + + + // Assert that the Location and Retention values are correct on the Wizard window + Assert.assertEquals(feedWizardPage.getFeedPathText(0), + baseTestHDFSDir + "/newInput/${YEAR}/${MONTH}/${DAY}/${HOUR}/${MINUTE}", + "Unexpected Cluster Data Location on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedPathText(1), + baseTestHDFSDir + "/newFalcon/clicksStats", + "Unexpected Cluster Stats Location on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedPathText(2), + baseTestHDFSDir + "/newFalcon/clicksMetaData", + "Unexpected Cluster Meta Location on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedClusterRetentionLimitText(), "60", + "Unexpected Retention Limit on the Wizard window"); + Assert.assertEquals(feedWizardPage.getFeedClusterRetentionUnitText(), "minutes", + "Unexpected Retention Unit on the Wizard window"); + + + } + + /** + * Create feed. Using API check that feed was created. + * @throws Exception + */ + @Test + public void testSummaryStepDefaultScenario() throws Exception{ + feedWizardPage.setFeed(feed); - //Check the response to validate if the feed creation went successfully + //Check the response using API to validate if the feed creation went successfully ServiceResponse response = prism.getFeedHelper().getEntityDefinition(feed.toString()); AssertUtil.assertSucceeded(response); + } + }
