sarutak opened a new pull request #28627:
URL: https://github.com/apache/spark/pull/28627
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section
is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster
reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class
hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other
DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
This PR mainly adds two things.
1. Real headless browser support for UI test
2. A test suite using headless Chrome as one instance of those browsers.
Also, for environment where Chrome and Chrome driver is not installed,
`ChromeUITest` tag is added to filter out the test suite.
By default, test suites with `ChromeUITest` is disabled.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
In the current master, there are two problems for UI test.
1. Lots of tests especially JavaScript related ones are done manually.
Appearance is better to be confirmed by our eyes but logic should be tested
by test cases ideally.
2. Compared to the real web browsers, HtmlUnit doesn't seem to support
JavaScript enough.
I added a JavaScript related test before for SPARK-31534 using HtmlUnit
which is simple library based headless browser for test.
The test I added works somehow but some JavaScript related error is shown in
unit-tests.log.
```
======= EXCEPTION START ========
Exception
class=[net.sourceforge.htmlunit.corejs.javascript.JavaScriptException]
com.gargoylesoftware.htmlunit.ScriptException: Error: TOOLTIP: Option
"sanitizeFn" provided type "window" but expected type "(null|function)".
(http://192.168.1.209:60724/static/jquery-3.4.1.min.js#2)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:904)
at
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:835)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:807)
at
com.gargoylesoftware.htmlunit.InteractivePage.executeJavaScriptFunctionIfPossible(InteractivePage.java:216)
at
com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52)
at
com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102)
at
com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:426)
at
com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:157)
at java.lang.Thread.run(Thread.java:748)
Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException:
Error: TOOLTIP: Option "sanitizeFn" provided type "window" but expected type
"(null|function)". (http://192.168.1.209:60724/static/jquery-3.4.1.min.js#2)
at
net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1009)
at
net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800)
at
net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:413)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:252)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:828)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:889)
... 10 more
JavaScriptException value = Error: TOOLTIP: Option "sanitizeFn" provided
type "window" but expected type "(null|function)".
== CALLING JAVASCRIPT ==
function () {
throw e;
}
======= EXCEPTION END ========
```
I tried to upgrade HtmlUnit to 2.40.0 but what is worse, the test become not
working even though it works on real browsers like Chrome, Safari and Firefox
without error.
```
[info] UISeleniumSuite:
[info] - SPARK-31534: text for tooltip should be escaped *** FAILED *** (17
seconds, 745 milliseconds)
[info] The code passed to eventually never returned normally. Attempted 2
times over 12.910785232 seconds. Last failure message:
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: Assignment to
undefined "regeneratorRuntime" in strict mode
(http://192.168.1.209:62132/static/vis-timeline-graph2d.min.js#52(Function)#1)
```
To resolve those problems, it's better to support headless browser for UI
test.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as
the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes
- provide the console output, description and/or an example to show the
behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to
the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some
test cases that check the changes thoroughly including negative and positive
cases if possible.
If it was tested in a way different from regular unit tests, please clarify
how you tested step by step, ideally copy and paste-able, so that other
reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why
it was difficult to add.
-->
I tested with following patterns. Both Chrome and Chrome driver should be
installed to test.
1. sbt / with default excluded tags (expect to be skipped)
`build/sbt -Dspark.test.webdriver.chrome.driver=/path/to/chromedriver
"testOnly org.apache.spark.ui.ChromeUISeleniumSuite"`
2. sbt / overwrite excluded tags as `org.apache.spark.tags.ChromeUITest`
(expect to be skipped)
`build/sbt -Dtest.exclude.tags="org.apache.spark.tags.ChromeUITest"
-Dspark.test.webdriver.chrome.driver=/path/to/chromedriver "testOnly
org.apache.spark.ui.ChromeUISeleniumSuite"`
3. sbt / overwrite excluded tags as empty string (expect to succeed)
`build/sbt -Dtest.exclude.tags=
-Dspark.test.webdriver.chrome.driver=/path/to/chromedriver "testOnly
org.apache.spark.ui.ChromeUISeleniumSuite"`
4. mvn / with default excluded tags (expect to be skipped)
`build/mvn -Dspark.test.webdriver.chrome.driver=/path/to/chromedriver83
-Dtest=none -DwildcardSuites=org.apache.spark.ui.ChromeUISeleniumSuite test`
5. mvn / overwrite excluded tags as `org.apache.spark.tags.ChromeUITest`
(expect to be skipped)
`build/mvn -Dtest.exclude.tags=org.apache.spark.tags.ChromeUITest
-Dspark.test.webdriver.chrome.driver=/path/to/chromedriver83 -Dtest=none
-DwildcardSuites=org.apache.spark.ui.ChromeUISeleniumSuite test`
6. mvn / overwrite excluded tags as empty string (expect to succeed)
`build/mvn -Dtest.exclude.tags=
-Dspark.test.webdriver.chrome.driver=/path/to/chromedriver -Dtest=none
-DwildcardSuites=org.apache.spark.ui.ChromeUISeleniumSuite test`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]