falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rostafiyc...@apache.org
Subject falcon git commit: FALCON-1254 ClusterSetup UI: edit xml test cases, stabilize 2 tests. Contributed by Paul Isaychuk
Date Tue, 09 Jun 2015 12:46:59 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 659f229f5 -> 77efa6e9d


 FALCON-1254 ClusterSetup UI: edit xml test cases, stabilize 2 tests. Contributed by Paul
Isaychuk


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/77efa6e9
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/77efa6e9
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/77efa6e9

Branch: refs/heads/master
Commit: 77efa6e9d913593044864aa31ca5e8682ba395a4
Parents: 659f229
Author: Ruslan Ostafiychuk <rostafiychuk@apache.org>
Authored: Tue Jun 9 15:43:06 2015 +0300
Committer: Ruslan Ostafiychuk <rostafiychuk@apache.org>
Committed: Tue Jun 9 15:43:06 2015 +0300

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |  1 +
 .../regression/ui/search/ClusterWizardPage.java | 65 ++++++++++-------
 .../regression/searchUI/ClusterSetupTest.java   | 75 +++++++++++++++++++-
 3 files changed, 113 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/77efa6e9/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index e043577..d4b1d67 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -5,6 +5,7 @@ Trunk (Unreleased)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+   FALCON-1254 ClusterSetup UI: edit xml test cases, stabilize 2 tests (Paul Isaychuk via
Ruslan Ostafiychuk)
    
    FALCON-1215 Adding new test cases related to rerun feature (Pragya M via Samarth Gupta)
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/77efa6e9/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 92b1ee5..c2493e8 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
@@ -26,11 +26,9 @@ import org.apache.falcon.entity.v0.cluster.Interfacetype;
 import org.apache.falcon.entity.v0.cluster.Location;
 import org.apache.falcon.entity.v0.cluster.Property;
 import org.apache.falcon.regression.Entities.ClusterMerlin;
