From c1c883c4122a8991f62542ad84ba699674fdff33 Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Tue, 9 Feb 2016 20:25:54 +0530 Subject: [PATCH 1/3] create seperate matrix for selenium test case --- .travis.yml | 4 + .../apache/zeppelin/AbstractZeppelinIT.java | 2 +- .../java/org/apache/zeppelin/ZeppelinIT.java | 133 ++++++++++-------- 3 files changed, 78 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2619ed1c7cc..e5436684f60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,10 @@ matrix: - jdk: "oraclejdk7" env: SPARK_VER="1.1.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.1 -Phadoop-2.3 -Ppyspark" BUILD_FLAG="package -DskipTests" TEST_FLAG="verify" + # Test selenium + - jdk: "oraclejdk7" + env: TEST_SELENIUM="true" SPARK_VER="1.6.0" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark -Pscalding" BUILD_FLAG="package -Pbuild-distr" TEST_FLAG="verify -Pusing-packaged-distr" + before_install: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java index 1e442e43c56..29569fc8c22 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java @@ -97,7 +97,7 @@ public WebElement apply(WebDriver driver) { } protected boolean endToEndTestEnabled() { - return null != System.getenv("CI"); + return null != System.getenv("TEST_SELENIUM"); } protected void createNewNote() { diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java index e9a56cc108d..dcd26fe244a 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java @@ -35,7 +35,7 @@ * To test, ZeppelinServer should be running on port 8080 * On OSX, you'll need firefox 42.0 installed, then you can run with * - * PATH=~/Applications/Firefox.app/Contents/MacOS/:$PATH CI="" \ + * PATH=~/Applications/Firefox.app/Contents/MacOS/:$PATH TEST_SELENIUM="" \ * mvn -Dtest=org.apache.zeppelin.ZeppelinIT -Denforcer.skip=true \ * test -pl zeppelin-server * @@ -62,7 +62,7 @@ public void tearDown() { } @Test - public void testAngularDisplay() throws InterruptedException{ + public void testAngularDisplay() throws InterruptedException { if (!endToEndTestEnabled()) { return; } @@ -78,16 +78,16 @@ public void testAngularDisplay() throws InterruptedException{ */ WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); paragraph1Editor.sendKeys("println" + Keys.chord(Keys.SHIFT, "9") + "\"" - + Keys.chord(Keys.SHIFT, "5") - + "angular
" - + "BindingTest_{{myVar}}_
\")"); + + Keys.chord(Keys.SHIFT, "5") + + "angular
" + + "BindingTest_{{myVar}}_
\")"); paragraph1Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(1, "FINISHED"); // check expected text waitForText("BindingTest__", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); /* * Bind variable @@ -101,7 +101,7 @@ public void testAngularDisplay() throws InterruptedException{ // check expected text waitForText("BindingTest_1_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); /* @@ -111,23 +111,23 @@ public void testAngularDisplay() throws InterruptedException{ WebElement paragraph3Editor = driver.findElement(By.xpath(getParagraphXPath(3) + "//textarea")); paragraph3Editor.sendKeys( "print" + Keys.chord(Keys.SHIFT, "9") + "\"myVar=\"" + Keys.chord(Keys.ADD) - + "z.angular" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\"))"); + + "z.angular" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\"))"); paragraph3Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(3, "FINISHED"); // check expected text waitForText("myVar=1", By.xpath( - getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")); + getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")); /* * Click element */ driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); // check expected text waitForText("BindingTest_2_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); /* * Register watcher @@ -138,9 +138,9 @@ public void testAngularDisplay() throws InterruptedException{ WebElement paragraph4Editor = driver.findElement(By.xpath(getParagraphXPath(4) + "//textarea")); paragraph4Editor.sendKeys( "z.angularWatch" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\", " - + Keys.chord(Keys.SHIFT, "9") - + "before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)" - + Keys.EQUALS + ">{ z.run" +Keys.chord(Keys.SHIFT, "9") + "2, context)}"); + + Keys.chord(Keys.SHIFT, "9") + + "before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)" + + Keys.EQUALS + ">{ z.run" + Keys.chord(Keys.SHIFT, "9") + "2, context)}"); paragraph4Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(4, "FINISHED"); @@ -149,16 +149,16 @@ public void testAngularDisplay() throws InterruptedException{ * Click element, again and see watcher works */ driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); // check expected text waitForText("BindingTest_3_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); + getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); waitForParagraph(3, "FINISHED"); // check expected text by watcher waitForText("myVar=3", By.xpath( - getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")); + getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")); /* * Unbind @@ -195,53 +195,66 @@ public void testAngularDisplay() throws InterruptedException{ System.out.println("testCreateNotebook Test executed"); } catch (ElementNotVisibleException e) { LOG.error("Exception in ZeppelinIT while testAngularDisplay ", e); - File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); + File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); } } @Test public void testSparkInterpreterDependencyLoading() { - // navigate to interpreter page - WebElement interpreterLink = driver.findElement(By.linkText("Interpreter")); - interpreterLink.click(); - - // add new dependency to spark interpreter - WebElement sparkEditBtn = pollingWait(By.xpath("//div[h3[text()[contains(.,'spark')]]]//button[contains(.,'edit')]"), - MAX_BROWSER_TIMEOUT_SEC); - sparkEditBtn.click(); - WebElement depArtifact = driver.findElement(By.xpath("//input[@ng-model='setting.depArtifact']")); - String artifact = "org.apache.commons:commons-csv:1.1"; - depArtifact.sendKeys(artifact); - driver.findElement(By.xpath("//button[contains(.,'Save')]")).submit(); - driver.switchTo().alert().accept(); - - driver.navigate().back(); - createNewNote(); - - // wait for first paragraph's " READY " status text - waitForParagraph(1, "READY"); - - WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); - - paragraph1Editor.sendKeys("import org.apache.commons.csv.CSVFormat"); - paragraph1Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); - waitForParagraph(1, "FINISHED"); - - // check expected text - assertTrue(waitForText("import org.apache.commons.csv.CSVFormat", - By.xpath(getParagraphXPath(1) + "//div[starts-with(@id, 'p') and contains(@id, 'text')]/div"))); - - // reset dependency - interpreterLink.click(); - sparkEditBtn = pollingWait(By.xpath("//div[h3[text()[contains(.,'spark')]]]//button[contains(.,'edit')]"), - MAX_BROWSER_TIMEOUT_SEC); - sparkEditBtn.click(); - WebElement testDepRemoveBtn = driver.findElement(By.xpath("//tr[descendant::text()[contains(.,'" + - artifact + "')]]/td[3]/div")); - sleep(5000, true); - testDepRemoveBtn.click(); - driver.findElement(By.xpath("//button[contains(.,'Save')]")).submit(); - driver.switchTo().alert().accept(); + if (!endToEndTestEnabled()) { + return; + } + try { + // navigate to interpreter page + WebElement interpreterLink = driver.findElement(By.linkText("Interpreter")); + interpreterLink.click(); + + // add new dependency to spark interpreter + WebElement sparkEditBtn = pollingWait(By.xpath("//div[h3[text()[contains(.,'spark')]]]//button[contains(.,'edit')]"), + MAX_BROWSER_TIMEOUT_SEC); + sparkEditBtn.click(); + WebElement depArtifact = driver.findElement(By.xpath("//input[@ng-model='setting.depArtifact']")); + String artifact = "org.apache.commons:commons-csv:1.1"; + depArtifact.sendKeys(artifact); + driver.findElement(By.xpath("//button[contains(.,'Save')]")).submit(); + driver.switchTo().alert().accept(); + + driver.navigate().back(); + createNewNote(); + + // wait for first paragraph's " READY " status text + waitForParagraph(1, "READY"); + + WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); + + paragraph1Editor.sendKeys("import org.apache.commons.csv.CSVFormat"); + paragraph1Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); + waitForParagraph(1, "FINISHED"); + + // check expected text + assertTrue(waitForText("import org.apache.commons.csv.CSVFormat", + By.xpath(getParagraphXPath(1) + "//div[starts-with(@id, 'p') and contains(@id, 'text')]/div"))); + + deleteTestNotebook(driver); + sleep(1000, true); + + // reset dependency + interpreterLink.click(); + sparkEditBtn = pollingWait(By.xpath("//div[h3[text()[contains(.,'spark')]]]//button[contains(.,'edit')]"), + MAX_BROWSER_TIMEOUT_SEC); + sparkEditBtn.click(); + WebElement testDepRemoveBtn = driver.findElement(By.xpath("//tr[descendant::text()[contains(.,'" + + artifact + "')]]/td[3]/div")); + sleep(5000, true); + testDepRemoveBtn.click(); + driver.findElement(By.xpath("//button[contains(.,'Save')]")).submit(); + driver.switchTo().alert().accept(); + + } catch (ElementNotVisibleException e) { + LOG.error("Exception in ZeppelinIT while testAngularDisplay ", e); + File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); + + } } } From 2d334ff0f90747ba2bfc86b1feeacc73d9b5760a Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Sun, 14 Feb 2016 13:12:46 +0530 Subject: [PATCH 2/3] create different profile for selenium --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 513681036fc..dfe641ad348 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,10 @@ matrix: - jdk: "oraclejdk7" env: SPARK_VER="1.1.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.1 -Phadoop-2.3 -Ppyspark" BUILD_FLAG="package -DskipTests" TEST_FLAG="verify" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.rest.*Test,org.apache.zeppelin.spark* -DfailIfNoTests=false" + # Test selenium with spark module for 1.6.0 + - jdk: "oraclejdk7" + env: TEST_SELENIUM="true" SPARK_VER="1.6.0" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark" BUILD_FLAG="package -DskipTests" TEST_FLAG="verify" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.AbstractFunctionalSuite -DfailIfNoTests=false" + before_install: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" From bc85814194c4cb90eb66c76864e18f69d47378d3 Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Sun, 14 Feb 2016 13:16:24 +0530 Subject: [PATCH 3/3] remove TEST_SELENIUM from first profile --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dfe641ad348..5495398adab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ matrix: include: # Test all modules - jdk: "oraclejdk7" - env: TEST_SELENIUM="true" SPARK_VER="1.6.0" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark -Pscalding" BUILD_FLAG="package -Pbuild-distr" TEST_FLAG="verify -Pusing-packaged-distr" TEST_PROJECTS="" + env: SPARK_VER="1.6.0" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark -Pscalding" BUILD_FLAG="package -Pbuild-distr" TEST_FLAG="verify -Pusing-packaged-distr" TEST_PROJECTS="" # Test spark module for 1.5.2 - jdk: "oraclejdk7"