You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@livy.apache.org by js...@apache.org on 2017/06/27 06:39:29 UTC
[48/50] [abbrv] incubator-livy git commit: LIVY-358. [Follow-up] Add
unit test to verify header size configurations (#331)
LIVY-358. [Follow-up] Add unit test to verify header size configurations (#331)
* Add unit test to verify large header size configuration
Change-Id: I6c231f9fc9773d1ea40313661b7c49ccfaa44796
* Style fix
Change-Id: I24e617f95fd3e45a674a6b5a691428f0fdabcd89
* Style fix
Change-Id: I91e71979499da8ebba41223b6fe41862de168d03
* Revert the changes
Change-Id: Id7bbd1b2378867c8534b900bc7ba9b1234a9b985
* Add configurations to livy.conf.template
Change-Id: I84d428869bc5cc22aa7f00c6c603ea4a6b052964
Project: http://git-wip-us.apache.org/repos/asf/incubator-livy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-livy/commit/2abb8a3d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-livy/tree/2abb8a3d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-livy/diff/2abb8a3d
Branch: refs/heads/master
Commit: 2abb8a3d2850c506ffd2b8a210813f1b8353045f
Parents: 59af39d
Author: Saisai Shao <sa...@gmail.com>
Authored: Thu May 18 11:24:38 2017 +0800
Committer: Jeff Zhang <zj...@gmail.com>
Committed: Wed May 17 23:24:38 2017 -0400
----------------------------------------------------------------------
.../livy/client/http/LivyConnectionSpec.scala | 53 +++++++++++++-------
conf/livy.conf.template | 4 ++
2 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/2abb8a3d/client-http/src/test/scala/com/cloudera/livy/client/http/LivyConnectionSpec.scala
----------------------------------------------------------------------
diff --git a/client-http/src/test/scala/com/cloudera/livy/client/http/LivyConnectionSpec.scala b/client-http/src/test/scala/com/cloudera/livy/client/http/LivyConnectionSpec.scala
index 886d0fd..4e36106 100644
--- a/client-http/src/test/scala/com/cloudera/livy/client/http/LivyConnectionSpec.scala
+++ b/client-http/src/test/scala/com/cloudera/livy/client/http/LivyConnectionSpec.scala
@@ -18,20 +18,20 @@
package com.cloudera.livy.client.http
+import java.io.IOException
import java.net.URLEncoder
import java.nio.charset.StandardCharsets.UTF_8
-import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
import org.apache.http.client.utils.URIBuilder
import org.eclipse.jetty.security._
import org.eclipse.jetty.security.authentication.BasicAuthenticator
-import org.eclipse.jetty.server.Server
-import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}
import org.eclipse.jetty.util.security._
import org.scalatest.{BeforeAndAfterAll, FunSpecLike}
import org.scalatest.Matchers._
+import org.scalatra.servlet.ScalatraListener
-import com.cloudera.livy.LivyBaseUnitTestSuite
+import com.cloudera.livy.{LivyBaseUnitTestSuite, LivyConf}
+import com.cloudera.livy.server.WebServer
class LivyConnectionSpec extends FunSpecLike with BeforeAndAfterAll with LivyBaseUnitTestSuite {
describe("LivyConnection") {
@@ -60,31 +60,29 @@ class LivyConnectionSpec extends FunSpecLike with BeforeAndAfterAll with LivyBas
csh
}
- def staticServlet(): HttpServlet = new HttpServlet {
- override def doGet(req: HttpServletRequest, resp: HttpServletResponse): Unit = {
- resp.getWriter.print("true")
- }
- }
-
- def test(password: String): Unit = {
+ def test(password: String, livyConf: LivyConf = new LivyConf()): Unit = {
val username = "user name"
- val server = new Server(0)
- val context = new ServletContextHandler(ServletContextHandler.SESSIONS)
- context.setSecurityHandler(basicAuth(username, password, "realm"))
- context.setContextPath("/")
- context.addServlet(new ServletHolder(staticServlet()), "/")
- server.setHandler(context)
+ val server = new WebServer(livyConf, "0.0.0.0", 0)
+ server.context.setSecurityHandler(basicAuth(username, password, "realm"))
+ server.context.setResourceBase("src/main/com/cloudera/livy/server")
+ server.context.setInitParameter(ScalatraListener.LifeCycleKey,
+ classOf[HttpClientTestBootstrap].getCanonicalName)
+ server.context.addEventListener(new ScalatraListener)
server.start()
val utf8Name = UTF_8.name()
- val uri = new URIBuilder(server.getURI())
+ val uri = new URIBuilder()
+ .setScheme(server.protocol)
+ .setHost(server.host)
+ .setPort(server.port)
.setUserInfo(URLEncoder.encode(username, utf8Name), URLEncoder.encode(password, utf8Name))
.build()
info(uri.toString)
val conn = new LivyConnection(uri, new HttpConf(null))
try {
- conn.get(classOf[Boolean], "/") shouldBe true
+ conn.get(classOf[Object], "/") should not be (null)
+
} finally {
conn.close()
}
@@ -100,5 +98,22 @@ class LivyConnectionSpec extends FunSpecLike with BeforeAndAfterAll with LivyBas
it("should support HTTP auth with empty password") {
test("")
}
+
+ it("should be failed with large header size") {
+ val livyConf = new LivyConf()
+ .set(LivyConf.REQUEST_HEADER_SIZE, 1024)
+ .set(LivyConf.RESPONSE_HEADER_SIZE, 1024)
+ val pwd = "test-password" * 100
+ val exception = intercept[IOException](test(pwd, livyConf))
+ exception.getMessage.contains("Request Entity Too Large") should be(true)
+ }
+
+ it("should be succeeded with configured header size") {
+ val livyConf = new LivyConf()
+ .set(LivyConf.REQUEST_HEADER_SIZE, 2048)
+ .set(LivyConf.RESPONSE_HEADER_SIZE, 2048)
+ val pwd = "test-password" * 100
+ test(pwd, livyConf)
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/2abb8a3d/conf/livy.conf.template
----------------------------------------------------------------------
diff --git a/conf/livy.conf.template b/conf/livy.conf.template
index 8bef995..d57717a 100644
--- a/conf/livy.conf.template
+++ b/conf/livy.conf.template
@@ -19,6 +19,10 @@
# What spark deploy mode Livy sessions should use.
# livy.spark.deploy-mode =
+# Configure Livy server http request and response header size.
+# livy.server.request-header.size = 131072
+# livy.server.response-header.size = 131072
+
# Enabled to check whether timeout Livy sessions should be stopped.
# livy.server.session.timeout-check = true