falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rag...@apache.org
Subject falcon git commit: FALCON-1242: Search UI test for entity upload button contributed by Namit Maheshwari
Date Sat, 30 May 2015 00:08:21 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 5d6f957ca -> 4e81193f4


FALCON-1242: Search UI test for entity upload button 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/4e81193f
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/4e81193f
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/4e81193f

Branch: refs/heads/master
Commit: 4e81193f418dadef9f04417f3ec29dde997424dc
Parents: 5d6f957
Author: Raghav Kumar Gautam <raghav@apache.org>
Authored: Fri May 29 17:08:20 2015 -0700
Committer: Raghav Kumar Gautam <raghav@apache.org>
Committed: Fri May 29 17:08:20 2015 -0700

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |   2 +
 .../ui/search/AbstractSearchPage.java           |   4 +-
 .../regression/ui/search/ClusterWizardPage.java |  19 +++
 .../falcon/regression/ui/search/PageHeader.java |  26 +++-
 .../regression/searchUI/HomePageTest.java       | 122 ++++++++++++++++++-
 5 files changed, 168 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/4e81193f/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index 27a4157..c581415 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -5,6 +5,8 @@ Trunk (Unreleased)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+   FALCON-1242 Search UI test for entity upload button (Namit Maheshwari)
+
    FALCON-1222 Feed Wizard multiple tests (Namit Maheshwari)
 
    FALCON-1229 Tests for instance page on SearchUI (Ruslan Ostafiychuk)

