Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ notifications:
secure: Yc9ZlTaxhcZT3GWkYyiKpREEORBDLNoTHRqBJNOKvIF1oOCZPH0E9KqaJewwcoSno9G8yhd239kzYtv34moAxYdyKe89SomiH+9wFFpjlS7Ge28+VTWv8yr1EL6pUMW7rJDDODeKxwEHMkdCMARFLrYlQ8xM9quWrc98zqULwusIZpGyVwT3K/4PpWL1OH7D9d0Ain3jods1t7hEzlt8XykLhxpu20bKtxo/0rBJre7f6oCCjEARsHJkvx31VuuZAp5cCLOXPc22Fsd7kqOzzGpsLQICURwUqf7DR8qWyFyXT3QnfJwc2uYXE1yj6SOGxHV1jXOSIymiUFD+8afHlm4SBnqo0UhAIf1z3AJ7r+MSsCTLK7w7kY1WjfOXCK74hiNzS8WmzZJ7C3cVCKYEaxYDDbpUqx9b1+gRaf+acJEuvkMLlkJo5Rze+njdeR9RZbR7i0KR3OCLjXDlu87P2orq6iMNCTDs1FtXlOFeeL42o1YcL1CCKnVXr9feGDSmpZ7Y1ypih+yoeFRYrdG/rPEcgppPXCZBbCWqlzAoRMDrFck+weHTCyMzm16moz2dAxCulm8TrUlb5z4ClbasD6sfdaSFskQtpnW6JtG9gIQt6pfJGkHzMV3Js06sUTNhRWtiLXyUJAftN2xq1skFoMR5beg2a1H9+OKeS03a45E=

before_install:
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_10110adb91b4_key -iv $encrypted_10110adb91b4_iv -in tests/credentials.json.enc -out tests/credentials.json -d; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K "$encrypted_8D2E480FC532_key" -iv "$encrypted_8D2E480FC532_iv" -in tests/credentials.json.enc -out tests/credentials.json -d; fi'
- "./tools/travis/setup.sh"
install: true
script:
Expand Down
11 changes: 11 additions & 0 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ dependencies {
tasks.withType(ScalaCompile) {
scalaCompileOptions.additionalParameters = gradle.scala.compileFlags
}

task buildArtifacts(type:Exec) {
workingDir 'src/test/resources'
commandLine './build.sh'
}

tasks.withType(Test) {
dependsOn buildArtifacts
}

testClasses.dependsOn(buildArtifacts)
Binary file modified tests/credentials.json.enc
Binary file not shown.
16 changes: 13 additions & 3 deletions tests/dat/db2/testDB2Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ def main(args):
print ("Connection failed.")
return {"error":"Error connecting to db2"}

# Select from TestTable (the row just inserted)
cmd = "SELECT HISP_DESC FROM SAMPLES.HISPANIC_ORIGIN WHERE HISP_CODE='03'"
# Select from TestTable (the row just inserted).
#
# Due to the db2 lite plan we use, the schema name is fixed to be
# the same as the username. We cut the value of the UID field
# in the ssldsn to get it and insert it in the select statement.
# The ssldsn looks like this:
# ssldsn="DATABASE=BLUDB;HOSTNAME=dashdb-xxxx.services.dal.bluemix.net;PORT=50001;PROTOCOL=TCPIP;UID=yyyyyyy;PWD=<hidden>;"
#
ssldsndict = dict(x.split("=") for x in ssldsn.rstrip(";").split(";"))
print("user={}".format(ssldsndict["UID"]))

cmd = "SELECT HISP_DESC FROM {}.HISPANIC_ORIGIN WHERE HISP_CODE='03'".format(ssldsndict["UID"])
result = ibm_db.exec_immediate(conn, cmd)

if not result:
Expand All @@ -27,4 +37,4 @@ def main(args):
if __name__ == "__main__":
# execute only if run as a script
input = {"__bx_creds":{"dashDB":{"ssldsn":"<ssldsn from credentials>"}}}
print(main(input))
print(main(input))
7 changes: 3 additions & 4 deletions tests/dat/watson/testWatsonService.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def main(args):
language_translator = LanguageTranslatorV3(
version="2018-05-01",
url=args.get("url"),
username=args.get("username"),
password=args.get("password"))
username="APIKey",
password=args.get("apikey"))

translation = language_translator.translate(text='Hello', model_id='en-es')
if LooseVersion(sdk_version) < LooseVersion('2.0.0'):
Expand All @@ -20,6 +20,5 @@ def main(args):
if __name__ == "__main__":
# execute only if run as a script
input = {"url":"<url from credentials>",
"username":"<username from credentials>",
"password":"<password from credentials>"}
"apikey":"<apikey from credentials>"}
print(main(input))
8 changes: 8 additions & 0 deletions tests/src/test/resources/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

