You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/09/24 03:47:29 UTC
[incubator-openwhisk-runtime-go] 02/02: minor updates to travis 1.11
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-go.git
commit c9fd6e82fc0a9d73d7fd2ae6cc6aa27acfbf0544
Author: Carlos Santana <cs...@apache.org>
AuthorDate: Sun Sep 23 15:32:36 2018 -0400
minor updates to travis 1.11
---
.travis.yml | 6 +-
.../actionContainers/ActionLoopBasicGoTests.scala | 15 ++--
.../actionContainers/ActionLoopBasicTests.scala | 12 +--
.../ActionLoopContainerTests.scala | 28 +++---
.../ActionLoopGoContainerTests.scala | 99 ++++++++++------------
.../actionContainers/GoResourceHelpers.scala | 38 ++++++---
tools/travis/publish.sh | 11 +++
tools/travis/test.sh | 2 +-
8 files changed, 115 insertions(+), 96 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a240ad2..a2ef5e3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@
sudo: required
language: go
go:
-- 1.10.2
+- "1.11"
services:
- docker
notifications:
@@ -25,13 +25,13 @@ deploy:
repo: apache/incubator-openwhisk-runtime-go
- provider: script
skip_cleanup: true
- script: "./tools/travis/publish.sh openwhisk actionProxyLoop master"
+ script: "./tools/travis/publish.sh openwhisk actionProxyLoop latest"
on:
branch: master
repo: apache/incubator-openwhisk-runtime-go
- provider: script
skip_cleanup: true
- script: "./tools/travis/publish.sh openwhisk golang1.10 master"
+ script: "./tools/travis/publish.sh openwhisk golang1.11 latest"
on:
branch: master
repo: apache/incubator-openwhisk-runtime-go
diff --git a/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicGoTests.scala b/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicGoTests.scala
index 5534474..72d3b96 100644
--- a/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicGoTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicGoTests.scala
@@ -23,16 +23,20 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class ActionLoopBasicGoTests extends BasicActionRunnerTests with WskActorSystem {
+class ActionLoopBasicGoTests
+ extends BasicActionRunnerTests
+ with WskActorSystem {
val goCompiler = "actionloop-golang-v1.11"
val image = goCompiler
- override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = {
+ override def withActionContainer(env: Map[String, String] = Map.empty)(
+ code: ActionContainer => Unit) = {
withContainer(image, env)(code)
}
- def withActionLoopContainer(code: ActionContainer => Unit) = withContainer(image)(code)
+ def withActionLoopContainer(code: ActionContainer => Unit) =
+ withContainer(image)(code)
behavior of image
@@ -80,7 +84,6 @@ class ActionLoopBasicGoTests extends BasicActionRunnerTests with WskActorSystem
|}
""".stripMargin)
-
override val testEnv = TestConfig(
"""
|package main
@@ -109,7 +112,9 @@ class ActionLoopBasicGoTests extends BasicActionRunnerTests with WskActorSystem
|func niam(args map[string]interface{}) map[string]interface{} {
| return args
|}
- """.stripMargin, main="niam")
+ """.stripMargin,
+ main = "niam"
+ )
override val testLargeInput = TestConfig(
"""|package main
diff --git a/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicTests.scala b/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicTests.scala
index 32d43c3..7936af4 100644
--- a/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/ActionLoopBasicTests.scala
@@ -27,25 +27,25 @@ class ActionLoopBasicTests extends BasicActionRunnerTests with WskActorSystem {
val image = "actionloop"
- override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = {
+ override def withActionContainer(env: Map[String, String] = Map.empty)(
+ code: ActionContainer => Unit) = {
withContainer(image, env)(code)
}
- def withActionLoopContainer(code: ActionContainer => Unit) = withContainer(image)(code)
+ def withActionLoopContainer(code: ActionContainer => Unit) =
+ withContainer(image)(code)
behavior of image
override val testNoSourceOrExec = TestConfig("")
- override val testNotReturningJson = TestConfig(
- """#!/bin/bash
+ override val testNotReturningJson = TestConfig("""#!/bin/bash
|read line
|echo '"not json"' >&3
|read line
|""".stripMargin)
- override val testEcho = TestConfig(
- """|#!/bin/bash
+ override val testEcho = TestConfig("""|#!/bin/bash
|while read line
|do
| echo "hello stdout"
diff --git a/tests/src/test/scala/runtime/actionContainers/ActionLoopContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/ActionLoopContainerTests.scala
index 9c2ebfb..002bbc8 100644
--- a/tests/src/test/scala/runtime/actionContainers/ActionLoopContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/ActionLoopContainerTests.scala
@@ -26,13 +26,16 @@ import org.scalatest.junit.JUnitRunner
import spray.json.{JsObject, JsString}
@RunWith(classOf[JUnitRunner])
-class ActionLoopContainerTests extends ActionProxyContainerTestUtils with WskActorSystem {
+class ActionLoopContainerTests
+ extends ActionProxyContainerTestUtils
+ with WskActorSystem {
import GoResourceHelpers._
val image = "actionloop"
- def withActionLoopContainer(code: ActionContainer => Unit) = withContainer("actionloop")(code)
+ def withActionLoopContainer(code: ActionContainer => Unit) =
+ withContainer("actionloop")(code)
behavior of "actionloop"
@@ -58,7 +61,6 @@ class ActionLoopContainerTests extends ActionProxyContainerTestUtils with WskAct
private def okMsg(key: String, value: String) =
200 -> Some(JsObject(key -> JsString(value)))
-
it should "run sample with init that does nothing" in {
val (out, err) = withActionLoopContainer { c =>
c.init(JsObject())._1 should be(403)
@@ -66,25 +68,21 @@ class ActionLoopContainerTests extends ActionProxyContainerTestUtils with WskAct
}
}
-
it should "deploy a shell script" in {
val script = shCodeHello("main")
val mesg = ExeBuilder.mkBase64Src(script, "main")
- withActionLoopContainer {
- c =>
- val payload = initPayload(mesg)
- c.init(payload)._1 should be(200)
- c.run(helloMsg()) should be(okMsg("main", "Hello, Demo"))
+ withActionLoopContainer { c =>
+ val payload = initPayload(mesg)
+ c.init(payload)._1 should be(200)
+ c.run(helloMsg()) should be(okMsg("main", "Hello, Demo"))
}
}
it should "deploy a zip based script" in {
val scr = ExeBuilder.mkBase64SrcZip(shCodeHello("main"), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(scr))._1 should be(200)
- c.run(helloMsg()) should be(okMsg("main", "Hello, Demo"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(scr))._1 should be(200)
+ c.run(helloMsg()) should be(okMsg("main", "Hello, Demo"))
}
}
- }
-
+}
diff --git a/tests/src/test/scala/runtime/actionContainers/ActionLoopGoContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/ActionLoopGoContainerTests.scala
index b59e306..54857e0 100644
--- a/tests/src/test/scala/runtime/actionContainers/ActionLoopGoContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/ActionLoopGoContainerTests.scala
@@ -29,14 +29,17 @@ import org.scalatest.junit.JUnitRunner
import spray.json.{JsObject, JsString}
@RunWith(classOf[JUnitRunner])
-class ActionLoopGoContainerTests extends ActionProxyContainerTestUtils with WskActorSystem {
+class ActionLoopGoContainerTests
+ extends ActionProxyContainerTestUtils
+ with WskActorSystem {
import GoResourceHelpers._
val goCompiler = "actionloop-golang-v1.11"
val image = goCompiler
- def withActionLoopContainer(code: ActionContainer => Unit) = withContainer(image)(code)
+ def withActionLoopContainer(code: ActionContainer => Unit) =
+ withContainer(image)(code)
behavior of image
@@ -69,7 +72,6 @@ class ActionLoopGoContainerTests extends ActionProxyContainerTestUtils with WskA
private def okMsg(key: String, value: String) =
200 -> Some(JsObject(key -> JsString(value)))
-
it should "run sample with init that does nothing" in {
val (out, err) = withActionLoopContainer { c =>
c.init(JsObject())._1 should be(403)
@@ -78,103 +80,90 @@ class ActionLoopGoContainerTests extends ActionProxyContainerTestUtils with WskA
}
it should "accept a binary main" in {
- val exe = ExeBuilder.mkBase64Exe(
- goCompiler, helloSrc("main"), "main")
+ val exe = ExeBuilder.mkBase64Exe(goCompiler, helloSrc("main"), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(exe))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(exe))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
}
}
-
//def pr(x: Any) = { println(x) ; x}
it should "accept a zipped main binary" in {
- val zip = ExeBuilder.mkBase64Zip(
- goCompiler, helloSrc("main"), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(zip))._1 should be(200)
- c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
+ val zip = ExeBuilder.mkBase64Zip(goCompiler, helloSrc("main"), "main")
+ withActionLoopContainer { c =>
+ c.init(initPayload(zip))._1 should be(200)
+ c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
}
}
it should "accept a binary not-main" in {
- val exe = ExeBuilder.mkBase64Exe(
- goCompiler, helloSrc("hello"), "hello")
- withActionLoopContainer {
- c =>
- c.init(initPayload(exe, "hello"))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
+ val exe = ExeBuilder.mkBase64Exe(goCompiler, helloSrc("hello"), "hello")
+ withActionLoopContainer { c =>
+ c.init(initPayload(exe, "hello"))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
}
}
it should "accept a zipped binary not-main" in {
- val zip = ExeBuilder.mkBase64Zip(
- goCompiler, helloSrc("hello"), "hello")
- withActionLoopContainer {
- c =>
- c.init(initPayload(zip, "hello"))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
+ val zip = ExeBuilder.mkBase64Zip(goCompiler, helloSrc("hello"), "hello")
+ withActionLoopContainer { c =>
+ c.init(initPayload(zip, "hello"))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
}
}
it should "accept a src main action " in {
var src = ExeBuilder.mkBase64Src(helloSrc("main"), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(src))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(src))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
}
}
it should "accept a src not-main action " in {
var src = ExeBuilder.mkBase64Src(helloSrc("hello"), "hello")
- withActionLoopContainer {
- c =>
- c.init(initPayload(src, "hello"))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(src, "hello"))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
}
}
-
it should "accept a zipped src main action" in {
var src = ExeBuilder.mkBase64SrcZip(helloSrc("main"), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(src))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(src))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-main", "Hello, Demo!"))
}
}
it should "accept a zipped src not-main action" in {
var src = ExeBuilder.mkBase64SrcZip(helloSrc("hello"), "hello")
- withActionLoopContainer {
- c =>
- c.init(initPayload(src, "hello"))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
+ withActionLoopContainer { c =>
+ c.init(initPayload(src, "hello"))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("main-hello", "Hello, Demo!"))
}
}
it should "deploy a zip main src with subdir" in {
- var src = ExeBuilder.mkBase64SrcZip(Seq(
- Seq("hello", "hello.go") -> helloGo("Hello", "hello"),
- Seq("main") ->
- """
+ var src = ExeBuilder.mkBase64SrcZip(
+ Seq(
+ Seq("hello", "hello.go") -> helloGo("Hello", "hello"),
+ Seq("main") ->
+ """
|package main
|import "hello"
|func Main(args map[string]interface{})map[string]interface{} {
| return hello.Hello(args)
|}
""".stripMargin
- ), "main")
- withActionLoopContainer {
- c =>
- c.init(initPayload(src))._1 shouldBe (200)
- c.run(helloMsg()) should be(okMsg("hello-Hello", "Hello, Demo!"))
+ ),
+ "main"
+ )
+ withActionLoopContainer { c =>
+ c.init(initPayload(src))._1 shouldBe (200)
+ c.run(helloMsg()) should be(okMsg("hello-Hello", "Hello, Demo!"))
}
}
}
-
diff --git a/tests/src/test/scala/runtime/actionContainers/GoResourceHelpers.scala b/tests/src/test/scala/runtime/actionContainers/GoResourceHelpers.scala
index 1370fe5..02782a6 100644
--- a/tests/src/test/scala/runtime/actionContainers/GoResourceHelpers.scala
+++ b/tests/src/test/scala/runtime/actionContainers/GoResourceHelpers.scala
@@ -29,6 +29,7 @@ import actionContainers.ResourceHelpers
import scala.util.Random
object GoResourceHelpers {
+
/** Create a temporary directory in your /tmp directory.
* /tmp/openwhisk/random-lowercase-string/prefix+suffix
*
@@ -39,12 +40,18 @@ object GoResourceHelpers {
*
*/
def tmpDirectoryFile(prefix: String, suffix: String = "") =
- new File(new File(new File("/tmp", "openwhisk"),
- Random.alphanumeric.take(10).toArray.mkString.toLowerCase /*random filename alphanumeric and lower case*/)
- , prefix++suffix)
+ new File(
+ new File(new File("/tmp", "openwhisk"),
+ Random.alphanumeric
+ .take(10)
+ .toArray
+ .mkString
+ .toLowerCase /*random filename alphanumeric and lower case*/ ),
+ prefix ++ suffix
+ )
def createTmpDirectory(prefix: String, suffix: String = "") = {
- val tmpDir = tmpDirectoryFile(prefix,suffix)
+ val tmpDir = tmpDirectoryFile(prefix, suffix)
tmpDir.mkdirs()
tmpDir.toPath.toAbsolutePath
}
@@ -62,7 +69,9 @@ object GoResourceHelpers {
val arPath = createTmpDirectory("output", extension).toAbsolutePath()
// We "mount" it as a filesystem, so we can just copy files into it.
- val dstUri = new URI("jar:" + arPath.toUri().getScheme(), arPath.toAbsolutePath().toString(), null)
+ val dstUri = new URI("jar:" + arPath.toUri().getScheme(),
+ arPath.toAbsolutePath().toString(),
+ null)
// OK, that's a hack. Doing this because newFileSystem wants to create that file.
arPath.toFile().delete()
val fs = FileSystems.newFileSystem(dstUri, Map(("create" -> "true")).asJava)
@@ -91,14 +100,14 @@ object GoResourceHelpers {
FileVisitResult.CONTINUE
}
- })
+ }
+ )
fs.close()
arPath
}
-
/**
* Creates a temporary directory in the home and reproduces the desired file structure
* in it. Returns the path of the temporary directory and the path of each
@@ -108,7 +117,8 @@ object GoResourceHelpers {
* a tmp folder in the home directory.
*
* */
- private def writeSourcesToHomeTmpDirectory(sources: Seq[(Seq[String], String)]): (Path, Seq[Path]) = {
+ private def writeSourcesToHomeTmpDirectory(
+ sources: Seq[(Seq[String], String)]): (Path, Seq[Path]) = {
// A temporary directory for the source files.
val srcDir = createTmpDirectory("src")
val srcAbsPaths = for ((sourceName, sourceContent) <- sources) yield {
@@ -145,7 +155,9 @@ object GoResourceHelpers {
// prepare sources, then compile them
// return the exe File and the output dir Path
- private def compile(image: String, sources: Seq[(Seq[String], String)], main: String) = {
+ private def compile(image: String,
+ sources: Seq[(Seq[String], String)],
+ main: String) = {
require(!sources.isEmpty)
// The absolute paths of the source file
@@ -172,13 +184,17 @@ object GoResourceHelpers {
}
- def mkBase64Exe(image: String, sources: Seq[(Seq[String] /*lines*/, String /*name*/)], main: String) = {
+ def mkBase64Exe(image: String,
+ sources: Seq[(Seq[String] /*lines*/, String /*name*/ )],
+ main: String) = {
val (exe, dir) = compile(image, sources, main)
//println(s"exe=${exe.getAbsolutePath}")
ResourceHelpers.readAsBase64(exe.toPath)
}
- def mkBase64Zip(image: String, sources: Seq[(Seq[String], String)], main: String) = {
+ def mkBase64Zip(image: String,
+ sources: Seq[(Seq[String], String)],
+ main: String) = {
val (exe, dir) = compile(image, sources, main)
val archive = makeZipFromDir(dir)
//println(s"zip=${archive.toFile.getAbsolutePath}")
diff --git a/tools/travis/publish.sh b/tools/travis/publish.sh
index 51690f2..cad9d8a 100755
--- a/tools/travis/publish.sh
+++ b/tools/travis/publish.sh
@@ -34,4 +34,15 @@ TERM=dumb ./gradlew \
-PdockerRegistry=docker.io \
-PdockerImagePrefix=${IMAGE_PREFIX} \
-PdockerImageTag=${IMAGE_TAG}
+
+ # if doing latest also push a tag with the hash commit
+ if [ ${IMAGE_TAG} == "latest" ]; then
+ SHORT_COMMIT=`git rev-parse --short HEAD`
+ TERM=dumb ./gradlew \
+ :core:${RUNTIME}:distDocker \
+ -PdockerRegistry=docker.io \
+ -PdockerImagePrefix=${IMAGE_PREFIX} \
+ -PdockerImageTag=${SHORT_COMMIT}
+ fi
+
fi
diff --git a/tools/travis/test.sh b/tools/travis/test.sh
index 2534d83..d11e175 100755
--- a/tools/travis/test.sh
+++ b/tools/travis/test.sh
@@ -27,6 +27,6 @@ WHISKDIR="$ROOTDIR/../openwhisk"
export OPENWHISK_HOME=$WHISKDIR
cd ${ROOTDIR}
TERM=dumb ./gradlew :tests:test
-
+go version
TERM=dumb ./gradlew test --info