cbickel commented on a change in pull request #2810: Add couchdb clustering
URL:
https://github.com/apache/incubator-openwhisk/pull/2810#discussion_r153528486
##########
File path: tests/src/test/scala/ha/ShootComponentsTests.scala
##########
@@ -63,18 +60,61 @@ class ShootComponentsTests extends FlatSpec with Matchers
with WskTestHelpers wi
val controller0DockerHost = WhiskProperties.getBaseControllerHost() + ":" +
WhiskProperties.getProperty(
WhiskConfig.dockerPort)
- def restartComponent(host: String, component: String) = {
+ val couchDB0DockerHost = WhiskProperties.getBaseDBHost() + ":" +
WhiskProperties.getProperty(
+ WhiskConfig.dockerPort)
+
+ val dbProtocol = WhiskProperties.getProperty(WhiskConfig.dbProtocol)
+ val dbHostsList = WhiskProperties.getProperty(WhiskConfig.dbHostsList)
+ val dbPort = WhiskProperties.getProperty(WhiskConfig.dbPort)
+ val dbUsername = WhiskProperties.getProperty(WhiskConfig.dbUsername)
+ val dbPassword = WhiskProperties.getProperty(WhiskConfig.dbPassword)
+ val dbPrefix = WhiskProperties.getProperty(WhiskConfig.dbPrefix)
+ val dbWhiskAuth = WhiskProperties.getProperty(WhiskConfig.dbAuths)
+
+ private def getDockerCommand(host: String, component: String, cmd: String) =
{
def file(path: String) = Try(new
File(path)).filter(_.exists).map(_.getAbsolutePath).toOption
+
val docker = (file("/usr/bin/docker") orElse
file("/usr/local/bin/docker")).getOrElse("docker")
- val cmd = Seq(docker, "--host", host, "restart", component)
+ Seq(docker, "--host", host, cmd, component)
+ }
+
+ def restartComponent(host: String, component: String) = {
+ val cmd: Seq[String] = getDockerCommand(host, component, "restart")
+ println(s"Running command: ${cmd.mkString(" ")}")
+
+ TestUtils.runCmd(0, new File("."), cmd: _*)
+ }
+
+ def stopComponent(host: String, component: String) = {
+ val cmd: Seq[String] = getDockerCommand(host, component, "stop")
+ println(s"Running command: ${cmd.mkString(" ")}")
+
+ TestUtils.runCmd(0, new File("."), cmd: _*)
+ }
+
+
+ def startComponent(host: String, component: String) = {
+ val cmd: Seq[String] = getDockerCommand(host, component, "start")
println(s"Running command: ${cmd.mkString(" ")}")
TestUtils.runCmd(0, new File("."), cmd: _*)
}
def ping(host: String, port: Int) = {
- val response = Try { Http().singleRequest(HttpRequest(uri =
s"http://$host:$port/ping")).futureValue }.toOption
+ val response = Try {
+ Http().singleRequest(HttpRequest(uri =
s"http://$host:$port/ping")).futureValue
+ }.toOption
+
+ response.map { res =>
+ (res.status, Unmarshal(res).to[String].futureValue)
+ }
+ }
+
+ def pingDB(host: String, port: Int) = {
Review comment:
what do you think about using one ping method and passing the `path` as an
argument.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services