# build the necessary resources for the testcases
# this is not implemented, yet
# it will look like this:
# (cd python-zip && zip ../python.zip -r .)
Binary file added tests/src/test/resources/python2_virtualenv.zip
Binary file not shown.
Binary file added tests/src/test/resources/python3_virtualenv.zip
Binary file not shown.
Binary file added tests/src/test/resources/python_virtualenv_dir.zip
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package runtime.actionContainers

import java.io.File
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import spray.json.DefaultJsonProtocol._
Expand All @@ -24,7 +25,6 @@ import common.WskActorSystem
import actionContainers.{ActionContainer, BasicActionRunnerTests}
import actionContainers.ActionContainer.withContainer
import actionContainers.ResourceHelpers.{readAsBase64, ZipBuilder}
import common.TestUtils
import java.nio.file.Paths

@RunWith(classOf[JUnitRunner])
Expand Down Expand Up @@ -105,6 +105,7 @@ class IBMPythonActionContainerTests extends BasicActionRunnerTests with WskActor
| "api_key": os.environ['__OW_API_KEY'],
| "namespace": os.environ['__OW_NAMESPACE'],
| "action_name": os.environ['__OW_ACTION_NAME'],
| "action_version": os.environ['__OW_ACTION_VERSION'],
| "activation_id": os.environ['__OW_ACTIVATION_ID'],
| "deadline": os.environ['__OW_DEADLINE']
| }
Expand Down Expand Up @@ -213,9 +214,17 @@ class IBMPythonActionContainerTests extends BasicActionRunnerTests with WskActor
})
}

//
// return the full path/filename of a file from the classpath
//
def testArtifact(name: String): String = {
new File(this.getClass.getClassLoader.getResource(name).toURI).toString()
}

it should "report error if zipped Python action containing a virtual environment for wrong python version" in {
val zippedPythonAction = "python2_virtualenv.zip"
val zippedPythonActionName = TestUtils.getTestActionFilename(zippedPythonAction)
val zippedPythonActionName = testArtifact(zippedPythonAction)

val code = readAsBase64(Paths.get(zippedPythonActionName))

val (out, err) = withActionContainer() { c =>
Expand All @@ -242,7 +251,7 @@ class IBMPythonActionContainerTests extends BasicActionRunnerTests with WskActor
}

it should "report error if zipped Python action has wrong main module name" in {
val zippedPythonActionWrongName = TestUtils.getTestActionFilename("python_virtualenv_name.zip")
val zippedPythonActionWrongName = testArtifact("python_virtualenv_name.zip")

val code = readAsBase64(Paths.get(zippedPythonActionWrongName))

Expand All @@ -260,7 +269,7 @@ class IBMPythonActionContainerTests extends BasicActionRunnerTests with WskActor
}

it should "report error if zipped Python action has invalid virtualenv directory" in {
val zippedPythonActionWrongDir = TestUtils.getTestActionFilename("python_virtualenv_dir.zip")
val zippedPythonActionWrongDir = testArtifact("python_virtualenv_dir.zip")

val code = readAsBase64(Paths.get(zippedPythonActionWrongDir))
val (out, err) = withActionContainer() { c =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class CredentialsIBMPythonWatsonTests extends TestHelpers with WskTestHelpers wi
JsonParser(ParserInput(vcapString)).asJsObject.fields("language_translator").asInstanceOf[JsArray].elements(0)
val creds = vcapInfo.asJsObject.fields("credentials").asJsObject
val url = creds.fields("url").asInstanceOf[JsString]
val username = creds.fields("username").asInstanceOf[JsString]
val password = creds.fields("password").asInstanceOf[JsString]
val apikey = creds.fields("apikey").asInstanceOf[JsString]

/*
Uses Watson Translation Service to translate the word "Hello" in English, to "Hola" in Spanish.
Expand All @@ -55,7 +54,7 @@ class CredentialsIBMPythonWatsonTests extends TestHelpers with WskTestHelpers wi
file,
main = Some("main"),
kind = defaultKind,
parameters = Map("url" -> url, "username" -> username, "password" -> password))
parameters = Map("url" -> url, "apikey" -> apikey))
}

withActivation(wsk.activation, wsk.action.invoke(actionName)) { activation =>
Expand Down
2 changes: 1 addition & 1 deletion tools/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ docker tag openwhisk/python2action python2action

TERM=dumb ./gradlew install

# Build IBM nodejs runtime
# Build IBM Python runtime images
cd $ROOTDIR
TERM=dumb ./gradlew distDocker -PdockerImagePrefix=${IMAGE_PREFIX}
6 changes: 5 additions & 1 deletion tools/travis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ SCRIPTDIR=$(cd $(dirname "$0") && pwd)
ROOTDIR="$SCRIPTDIR/../.."
HOMEDIR="$SCRIPTDIR/../../../"

# OpenWhisk stuff
# clone openWhisk
cd $HOMEDIR
git clone --depth=1 https://github.com/apache/openwhisk.git openwhisk

# setup the openwhisk environment
cd openwhisk
./tools/travis/setup.sh

# Also build required test artifacts
./gradlew :tests:buildArtifacts