Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Allow TCK to run as docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlugter authored May 21, 2020
1 parent c2809f4 commit 9b344d2
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ jobs:
if: tag =~ ^v
script:
- echo "$DOCKER_PASSWORD" | docker login -u cloudstatebot --password-stdin
- sbt "set concurrentRestrictions in Global += Tags.limitAll(1)" "dockerBuildAllNonNative publish" operator/docker:publish
- sbt "set concurrentRestrictions in Global += Tags.limitAll(1)" "dockerBuildAllNonNative publish" operator/docker:publish tck/docker:publish

- stage: Deploy
name: Publish latest builds
if: branch = master AND type = push
script:
- echo "$DOCKER_PASSWORD" | docker login -u cloudstatebot --password-stdin
- sbt -Duse.native.builds=false -Ddocker.tag=latest "set concurrentRestrictions in Global += Tags.limitAll(1)" "dockerBuildAllNonNative publish" operator/docker:publish
- sbt -Duse.native.builds=false -Ddocker.tag=latest "set concurrentRestrictions in Global += Tags.limitAll(1)" "dockerBuildAllNonNative publish" operator/docker:publish tck/docker:publish

cache:
directories:
Expand Down
14 changes: 8 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ lazy val protocols = (project in file("protocols"))
IO.zip(
archiveStructure(cloudstateProtocolsName,
(base / "frontend" ** "*.proto" +++
base / "protocol" ** "*.proto" +++
base / "proxy" ** "*.proto")),
base / "protocol" ** "*.proto")),
cloudstateProtos
)

Expand Down Expand Up @@ -456,7 +455,7 @@ lazy val `proxy-core` = (project in file("proxy/core"))
},
PB.protoSources in Compile ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Seq(baseDir / "proxy", baseDir / "frontend", baseDir / "protocol")
Seq(baseDir / "frontend", baseDir / "protocol")
},
PB.protoSources in Test ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Expand Down Expand Up @@ -796,13 +795,13 @@ lazy val `load-generator` = (project in file("samples/js-shopping-cart-load-gene
)

lazy val `tck` = (project in file("tck"))
.enablePlugins(AkkaGrpcPlugin)
.enablePlugins(AkkaGrpcPlugin, JavaAppPackaging, DockerPlugin)
.configs(IntegrationTest)
.dependsOn(`akka-client`)
.settings(
Defaults.itSettings,
common,
name := "tck",
name := "cloudstate-tck",
libraryDependencies ++= Seq(
akkaDependency("akka-stream"),
akkaDependency("akka-discovery"),
Expand All @@ -814,8 +813,11 @@ lazy val `tck` = (project in file("tck"))
),
PB.protoSources in Compile ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Seq(baseDir / "proxy", baseDir / "protocol")
Seq(baseDir / "protocol")
},
dockerSettings,
Compile / bashScriptDefines / mainClass := Some("org.scalatest.run"),
bashScriptExtraDefines += "addApp io.cloudstate.tck.ConfiguredCloudStateTCK",
javaOptions in IntegrationTest := sys.props.get("config.resource").map(r => s"-Dconfig.resource=$r").toSeq,
parallelExecution in IntegrationTest := false,
executeTests in IntegrationTest := (executeTests in IntegrationTest)
Expand Down
39 changes: 39 additions & 0 deletions tck/src/it/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cloudstate-tck {
#verify is a list of names of combinations to run for the TCK
verify = []
#combinations is a list of config objects with a name, a proxy, and a frontend
combinations = []

tck {
hostname = "127.0.0.1"
hostname = ${?HOST}
port = 8090
}

proxy {
hostname = "127.0.0.1"
hostname = ${?HOST}
port = 9000
directory = ${user.dir}
command = []
stop-command = []
env-vars {
}
# If specified, will start a docker container, with the environment variable USER_FUNCTION_HOST set to the host
# to connect to, USER_FUNCTION_PORT set to the port to connect to, and HTTP_PORT set to the port above.
docker-image = ""
}

frontend {
hostname = "127.0.0.1"
hostname = ${?HOST}
port = 8080
directory = ${user.dir}
command = []
stop-command = []
env-vars {
}
# If specified, will start a docker container, with the environment variable PORT set to the port above.
docker-image = ""
}
}
32 changes: 30 additions & 2 deletions tck/src/it/scala/io/cloudstate/tck/TCK.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.cloudstate.tck

import org.scalatest._
import com.typesafe.config.{Config, ConfigFactory}
import com.typesafe.config.ConfigFactory

import scala.collection.JavaConverters._

Expand All @@ -21,6 +21,34 @@ class TCK extends Suites({
iterator.
asScala.
filter(section => verify(section.getString("name"))).
map(c => new CloudStateTCK(TckConfiguration.fromConfig(c))).
map(c => new ManagedCloudStateTCK(TckConfiguration.fromConfig(c))).
toVector
}: _*) with SequentialNestedSuiteExecution

object ManagedCloudStateTCK {
def settings(config: TckConfiguration): CloudStateTCK.Settings = {
CloudStateTCK.Settings(
CloudStateTCK.Address(config.tckHostname, config.tckPort),
CloudStateTCK.Address(config.proxy.hostname, config.proxy.port),
CloudStateTCK.Address(config.frontend.hostname, config.frontend.port)
)
}
}

class ManagedCloudStateTCK(config: TckConfiguration) extends CloudStateTCK("for " + config.name, ManagedCloudStateTCK.settings(config)) {
config.validate()

val processes: TckProcesses = TckProcesses.create(config)

override def beforeAll(): Unit = {
processes.frontend.start()
super.beforeAll()
processes.proxy.start()
}

override def afterAll(): Unit = {
try Option(processes).foreach(_.proxy.stop())
finally try Option(processes).foreach(_.frontend.stop())
finally super.afterAll()
}
}
39 changes: 10 additions & 29 deletions tck/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
cloudstate-tck {
#verify is a list of names of combinations to run for the TCK
verify = []
#combinations is a list of config objects with a name, a proxy, and a frontend
combinations = []

tck {
hostname = "127.0.0.1"
hostname = ${?HOST}
port = 8090
}
cloudstate.tck {
hostname = "127.0.0.1"
hostname = ${?TCK_HOST}
port = 8090
port = ${?TCK_PORT}

proxy {
hostname = "127.0.0.1"
hostname = ${?HOST}
hostname = ${?TCK_PROXY_HOST}
port = 9000
directory = ${user.dir}
command = []
stop-command = []
env-vars {
}
# If specified, will start a docker container, with the environment variable USER_FUNCTION_HOST set to the host
# to connect to, USER_FUNCTION_PORT set to the port to connect to, and HTTP_PORT set to the port above.
docker-image = ""
port = ${?TCK_PROXY_PORT}
}

frontend {
hostname = "127.0.0.1"
hostname = ${?HOST}
hostname = ${?TCK_FRONTEND_HOST}
port = 8080
directory = ${user.dir}
command = []
stop-command = []
env-vars {
}
# If specified, will start a docker container, with the environment variable PORT set to the port above.
docker-image = ""
port = ${?TCK_FRONTEND_PORT}
}
}
}
Loading

0 comments on commit 9b344d2

Please sign in to comment.