-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;
@@ -96,11 +94,19 @@ public class ClusterWizardPage extends AbstractSearchPage {
      * Methods to fill specific wizard fields.
      */
     public void setName(String name) {
-        WebElement nameInput = driver.findElement(By.xpath("//div[label[text()='Name']]/input"));
+        WebElement nameInput = getNameInput();
         nameInput.clear();
         sendKeysSlowly(nameInput, name);
     }
 
+    public String getName() {
+        return getNameInput().getAttribute("value");
+    }
+
+    private WebElement getNameInput() {
+        return driver.findElement(By.xpath("//div[label[text()='Name']]/input"));
+    }
+
     public void setColo(String colo) {
         WebElement coloInput = clusterBox.findElement(By.xpath("//div[label[text()='Colo']]/input"));
         coloInput.clear();
@@ -172,7 +178,7 @@ public class ClusterWizardPage extends AbstractSearchPage {
     public void addTag(String key, String value) {
         List<WebElement> tagInputs = clusterBox.findElements(By.xpath("//input[@ng-model='tag.key']"));
         List<WebElement> valueInputs = clusterBox.findElements(By.xpath("//input[@ng-model='tag.value']"));
-        WebElement tagInput = tagInputs.get(tagInputs.size()-1);
+        WebElement tagInput = tagInputs.get(tagInputs.size() - 1);
         sendKeysSlowly(tagInput, key);
         WebElement valueInput = valueInputs.get(valueInputs.size() - 1);
         sendKeysSlowly(valueInput, value);
@@ -268,11 +274,19 @@ public class ClusterWizardPage extends AbstractSearchPage {
 
     public ClusterMerlin getXmlPreview() {
         //preview block fetches changes slower then they appear on the form
-        TimeUtil.sleepSeconds(1);
+        waitForAngularToFinish();
         String previewData = xmlPreview.getAttribute("value");
         return new ClusterMerlin(previewData);
     }
 
+    public void setClusterXml(String clusterXml) {
+        clickEditXml(true);
+        xmlPreview.clear();
+        xmlPreview.sendKeys(clusterXml);
+        waitForAngularToFinish();
+        clickEditXml(false);
+    }
+
     /**
      * Retrieves hte value of the summary box and parses it to cluster properties.
      * @param draft empty cluster to contain all properties.
@@ -352,8 +366,10 @@ public class ClusterWizardPage extends AbstractSearchPage {
             propsLeft = propsLeft.split("Properties")[1];
             String properties = propsLeft.split("Locations")[0].trim();
             for (String line : properties.split("\\n")) {
-                slices = line.split(":");
-                cluster.addProperty(slices[0].trim(), slices[1].trim());
+                int indx = line.indexOf(":");
+                String name = line.substring(0, indx).trim();
+                String value = line.substring(indx + 1, line.length()).trim();
+                cluster.addProperty(name, value);
             }
         }
         //retrieve locations
@@ -387,10 +403,11 @@ public class ClusterWizardPage extends AbstractSearchPage {
     /**
      * Clicks on editXml button.
      */
-    private void clickEditXml() {
+    public void clickEditXml(boolean shouldBeEnabled) {
         editXML.click();
         String disabled = xmlPreview.getAttribute("disabled");
-        Assert.assertEquals(disabled, null, "Xml preview should be enabled.");
+        Assert.assertEquals(disabled == null, shouldBeEnabled,
+            "Xml preview should be " + (shouldBeEnabled ? "enabled" : "disabled"));
     }
 
     /**
@@ -409,24 +426,6 @@ public class ClusterWizardPage extends AbstractSearchPage {
     }
 
     /**
-     * Checks whether alert has appeared and does it contains expected message.
-     * @param alertMessage expected message
-     */
-    public void checkSubmissionAlert(boolean shouldSucceed, String alertMessage) {
-        String className = "alert ng-binding bg-danger";
-        if (shouldSucceed) {
-            className = "alert ng-binding bg-success";
-        }
-        waitForElement(String.format("//div[contains(@class, '%s')]", className), DEFAULT_TIMEOUT,
"Alert not found.");
-        //alert message is not a content of a div, but is product of the script
-        //so we can't just retrieve it as usually
-        String alertText = ((JavascriptExecutor)driver).executeScript(String.format(
-            "return (function(){return document.getElementsByClassName('%s')[0].textContent;})();",
-            className)).toString().trim();
-        Assert.assertEquals(alertText, alertMessage);
-    }
-
-    /**
      * Clicks on previous button.
      */
     public void clickPrevious() {
@@ -438,6 +437,18 @@ public class ClusterWizardPage extends AbstractSearchPage {
         clusterBox.findElement(By.xpath("//input[@type='checkbox']")).click();
     }
 
+    public String getInterfaceEndpoint(Interfacetype interfacetype) {
+        String xpath = String.format("(//input[@ng-model='_interface._endpoint'])[%s]", interfacetype.ordinal()
+ 1);
+        WebElement endpoint = clusterBox.findElement(By.xpath(xpath));
+        return endpoint.getAttribute("value");
+    }
+
+    public String getInterfaceVersion(Interfacetype interfacetype) {
+        String xpath = String.format("(//input[@ng-model='_interface._version'])[%s]", interfacetype.ordinal()
+ 1);
+        WebElement version = clusterBox.findElement(By.xpath(xpath));
+        return version.getAttribute("value");
+    }
+
     /**
      * Checks whether registry interface is enabled for input or not.
      */

http://git-wip-us.apache.org/repos/asf/falcon/blob/77efa6e9/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 d616b84..12b3fe5 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
@@ -17,8 +17,10 @@
  */
 package org.apache.falcon.regression.searchUI;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.falcon.entity.v0.cluster.ClusterLocationType;
 import org.apache.falcon.entity.v0.cluster.Interface;
+import org.apache.falcon.entity.v0.cluster.Interfacetype;
 import org.apache.falcon.entity.v0.cluster.Location;
 import org.apache.falcon.entity.v0.cluster.Property;
 import org.apache.falcon.regression.Entities.ClusterMerlin;
@@ -228,14 +230,16 @@ public class ClusterSetupTest extends BaseUITestClass{
         //reverse staging and working location dirs
         String staging = sourceCluster.getLocation(ClusterLocationType.STAGING).get(0).getPath();
         String working = sourceCluster.getLocation(ClusterLocationType.WORKING).get(0).getPath();
+        //set working to dir which has 777 permissions
         sourceCluster.getLocation(ClusterLocationType.WORKING).get(0).setPath(staging);
+        //set staging to dir which has 755 permissions
         sourceCluster.getLocation(ClusterLocationType.STAGING).get(0).setPath(working);
         clusterSetup.fillForm(sourceCluster);
         clusterSetup.clickNext();
         clusterSetup.clickSave();
         String alertMessage = clusterSetup.getActiveAlertText();
         Assert.assertEquals(alertMessage,
-            String.format("Path %s has permissions: rwxrwxrwx, should be rwxr-xr-x", staging));
+            String.format("Path %s has permissions: rwxr-xr-x, should be rwxrwxrwx", working));
     }
 
     /**
@@ -254,6 +258,75 @@ public class ClusterSetupTest extends BaseUITestClass{
             String.format("Location %s for cluster %s must exist.", nonExistent, sourceCluster.getName()));
     }
 
+    /**
+     * Populate cluster with properties. Click Edit XML. Change cluster name and
+     * description, add registry interface. Check that they were enabled and populated
+     * in wizard.
+     */
+    @Test
+    public void testEditXml() {
+        clusterSetup.fillForm(sourceCluster);
+        //check that registry is empty
+        String registryEndpoint = clusterSetup.getInterfaceEndpoint(Interfacetype.REGISTRY);
+        Assert.assertTrue(StringUtils.isEmpty(registryEndpoint), "Registry endpoint should
be empty");
+        String registryVersion = clusterSetup.getInterfaceVersion(Interfacetype.REGISTRY);
+        Assert.assertTrue(StringUtils.isEmpty(registryVersion), "Registry version should
be empty");
+        Assert.assertFalse(clusterSetup.isRegistryEnabled(), "Registry should be disabled.");
+
+        //change cluster xml
+        sourceCluster.setName(sourceCluster.getName() + "-new");
+        sourceCluster.setDescription("newDescription");
+        Interface iFace = new Interface();
+        iFace.setEndpoint(cluster.getClusterHelper().getHostname());
+        iFace.setVersion("1.0.0");
+        iFace.setType(Interfacetype.REGISTRY);
+        sourceCluster.getInterfaces().getInterfaces().add(iFace);
+
+        //populate it to xmlPreview
+        clusterSetup.setClusterXml(sourceCluster.toString());
+
+        //check values on wizard
+        registryEndpoint = clusterSetup.getInterfaceEndpoint(Interfacetype.REGISTRY);
+        Assert.assertEquals(registryEndpoint, sourceCluster.getInterfaces().getInterfaces().get(5).getEndpoint(),
+            "Registry endpoint on wizard should match to endpoint on preview xml.");
+        registryVersion = clusterSetup.getInterfaceVersion(Interfacetype.REGISTRY);
+        Assert.assertEquals(registryVersion, sourceCluster.getInterfaces().getInterfaces().get(5).getVersion(),
+            "Registry version on wizard should match to endpoint on preview xml.");
+        Assert.assertTrue(clusterSetup.isRegistryEnabled(), "Registry should be enabled.");
+    }
+
+    /**
+     * Populate cluster with properties. Click Edit XML. Break the XML (delete closing tag).
+     * Check that malformed cluster is not accepted by the form.
+     * Undo the change. Change cluster name to malformed one.
+     * Check that value is accepted.
+     */
+    @Test
+    public void testEditXmlInvalidValues(){
+        clusterSetup.fillForm(sourceCluster);
+        ClusterMerlin initialPreview = clusterSetup.getXmlPreview();
+
+        //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);
+
+        //compare preview before and after changes
+        ClusterMerlin finalPreview = clusterSetup.getXmlPreview();
+        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());
+
+        //check the value on a wizard
+        Assert.assertEquals(clusterSetup.getName(), sourceCluster.getName(), "Malformed name
should be accepted.");
+    }
+
     @AfterMethod(alwaysRun = true)
     public void tearDown() throws IOException {
         removeTestClassEntities();


Mime
View raw message