From 304d0beef90d3445d2c857ad494c4372ad61b32b Mon Sep 17 00:00:00 2001 From: Chetan Mehrotra Date: Tue, 26 Jun 2018 10:11:27 +0530 Subject: [PATCH] Use DockerCommand from ActionContainer --- .../actionContainers/ActionContainer.scala | 2 +- .../whisk/core/database/s3/S3Minio.scala | 26 +++---------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/tests/src/test/scala/actionContainers/ActionContainer.scala b/tests/src/test/scala/actionContainers/ActionContainer.scala index b9398cda8a9..47fc43e628c 100644 --- a/tests/src/test/scala/actionContainers/ActionContainer.scala +++ b/tests/src/test/scala/actionContainers/ActionContainer.scala @@ -90,7 +90,7 @@ object ActionContainer { }.get // This fails if the docker binary couldn't be located. } - private lazy val dockerCmd: String = { + lazy val dockerCmd: String = { /* * The docker host is set to a provided property 'docker.host' if it's * available; otherwise we check with WhiskProperties to see whether we are diff --git a/tests/src/test/scala/whisk/core/database/s3/S3Minio.scala b/tests/src/test/scala/whisk/core/database/s3/S3Minio.scala index b5391ef4c34..0c59e68a8c5 100644 --- a/tests/src/test/scala/whisk/core/database/s3/S3Minio.scala +++ b/tests/src/test/scala/whisk/core/database/s3/S3Minio.scala @@ -17,16 +17,16 @@ package whisk.core.database.s3 -import java.io.File import java.net.ServerSocket +import actionContainers.ActionContainer import akka.actor.ActorSystem import akka.stream.ActorMaterializer import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials} import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration import com.amazonaws.services.s3.AmazonS3ClientBuilder import com.typesafe.config.ConfigFactory -import common.{SimpleExec, StreamLogging, WhiskProperties} +import common.{SimpleExec, StreamLogging} import org.scalatest.{BeforeAndAfterAll, FlatSpec} import whisk.common.{Logging, TransactionId} import whisk.core.database.{AttachmentStore, DocumentSerializer} @@ -96,33 +96,13 @@ trait S3Minio extends FlatSpec with BeforeAndAfterAll with StreamLogging { private def dockerExec(cmd: String): String = { implicit val tid: TransactionId = TransactionId.testing - val command = s"$dockerCmd $cmd" + val command = s"${ActionContainer.dockerCmd} $cmd" val cmdSeq = command.split(" ").map(_.trim).filter(_.nonEmpty) val (out, err, code) = SimpleExec.syncRunCmd(cmdSeq) assert(code == 0, s"Error occurred for command '$command'. Exit code: $code, Error: $err") out } - //Taken from ActionContainer - private lazy val dockerBin: String = { - List("/usr/bin/docker", "/usr/local/bin/docker") - .find { bin => - new File(bin).isFile - } - .getOrElse(???) // This fails if the docker binary couldn't be located. - } - - private lazy val dockerCmd: String = { - val version = WhiskProperties.getProperty("whisk.version.name") - // Check if we are running on docker-machine env. - val hostStr = if (version.toLowerCase().contains("mac")) { - s" --host tcp://${WhiskProperties.getMainDockerEndpoint} " - } else { - "" - } - s"$dockerBin $hostStr" - } - private def freePort(): Int = { val socket = new ServerSocket(0) try socket.getLocalPort