Skip to content

Commit

Permalink
Fix deprecated issue & Support array result (#517)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ningyougang authored Aug 29, 2022
1 parent 7c47ef1 commit ddcce2e
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 61 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "cz.alenkacz:gradle-scalafmt:${gradle.scalafmt.version}"
Expand Down
12 changes: 6 additions & 6 deletions commands/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func invokeAction(
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(
Expand All @@ -214,7 +214,7 @@ func printInvocationResponse(
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)
Expand All @@ -232,13 +232,13 @@ func printInvocationResponse(
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(
Expand Down Expand Up @@ -1169,7 +1169,7 @@ func printInvocationMsg(
qualifiedName QualifiedName,
blocking bool,
header bool,
response map[string]interface{},
response interface{},
outputStream io.Writer) {
if header {
fmt.Fprintf(
Expand All @@ -1180,7 +1180,7 @@ func printInvocationMsg(
"ok": color.GreenString("ok:"),
"namespace": boldString(qualifiedName.GetNamespace()),
"name": boldString(qualifiedName.GetEntityName()),
"id": boldString(getValueFromJSONResponse(ACTIVATION_ID, response)),
"id": boldString(getValueFromResponse(ACTIVATION_ID, response)),
}))
}

Expand Down
20 changes: 11 additions & 9 deletions commands/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,19 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
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 {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/apache/openwhisk-cli
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
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ github.com/apache/openwhisk-client-go v0.0.0-20210311185314-87edc2364717 h1:7MsA
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=
Expand All @@ -59,6 +63,7 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
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=
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ gradle.ext.openwhisk = [

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']
13 changes: 10 additions & 3 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ task testWithoutCredentials(type: Test) {
}

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) {
Expand Down
3 changes: 3 additions & 0 deletions tests/src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit ddcce2e

Please sign in to comment.