Skip to content

Commit

Permalink
Add the fundamental framework of REST invocation for test cases (#2589)
Browse files Browse the repository at this point in the history
* Add the fundamental framework of REST invocation for test cases to replace wsk binary

Almost all the test cases in OpenWhisk are currently running based
on the wsk CLI binary. In order to separate the CLI out of OpenWhisk
core repository, we need to call REST API of OpenWhisk to access
OpenWhisk services instead of calling the wsk CLI binary command.

This PR adds the basic REST implementation for all the test cases
to use. One basic principle is to keep the changes to the existing
test cases as few as possible, so we add WskRest.scala as an equivalent
class to Wsk.scala and WskRestTestHelpers.scala as an equivalent file
to WskTestHelpers.scala for REST.

All the replacement of binary with REST will happen in an increamental fashion.
This PR only changes one existing test case in WskActionTests.scala, and
reimplements it in WskRestActionTests.scala. All the other test cases can follow
the same way to change the test cases one by one. New changes may be necessary
to the basic REST implementation as well in future to accommodate the test cases.

* Fixed the concerns regarding the comments

* Fixed comments about null and option match

* Get rid of null for rest result

* Consolidate the option map by getOrElse

* Refactor the function getNamespaceEntityName
  • Loading branch information
Vincent authored and dubee committed Oct 20, 2017
1 parent 4828692 commit 1c5c78b
Show file tree
Hide file tree
Showing 3 changed files with 1,431 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/src/test/scala/common/TestUtils.java
Expand Up @@ -212,7 +212,7 @@ public static class RunResult {
public final String stdout;
public final String stderr;

private RunResult(int exitCode, String stdout, String stderr) {
protected RunResult(int exitCode, String stdout, String stderr) {
this.exitCode = exitCode;
this.stdout = stdout;
this.stderr = stderr;
Expand Down
16 changes: 8 additions & 8 deletions tests/src/test/scala/common/Wsk.scala
Expand Up @@ -62,14 +62,14 @@ import whisk.utils.retry
* It also sets the apihost and apiversion explicitly to avoid ambiguity with
* a local property file if it exists.
*/
class Wsk() extends RunWskCmd {
implicit val action = new WskAction
implicit val trigger = new WskTrigger
implicit val rule = new WskRule
implicit val activation = new WskActivation
implicit val pkg = new WskPackage
implicit val namespace = new WskNamespace
implicit val api = new WskApi
class Wsk() extends RunWskCmd with BaseWsk {
override implicit val action = new WskAction
override implicit val trigger = new WskTrigger
override implicit val rule = new WskRule
override implicit val activation = new WskActivation
override implicit val pkg = new WskPackage
override implicit val namespace = new WskNamespace
override implicit val api = new WskApi
}

trait ListOrGetFromCollectionCLI extends BaseListOrGetFromCollection {
Expand Down

0 comments on commit 1c5c78b

Please sign in to comment.