http://git-wip-us.apache.org/repos/asf/falcon/blob/4e81193f/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 780cd0c..7c1f7ad 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
@@ -98,8 +98,8 @@ public abstract class AbstractSearchPage extends Page {
     }
 
     public String getActiveAlertText() {
-        WebElement alertsBlock = driver.findElement(By.className("messages-to-show"));
-        List<WebElement> alerts = alertsBlock.findElements(By.className("ng-animate"));
+        WebElement alertsBlock = driver.findElement(By.className("messages"));
+        List<WebElement> alerts = alertsBlock.findElements(By.className("message"));
         if (!alerts.isEmpty()) {
             WebElement last = alerts.get(alerts.size() - 1);
             if (last.isDisplayed()) {

http://git-wip-us.apache.org/repos/asf/falcon/blob/4e81193f/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/ClusterWizardPage.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/ClusterWizardPage.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/ClusterWizardPage.java
index 300a3d6..92b1ee5 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/ClusterWizardPage.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/ClusterWizardPage.java
@@ -446,4 +446,23 @@ public class ClusterWizardPage extends AbstractSearchPage {
         WebElement version = clusterBox.findElement(By.xpath("(//input[@ng-model='_interface._version'])[6]"));
         return endpoint.isEnabled() && version.isEnabled();
     }
+
+    private WebElement getNameUnavailable(){
+        return clusterBox.findElement(By.xpath(
+            "//div[contains(@class, 'nameInputDisplay') and contains(@class, 'custom-danger')]"));
+    }
+
+    public void checkNameUnavailableDisplayed(boolean isDisplayed) {
+        if (isDisplayed){
+            UIAssert.assertDisplayed(getNameUnavailable(), "Name Unavailable not displayed");
+        }else {
+            try{
+                getNameUnavailable();
+                Assert.fail("Name Unavailable found");
+            } catch (Exception ex){
+                LOGGER.info("Name Unavailable not found");
+            }
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/4e81193f/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
index c84cfe5..6524ccf 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
@@ -20,9 +20,11 @@ package org.apache.falcon.regression.ui.search;
 
 import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
 import org.apache.falcon.regression.core.util.AssertUtil;
+import org.apache.falcon.regression.core.util.TimeUtil;
 import org.apache.falcon.regression.core.util.UIAssert;
 import org.apache.log4j.Logger;
 import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.FindBy;
@@ -32,6 +34,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
 import org.testng.Assert;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -180,6 +183,12 @@ public class PageHeader {
         driver.get(oldUrl);
     }
 
+    public void uploadXml(String filePath) throws IOException {
+        final WebElement uploadEntityTextBox = uploadEntityBox.findElement(By.id("files"));
+        uploadEntityTextBox.sendKeys(filePath);
+        waitForAngularToFinish();
+    }
+
     public ClusterWizardPage doCreateCluster() {
         UIAssert.assertDisplayed(clusterCreateButton, "Cluster create button");
         Assert.assertEquals(clusterCreateButton.getText(), "Cluster",
@@ -233,7 +242,7 @@ public class PageHeader {
     }
 
     private WebElement getLogoutButton() {
-        return loginHeaderBox.findElement(By.tagName("button"));
+        return loginHeaderBox.findElement(By.xpath("//button[contains(.,'Logout')]"));
     }
 
     public LoginPage doLogout() {
@@ -244,4 +253,19 @@ public class PageHeader {
         return loginPage;
     }
 
+    protected void waitForAngularToFinish() {
+        final String javaScript = "return (window.angular != null) && "
+            + "(angular.element(document).injector() != null) && "
+            + "(angular.element(document).injector().get('$http').pendingRequests.length
=== 0)";
+        boolean isLoaded = false;
+        for (int i = 0; i < AbstractSearchPage.PAGELOAD_TIMEOUT_THRESHOLD && !isLoaded;
i++) {
+            final Object output = ((JavascriptExecutor) driver).executeScript(javaScript);
+            isLoaded = Boolean.valueOf(output.toString());
+            LOGGER.info(i+1 + ". waiting on angular to finish.");
+            TimeUtil.sleepSeconds(1);
+        }
+        LOGGER.info("angular is done continuing...");
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/4e81193f/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 b752a86..f71739d 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
@@ -22,16 +22,23 @@ import org.apache.falcon.regression.core.bundle.Bundle;
 import org.apache.falcon.regression.core.helpers.ColoHelper;
 import org.apache.falcon.regression.core.util.AssertUtil;
 import org.apache.falcon.regression.core.util.BundleUtil;
+import org.apache.falcon.regression.core.util.FileUtil;
+import org.apache.falcon.regression.core.util.HadoopUtil;
+import org.apache.falcon.regression.core.util.OSUtil;
 import org.apache.falcon.regression.testHelper.BaseUITestClass;
+import org.apache.falcon.regression.ui.search.ClusterWizardPage;
 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.File;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.List;
 
 /** UI tests for Search UI Homepage. */
@@ -39,6 +46,11 @@ import java.util.List;
 public class HomePageTest extends BaseUITestClass {
     private static final Logger LOGGER = Logger.getLogger(HomePageTest.class);
     private SearchPage homePage = null;
+    private ColoHelper cluster = servers.get(0);
+    private FileSystem clusterFS = serverFS.get(0);
+    private String baseTestHDFSDir = cleanAndGetTestDir();
+    private String aggregateWorkflowDir = baseTestHDFSDir + "/aggregator";
+    private String feedInputPath = baseTestHDFSDir + "/input" + MINUTE_DATE_PATTERN;
 
     @BeforeMethod(alwaysRun = true)
     public void setup() {
@@ -61,8 +73,8 @@ public class HomePageTest extends BaseUITestClass {
     public void testNavigationToEntitiesTable() throws Exception {
         homePage.checkNoResult();
         bundles[0] = BundleUtil.readELBundle();
-        ColoHelper cluster = servers.get(0);
-        bundles[0] = new Bundle(bundles[0], cluster);
+        ColoHelper coloHelper = servers.get(0);
+        bundles[0] = new Bundle(bundles[0], coloHelper);
         bundles[0].generateUniqueBundle(this);
         String pigTestDir = cleanAndGetTestDir();
         String inputPath = pigTestDir + "/input" + MINUTE_DATE_PATTERN;
@@ -81,4 +93,110 @@ public class HomePageTest extends BaseUITestClass {
         Assert.assertEquals(searchResults.size(), 0, "Expecting no search results");
     }
 
+    /**
+     * Upload cluster, feed, process entity through upload entity button.
+     * The entity should get created.
+     * @throws Exception
+     */
+    @Test
+    public void testUploadEntity() throws Exception{
+
+        HadoopUtil.uploadDir(clusterFS, aggregateWorkflowDir, OSUtil.RESOURCES_OOZIE);
+        Bundle bundle = BundleUtil.readELBundle();
+        bundle.generateUniqueBundle(this);
+        bundle = new Bundle(bundle, cluster);
+        bundle.setInputFeedDataPath(feedInputPath);
+        bundle.setProcessWorkflow(aggregateWorkflowDir);
+
+
+        final String clusterXml = bundle.getClusterElement().toString();
+        homePage.getPageHeader().uploadXml(FileUtil.writeEntityToFile(clusterXml));
+        AssertUtil.assertSucceeded(prism.getClusterHelper().getEntityDefinition(clusterXml));
+
+        final String feedXml = bundle.getInputFeedFromBundle();
+        homePage.getPageHeader().uploadXml(FileUtil.writeEntityToFile(feedXml));
+        AssertUtil.assertSucceeded(prism.getFeedHelper().getEntityDefinition(feedXml));
+
+        final String outputFeedXml = bundle.getOutputFeedFromBundle();
+        homePage.getPageHeader().uploadXml(FileUtil.writeEntityToFile(outputFeedXml));
+        AssertUtil.assertSucceeded(prism.getFeedHelper().getEntityDefinition(outputFeedXml));
+
+        final String processXml = bundle.getProcessObject().toString();
+        homePage.getPageHeader().uploadXml(FileUtil.writeEntityToFile(processXml));
+        AssertUtil.assertSucceeded(prism.getProcessHelper().getEntityDefinition(processXml));
+
+    }
+
+    /**
+     * Upload bad cluster, feed, process entity through upload entity button.
+     * We should get an error.
+     * @throws Exception
+     */
+    @Test
+    public void testUploadBadEntity() throws Exception{
+
+        HadoopUtil.uploadDir(clusterFS, aggregateWorkflowDir, OSUtil.RESOURCES_OOZIE);
+        Bundle bundle = BundleUtil.readELBundle();
+        bundle.generateUniqueBundle(this);
+        bundle = new Bundle(bundle, cluster);
+        bundle.setInputFeedDataPath(feedInputPath);
+        bundle.setProcessWorkflow(aggregateWorkflowDir);
+
+        // Create a text file, with some text
+        File textFile = new File("invalid.txt");
+        PrintWriter writer = new PrintWriter(textFile, "UTF-8");
+        String text = "Some random text";
+        writer.println(text);
+        writer.close();
+        homePage.getPageHeader().uploadXml(textFile.getAbsolutePath());
+        String alertText = homePage.getActiveAlertText();
+        Assert.assertEquals(alertText, "Invalid xml. File not uploaded",
+            "Text file was allowed to be uploaded");
+
+        // Create a xml file with proper name, but invalid text contents
+        File xmlFile = new File("cluster.xml");
+        writer = new PrintWriter(xmlFile, "UTF-8");
+        text = "The first line\nThe second line";
+        writer.println(text);
+        writer.close();
+
+        homePage.getPageHeader().uploadXml(xmlFile.getAbsolutePath());
+        Thread.sleep(1000);
+        alertText = homePage.getActiveAlertText();
+        Assert.assertEquals(alertText, "Invalid xml. File not uploaded",
+            "XML file with invalid text was allowed to be uploaded");
+
+
+    }
+
+    /**
+     * Submit cluster with name e.g. myCluster.
+     * Select "create cluster". Try to populate name field with the name of previously submitted
cluster.
+     * Check that "name unavailable" has appeared.
+     * @throws Exception
+     */
+    @Test
+    public void clusterSetupNameAvailability() throws Exception{
+
+        HadoopUtil.uploadDir(clusterFS, aggregateWorkflowDir, OSUtil.RESOURCES_OOZIE);
+        Bundle bundle = BundleUtil.readELBundle();
+        bundle.generateUniqueBundle(this);
+        bundle = new Bundle(bundle, cluster);
+
+        // Submit Cluster
+        final String clusterXml = bundle.getClusterElement().toString();
+        homePage.getPageHeader().uploadXml(FileUtil.writeEntityToFile(clusterXml));
+        AssertUtil.assertSucceeded(prism.getClusterHelper().getEntityDefinition(clusterXml));
+
+        // Get cluster name and try to set it again
+        String clusterName = bundle.getClusterElement().getName();
+        ClusterWizardPage clusterWizardPage = homePage.getPageHeader().doCreateCluster();
+        clusterWizardPage.setName(clusterName);
+
+        // Assert that name unavailable is displayed
+        clusterWizardPage.checkNameUnavailableDisplayed(true);
+    }
+
+
+
 }


Mime
View raw message