Skip to content

Commit

Permalink
Increase max-content-length to 50 MB (#4059)
Browse files Browse the repository at this point in the history
  • Loading branch information
chetanmeh authored and rabbah committed Oct 12, 2018
1 parent cca09ad commit 4783c99
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/scala/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ akka.http {
client {
parsing.illegal-header-warnings = off
parsing.max-chunk-size = 50m
parsing.max-content-length = 50m
}

host-connection-pool {
Expand Down
12 changes: 12 additions & 0 deletions tests/src/test/scala/common/WhiskProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ public static boolean onLinux() {
return osname.equalsIgnoreCase("linux");
}

public static int getMaxActionSizeMB(){
return Integer.parseInt(getProperty("whisk.action.size.max", "10"));
}

/**
* python interpreter.
*/
Expand Down Expand Up @@ -397,6 +401,14 @@ private static boolean isWhiskPropertiesRequired() {
return getPropFromSystemOrEnv(WHISK_SERVER) == null;
}

private static String getProperty(String key, String defaultValue) {
String value = getPropFromSystemOrEnv(key);
if (value == null) {
value = whiskProperties.getProperty(key, defaultValue);
}
return value;
}

private static String getPropFromSystemOrEnv(String key) {
String value = System.getProperty(key);
if (value == null) {
Expand Down
26 changes: 26 additions & 0 deletions tests/src/test/scala/system/basic/WskActionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

package system.basic

import java.io.File
import java.nio.charset.StandardCharsets

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common._
import common.rest.WskRestOperations
import org.apache.commons.io.FileUtils
import spray.json._
import spray.json.DefaultJsonProtocol._

Expand Down Expand Up @@ -289,4 +293,26 @@ class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers with
activation.logs.get.mkString(" ") should include(s"hello, $utf8")
}
}

it should "invoke action with large code" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val name = "big-hello"
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
val filePath = TestUtils.getTestActionFilename("hello.js")
val code = FileUtils.readFileToString(new File(filePath), StandardCharsets.UTF_8)
val largeCode = code + " " * (WhiskProperties.getMaxActionSizeMB * FileUtils.ONE_MB).toInt
val tmpFile = File.createTempFile("whisk", ".js")
FileUtils.write(tmpFile, largeCode, StandardCharsets.UTF_8)
val result = action.create(name, Some(tmpFile.getAbsolutePath))
tmpFile.delete()
result
}

val hello = "hello"
val run = wsk.action.invoke(name, Map("payload" -> hello.toJson))
withActivation(wsk.activation, run) { activation =>
activation.response.status shouldBe "success"
activation.logs.get.mkString(" ") should include(s"hello, $hello")
}
}

}

0 comments on commit 4783c99

Please sign in to comment.