Fix deprecated issue & Support array result (#517)
* Fix deprecated issue
* Upgrade gradle to 6.9
* Add mavenCentral
* Add depVersion
* Add rest-assured lib
* Fix test code compile error
* Specify the akka-discovery version
* Make ActorSystem binds to a free port
This is avoid test case avoid below problem:
java.net.BindException: [/127.0.0.1:25520] Address already in use
After added this change, every test case will used a random port.
* Add latest dependency
- openwhisk-wskdeploy
- openwhisk-client-go
* Support array result
* Fix review comment
If return array, make the result return empty string
* Adjust limit_invocations_per_minute for travis env
* Build image to keep test code consistent with openwhisk
* Deploy etcd and elasticsearch
* Add akka-http2-support akka-http-xml lib
* Fix does not return activationId
* Change nodejs:10 to nodejs:14
* Add pureconfig to travis script
Avoid does not find pureconfig during testing CLI tests
* Use deprecated lib to avoid test case failed
Just for system.basic.WskCliActivationTests
diff --git a/build.gradle b/build.gradle
index dde0a2f..b7524b3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,6 +19,7 @@
buildscript {
repositories {
jcenter()
+ mavenCentral()
}
dependencies {
classpath "cz.alenkacz:gradle-scalafmt:${gradle.scalafmt.version}"
diff --git a/commands/action.go b/commands/action.go
index 7d4f5fd..9bd465c 100644
--- a/commands/action.go
+++ b/commands/action.go
@@ -199,7 +199,7 @@
qualifiedName QualifiedName,
parameters interface{},
blocking bool,
- result bool) (map[string]interface{}, error) {
+ result bool) (interface{}, error) {
// TODO remove all global modifiers
Client.Namespace = qualifiedName.GetNamespace()
res, _, err := Client.Actions.Invoke(
@@ -214,7 +214,7 @@
qualifiedName QualifiedName,
blocking bool,
header bool,
- result map[string]interface{},
+ result interface{},
err error) error {
if err == nil {
printInvocationMsg(qualifiedName, blocking, header, result, color.Output)
@@ -232,13 +232,13 @@
func printFailedBlockingInvocationResponse(
qualifiedName QualifiedName,
header bool,
- result map[string]interface{},
+ result interface{},
err error) error {
if isBlockingTimeout(err) {
printBlockingTimeoutMsg(
qualifiedName.GetNamespace(),
qualifiedName.GetEntityName(),
- getValueFromJSONResponse(ACTIVATION_ID, result))
+ getValueFromResponse(ACTIVATION_ID, result))
return err
} else if isApplicationError(err) {
printInvocationMsg(
@@ -1169,7 +1169,7 @@
qualifiedName QualifiedName,
blocking bool,
header bool,
- response map[string]interface{},
+ response interface{},
outputStream io.Writer) {
if header {
fmt.Fprintf(
@@ -1180,7 +1180,7 @@
"ok": color.GreenString("ok:"),
"namespace": boldString(qualifiedName.GetNamespace()),
"name": boldString(qualifiedName.GetEntityName()),
- "id": boldString(getValueFromJSONResponse(ACTIVATION_ID, response)),
+ "id": boldString(getValueFromResponse(ACTIVATION_ID, response)),
}))
}
diff --git a/commands/util.go b/commands/util.go
index 3fd930e..66f6f1e 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -604,17 +604,19 @@
return res
}
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
- var res interface{}
-
- for key, value := range response {
- if key == field {
- res = value
- break
+func getValueFromResponse(field string, response interface{}) interface{} {
+ if result, ok := response.(map[string]interface{}); ok {
+ for key, value := range result {
+ if key == field {
+ return value
+ }
}
}
-
- return res
+ if result, ok := response.([]interface{}); ok {
+ return result
+ } else {
+ return ""
+ }
}
func logoText() string {
diff --git a/go.mod b/go.mod
index d423c8f..fb01683 100644
--- a/go.mod
+++ b/go.mod
@@ -3,8 +3,8 @@
go 1.15
require (
- github.com/apache/openwhisk-client-go v0.0.0-20210311185314-87edc2364717
- github.com/apache/openwhisk-wskdeploy v0.0.0-20210316172333-03df1126c3b5
+ github.com/apache/openwhisk-client-go v0.0.0-20220811044404-a6921af2f086
+ github.com/apache/openwhisk-wskdeploy v0.0.0-20220815044620-520cbbbffb6e
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/fatih/color v1.10.0
diff --git a/go.sum b/go.sum
index 06ec20a..f4cf0c1 100644
--- a/go.sum
+++ b/go.sum
@@ -29,12 +29,16 @@
github.com/apache/openwhisk-client-go v0.0.0-20210311185314-87edc2364717/go.mod h1:SAQU4bHGJ0sg6c1vQ8ojmQKXgGaneVnexWX4+2/KMr8=
github.com/apache/openwhisk-client-go v0.0.0-20210313152306-ea317ea2794c h1:G1xH1WDL9VsJYkcD2ni56hbmVnPO45haTTbacVMpPb8=
github.com/apache/openwhisk-client-go v0.0.0-20210313152306-ea317ea2794c/go.mod h1:SAQU4bHGJ0sg6c1vQ8ojmQKXgGaneVnexWX4+2/KMr8=
+github.com/apache/openwhisk-client-go v0.0.0-20220811044404-a6921af2f086 h1:+JIxWzdw4++XsPA/w9/o+rcLoEiVmTCS2bBedqdDrOA=
+github.com/apache/openwhisk-client-go v0.0.0-20220811044404-a6921af2f086/go.mod h1:SAQU4bHGJ0sg6c1vQ8ojmQKXgGaneVnexWX4+2/KMr8=
github.com/apache/openwhisk-wskdeploy v0.0.0-20200827195556-535f5a9d3942 h1:SDeUi5Wqtv2J/4FkbjyZ3pCEMfy88DMTQix+qmAjo9I=
github.com/apache/openwhisk-wskdeploy v0.0.0-20200827195556-535f5a9d3942/go.mod h1:jRNFwq0Ribf74Jd7oYvoDtBH+RXb5nCVAIHji47ESjY=
github.com/apache/openwhisk-wskdeploy v0.0.0-20210305213302-f4f94e757f09 h1:+mxjBxL1qKwzPCt6mud6mw98ILdXd+0PVzj2ccfLt6k=
github.com/apache/openwhisk-wskdeploy v0.0.0-20210305213302-f4f94e757f09/go.mod h1:BtqnIRBNfk6hM+o3CE8joQZ3lSQm2qS5eVPo/rtoOyE=
github.com/apache/openwhisk-wskdeploy v0.0.0-20210316172333-03df1126c3b5 h1:MocS3KmzireB/s+MkjWDI5cgebAWjOZpUm5Ki2AO2kw=
github.com/apache/openwhisk-wskdeploy v0.0.0-20210316172333-03df1126c3b5/go.mod h1:6CZs4G/NMAHtopqyNVelubokzJt6XGfmsoflAQ+qwjM=
+github.com/apache/openwhisk-wskdeploy v0.0.0-20220815044620-520cbbbffb6e h1:u2T/WYd0rTyc0uCSPe1+QivSVWwPLptv8ItprYn5uOw=
+github.com/apache/openwhisk-wskdeploy v0.0.0-20220815044620-520cbbbffb6e/go.mod h1:RDVSvydyBXkuwj0ofqDbnWjXq6dhtVpLv4ploecui+M=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
@@ -59,6 +63,7 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 61a258f..332b043 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -16,6 +16,6 @@
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/settings.gradle b/settings.gradle
index 7c742d4..5f63b34 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -25,10 +25,14 @@
gradle.ext.scala = [
version: '2.12.7',
- compileFlags: ['-feature', '-unchecked', '-deprecation', '-Xfatal-warnings', '-Ywarn-unused-import']
+ depVersion : '2.12',
+ compileFlags: ['-feature', '-unchecked', '-deprecation', '-Ywarn-unused-import']
]
gradle.ext.scalafmt = [
version: '1.5.0',
config: new File(rootProject.projectDir, '.scalafmt.conf')
]
+
+gradle.ext.akka = [version : '2.6.12']
+gradle.ext.akka_http = [version : '10.2.4']
diff --git a/tests/build.gradle b/tests/build.gradle
index a731586..a8c794d 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -41,9 +41,16 @@
}
dependencies {
- compile "org.scala-lang:scala-library:${gradle.scala.version}"
- compile "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:tests"
- compile "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:test-sources"
+ implementation "com.typesafe.akka:akka-discovery_${gradle.scala.depVersion}:${gradle.akka.version}"
+ implementation "com.typesafe.akka:akka-http2-support_${gradle.scala.depVersion}:${gradle.akka_http.version}"
+ implementation "com.typesafe.akka:akka-http-xml_${gradle.scala.depVersion}:${gradle.akka_http.version}"
+ implementation "io.rest-assured:rest-assured:4.0.0"
+ implementation "junit:junit:4.11"
+ implementation "org.scala-lang:scala-library:${gradle.scala.version}"
+ implementation "org.scalatest:scalatest_${gradle.scala.depVersion}:3.0.8"
+ implementation "org.apache.openwhisk:openwhisk-common:${gradle.openwhisk.version}"
+ implementation "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:tests"
+ implementation "org.apache.openwhisk:openwhisk-tests:${gradle.openwhisk.version}:test-sources"
}
tasks.withType(ScalaCompile) {
diff --git a/tests/src/test/resources/application.conf b/tests/src/test/resources/application.conf
index 62fddd3..e73f414 100644
--- a/tests/src/test/resources/application.conf
+++ b/tests/src/test/resources/application.conf
@@ -17,6 +17,9 @@
# test-only overrides so that tests can override defaults in application.conf
# (todo: move all defaults to reference.conf)
+
+# Each ActorSystem binds to a free port
+akka.remote.artery.canonical.port=0
test {
whisk {
concurrency-limit {
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
index cafa462..86fda3b 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
@@ -279,8 +279,7 @@
withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
val response = activation.response
- response.result.get
- .fields("error") shouldBe Messages.abnormalInitialization.toJson
+ response.result.get.asJsObject.fields("error") shouldBe Messages.abnormalInitialization.toJson
response.status shouldBe ActivationResponse.messageForCode(ActivationResponse.DeveloperError)
}
}
@@ -294,9 +293,7 @@
withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
val response = activation.response
- response.result.get.fields("error") shouldBe Messages
- .timedoutActivation(3 seconds, true)
- .toJson
+ response.result.get.asJsObject.fields("error") shouldBe Messages.timedoutActivation(3 seconds, true).toJson
response.status shouldBe ActivationResponse.messageForCode(ActivationResponse.DeveloperError)
}
}
@@ -310,7 +307,7 @@
withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
val response = activation.response
- response.result.get.fields("error") shouldBe Messages.abnormalRun.toJson
+ response.result.get.asJsObject.fields("error") shouldBe Messages.abnormalRun.toJson
response.status shouldBe ActivationResponse.messageForCode(ActivationResponse.DeveloperError)
}
}
@@ -484,8 +481,8 @@
withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
val response = activation.response
- response.result.get.fields.get("error") shouldBe empty
- response.result.get.fields.get("author") shouldBe defined
+ response.result.get.asJsObject.fields.get("error") shouldBe empty
+ response.result.get.asJsObject.fields.get("author") shouldBe defined
}
}
@@ -505,7 +502,7 @@
val run = wsk.action.invoke(name)
withActivation(wsk.activation, run) { activation =>
activation.response.status shouldBe ActivationResponse.messageForCode(ActivationResponse.DeveloperError)
- activation.response.result.get
+ activation.response.result.get.asJsObject
.fields("error") shouldBe s"Failed to pull container image '$containerName'.".toJson
activation.annotations shouldBe defined
val limits = activation.annotations.get
@@ -621,14 +618,14 @@
val webEnabled = flag.toLowerCase == "true" || flag.toLowerCase == "yes"
val rawEnabled = flag.toLowerCase == "raw"
- wsk.action.create(name, file, web = Some(flag), update = true, kind = Some("nodejs:10"))
+ wsk.action.create(name, file, web = Some(flag), update = true, kind = Some("nodejs:14"))
val action = wsk.action.get(name)
val baseAnnotations = Parameters("web-export", JsBoolean(webEnabled || rawEnabled)) ++
Parameters("raw-http", JsBoolean(rawEnabled)) ++
Parameters("final", JsBoolean(webEnabled || rawEnabled)) ++
- Parameters("exec", "nodejs:10")
+ Parameters("exec", "nodejs:14")
val testAnnotations = if (requireAPIKeyAnnotation) {
baseAnnotations ++ Parameters(Annotations.ProvideApiKeyAnnotationName, JsFalse)
} else baseAnnotations
@@ -658,7 +655,7 @@
Parameters("web-export", JsTrue) ++
Parameters("raw-http", JsFalse) ++
Parameters("final", JsTrue) ++
- Parameters("exec", "nodejs:10")
+ Parameters("exec", "nodejs:14")
val createAnnotations = if (requireAPIKeyAnnotation) {
baseAnnotations ++
Parameters(Annotations.ProvideApiKeyAnnotationName, JsFalse) ++
@@ -674,10 +671,10 @@
overwrittenValue)
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, file, annotations = createAnnots, kind = Some("nodejs:10"))
+ action.create(name, file, annotations = createAnnots, kind = Some("nodejs:14"))
}
- wsk.action.create(name, file, web = Some("true"), update = true, kind = Some("nodejs:10"))
+ wsk.action.create(name, file, web = Some("true"), update = true, kind = Some("nodejs:14"))
val existingAnnots = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
assert(existingAnnots.startsWith(s"ok: got action $name, displaying field annotations\n"))
@@ -690,7 +687,7 @@
web = Some("true"),
update = true,
annotations = updateAnnots,
- kind = Some("nodejs:10"))
+ kind = Some("nodejs:14"))
val updatedAnnots =
wsk.action.get(name, fieldFilter = Some("annotations")).stdout
@@ -705,14 +702,14 @@
val file = Some(TestUtils.getTestActionFilename("echo.js"))
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, file, web = Some("true"), update = true, kind = Some("nodejs:10"))
+ action.create(name, file, web = Some("true"), update = true, kind = Some("nodejs:14"))
}
val baseAnnotations =
Parameters("web-export", JsTrue) ++
Parameters("raw-http", JsFalse) ++
Parameters("final", JsTrue) ++
- Parameters("exec", "nodejs:10")
+ Parameters("exec", "nodejs:14")
val testAnnotations = if (requireAPIKeyAnnotation) {
baseAnnotations ++
@@ -783,7 +780,7 @@
// -web true --web-secure true -> annotation "require-whisk-auth" value is an int
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, file, web = Some("true"), websecure = Some("true"), kind = Some("nodejs:10"))
+ action.create(name, file, web = Some("true"), websecure = Some("true"), kind = Some("nodejs:14"))
}
var stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
var secretJsVar = removeCLIHeader(stdout).parseJson
@@ -806,11 +803,11 @@
web = Some("true"),
websecure = Some(s"$secretStr"),
update = true,
- kind = Some("nodejs:10"))
+ kind = Some("nodejs:14"))
stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
val actualAnnotations =
removeCLIHeader(stdout).parseJson.convertTo[JsArray].elements
- actualAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:10"))) shouldBe true
+ actualAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:14"))) shouldBe true
actualAnnotations.contains(JsObject("key" -> JsString("web-export"), "value" -> JsBoolean(true))) shouldBe true
actualAnnotations.contains(JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(false))) shouldBe true
actualAnnotations.contains(JsObject("key" -> JsString("final"), "value" -> JsBoolean(true))) shouldBe true
@@ -823,7 +820,7 @@
web = Some("true"),
websecure = Some("true"),
update = true,
- kind = Some("nodejs:10"))
+ kind = Some("nodejs:14"))
stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
val secretNumJsVar = removeCLIHeader(stdout).parseJson
.convertTo[JsArray]
@@ -837,7 +834,7 @@
web = Some("true"),
websecure = Some("true"),
update = true,
- kind = Some("nodejs:10"))
+ kind = Some("nodejs:14"))
removeCLIHeader(stdout).parseJson
.convertTo[JsArray]
.elements
@@ -886,14 +883,14 @@
val secretStr = "my-secret"
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, file, web = Some("true"), annotations = createAnnots, kind = Some("nodejs:10"))
+ action.create(name, file, web = Some("true"), annotations = createAnnots, kind = Some("nodejs:14"))
}
- wsk.action.create(name, file, websecure = Some(secretStr), update = true, kind = Some("nodejs:10"))
+ wsk.action.create(name, file, websecure = Some(secretStr), update = true, kind = Some("nodejs:14"))
var stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
var existingAnnotations =
removeCLIHeader(stdout).parseJson.convertTo[JsArray].elements
- existingAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:10"))) shouldBe true
+ existingAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:14"))) shouldBe true
existingAnnotations.contains(JsObject("key" -> JsString("web-export"), "value" -> JsBoolean(true))) shouldBe true
existingAnnotations.contains(JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(false))) shouldBe true
existingAnnotations.contains(JsObject("key" -> JsString("final"), "value" -> JsBoolean(true))) shouldBe true
@@ -907,11 +904,11 @@
websecure = Some(secretStr),
update = true,
annotations = updateAnnots,
- kind = Some("nodejs:10"))
+ kind = Some("nodejs:14"))
stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
var updatedAnnotations =
removeCLIHeader(stdout).parseJson.convertTo[JsArray].elements
- updatedAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:10"))) shouldBe true
+ updatedAnnotations.contains(JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:14"))) shouldBe true
updatedAnnotations.contains(JsObject("key" -> JsString("web-export"), "value" -> JsBoolean(true))) shouldBe true
updatedAnnotations.contains(JsObject("key" -> JsString("raw-http"), "value" -> JsBoolean(false))) shouldBe true
updatedAnnotations.contains(JsObject("key" -> JsString("final"), "value" -> JsBoolean(true))) shouldBe true
@@ -1223,10 +1220,10 @@
val requireAPIKeyAnnotation = WhiskProperties.getBooleanProperty("whisk.feature.requireApiKeyAnnotation", true)
val expectedParam = JsObject("payload" -> JsString("test"))
val ns = wsk.namespace.whois()
- val expectedExec = JsObject("kind" -> "nodejs:10".toJson, "binary" -> JsFalse)
+ val expectedExec = JsObject("kind" -> "nodejs:14".toJson, "binary" -> JsFalse)
val expectedParams = Parameters("payload", "test")
val baseAnnotations =
- Parameters("exec", "nodejs:10")
+ Parameters("exec", "nodejs:14")
val expectedAnnots = if (requireAPIKeyAnnotation) {
baseAnnotations ++
Parameters(Annotations.ProvideApiKeyAnnotationName, JsFalse)
@@ -1238,7 +1235,7 @@
(wp, assetHelper) =>
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, defaultAction, parameters = paramInput, kind = Some("nodejs:10"))
+ action.create(name, defaultAction, parameters = paramInput, kind = Some("nodejs:14"))
}
wsk.action.get(name, fieldFilter = Some("name")).stdout should include(s"""$successMsg name\n"$name"""")
diff --git a/tests/src/test/scala/system/basic/HttpProxy.scala b/tests/src/test/scala/system/basic/HttpProxy.scala
index c0aa0e8..95b8b75 100644
--- a/tests/src/test/scala/system/basic/HttpProxy.scala
+++ b/tests/src/test/scala/system/basic/HttpProxy.scala
@@ -15,17 +15,17 @@
* limitations under the License.
*/
package system.basic
-import java.net.ServerSocket
+import java.net.ServerSocket
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
import akka.http.scaladsl.model.Uri.Authority
import akka.http.scaladsl.server.Route
-import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
import com.typesafe.sslconfig.akka.AkkaSSLConfig
-import common.{WskActorSystem, WskProps}
import common.rest.{AcceptAllHostNameVerifier, SSL}
+import common.{WskActorSystem, WskProps}
+
import javax.net.ssl.HostnameVerifier
import org.scalatest.Suite
import org.scalatest.concurrent.ScalaFutures
@@ -43,7 +43,6 @@
trait HttpProxy extends WskActorSystem with ScalaFutures {
self: Suite =>
- implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val testConfig: PatienceConfig = PatienceConfig(1.minute)
def withProxy(check: (WskProps, ListBuffer[(HttpRequest, HttpResponse)]) => Unit)(implicit wp: WskProps): Unit = {
@@ -64,7 +63,7 @@
handler
}
- val binding = Http(actorSystem).bindAndHandle(handler = proxy, interface = "localhost", port = port)
+ val binding = Http(actorSystem).newServerAt(interface = "localhost", port = port).bindFlow(proxy)
binding.map { b =>
val proxyProps = wp.copy(apihost = s"http://localhost:$port")
check(proxyProps, requests)
@@ -105,8 +104,8 @@
private def proxyRequest(req: HttpRequest, uri: Uri): HttpRequest = {
//https://github.com/akka/akka-http/issues/64
req
- .copy(headers = req.headers.filterNot(h => h.is("timeout-access")))
- .copy(uri = req.uri.copy(scheme = "", authority = Authority.Empty)) //Strip the authority as it refers to proxy
+ .withHeaders(headers = req.headers.filterNot(h => h.is("timeout-access")))
+ .withUri(uri = req.uri.copy(scheme = "", authority = Authority.Empty)) //Strip the authority as it refers to proxy
}
private def freePort(): Int = {
diff --git a/tools/travis/test_openwhisk.sh b/tools/travis/test_openwhisk.sh
index ca4780d..0cf1042 100755
--- a/tools/travis/test_openwhisk.sh
+++ b/tools/travis/test_openwhisk.sh
@@ -82,22 +82,42 @@
#
cd $OPENWHISK_HOME
+# Build openwhisk image to keep test case code consistent with latest openwhisk core code
+./gradlew distDocker -PdockerImagePrefix=openwhisk -PdockerImageTag=latest
+
# Install Ansible and other pre-reqs
#./tools/travis/setup.sh
# Fire up the cluster
-ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=openwhisk -e docker_image_tag=nightly"
+echo 'limit_invocations_per_minute: 120' >> $OPENWHISK_HOME/ansible/environments/local/group_vars/all
+ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=openwhisk -e docker_image_tag=latest"
cd $OPENWHISK_HOME/ansible
$ANSIBLE_CMD setup.yml
$ANSIBLE_CMD prereq.yml
$ANSIBLE_CMD couchdb.yml
$ANSIBLE_CMD initdb.yml
$ANSIBLE_CMD wipe.yml
-$ANSIBLE_CMD openwhisk.yml -e cli_tag=$openwhisk_cli_tag -e cli_installation_mode=local -e openwhisk_cli_home=$TRAVIS_BUILD_DIR -e controllerProtocolForSetup=http
+$ANSIBLE_CMD elasticsearch.yml
+$ANSIBLE_CMD etcd.yml
+$ANSIBLE_CMD openwhisk.yml -e cli_tag=$openwhisk_cli_tag -e cli_installation_mode=local -e openwhisk_cli_home=$TRAVIS_BUILD_DIR -e controller_protocol=http -e db_activation_backend=ElasticSearch
$ANSIBLE_CMD properties.yml
$ANSIBLE_CMD apigateway.yml
$ANSIBLE_CMD routemgmt.yml
+# avoid does not find pureconfig during testing CLI tests
+cat <<EOT >> $TRAVIS_BUILD_DIR/tests/src/test/resources/application.conf
+whisk {
+ controller {
+ https {
+ keystore-flavor = "PKCS12"
+ keystore-path = "$OPENWHISK_HOME/ansible/roles/controller/files/controller-openwhisk-keystore.p12"
+ keystore-password = "openwhisk"
+ client-auth = "true"
+ }
+ }
+}
+EOT
+
# Run the test cases under openwhisk to ensure the quality of the runnint API.
cd $TRAVIS_BUILD_DIR
./gradlew --console=plain :tests:test --tests=*ApiGwCliTests*