by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Francis De Brabandere
    @francisdb
    @fsanaulla I in the past used this check: .withReadyChecker(LogLineContains("Listening for signals"))
    Faiaz Sanaulla
    @fsanaulla
    how can i access to container host?
    Faiaz Sanaulla
    @fsanaulla
    Not relevant. Thank you for help.
    Shivam Sharma
    @shivamsharma
    Hi I am using docker-it-scala and I wanted to use typesafe configuration part but is this part commited to maven
    I am not getting some classes (DockerConfig, DockerKitConfig)
    Salar Rahmanian
    @softinio
    hey looking to use this for the first time … is there anyway I can specify a database name for using postgres?
    Salar Rahmanian
    @softinio
    ok think I figured that out
    its get set to the same as the username
    Salar Rahmanian
    @softinio
    only issue I have now is how to not store the container in cache so that postgres empty on each test run
    RoloAdriana
    @RoloAdriana

    Hi all! I'm new using this plugin and I'm having some issues. I 'm trying to use it to configure a mountebank container, which will allow me to test tcp connections. I'm stuck because I have managed to start the container without any problem, but to configure it with I have to pass a configuration file with the option "--configfile path". I have mounted the configuration file using volumes, but then, when I use the withCommand it looks like since there is a space betwen the option and the file is says it does not recognize that comand. As a workaround I tried to use withEntrypath and then copying the full command with options " mb start --configfile path" but then it says that the reference file it doesnt exists, I'm guessing it is because at that time the volume has not been mounted yet.

    Here is my service configuration

    trait DockerMountebankService extends DockerKit {
    
     val DefaultMountbankPort = 2525
     val ImposterPort=3000
    
     val ImpostersPath = getClass.getResource("/imposters_config/").getPath
    
     val volumes = Seq(
       VolumeMapping(container = "/imposters", host = ImpostersPath , rw = true)
     )
    //  val DefaultTcpPort
    
     val mountebankContainer = DockerContainer("expert360/mountebank")
       .withVolumes(volumes)
       .withPorts(DefaultMountbankPort -> Some(2525))
       .withPorts(ImposterPort -> None)
       .withReadyChecker(DockerReadyChecker.LogLineContains("mountebank v1.3.0 (node v0.12.2) now taking orders"))
       .withEntrypoint("mb start--configfile /imposters/imposters.ejs") // it fails saying "no such file or directory"
     //    .withCommand("--configfile /imposters/imposters.ejs")  it fails saying "--configfile /imposters/imposters.ejs" is not recognized as a command
    
     abstract override def dockerContainers = mountebankContainer :: super.dockerContainers
    }

    Any help would be appreciated

    Satendra Tiwari
    @sattiwari
    hi
    i am using docker testkit and i want to create multiple c docker containers and test movement of data across c containers
    but my problem is testkit is failing for anything other than default c* port 9042
    so basically first container is created but the second one fails
    any pointers?
    Alexis Hernandez
    @AlexITC
    hi, I'm having a weird issue, I've copied DockerPostgresService from samples to my project, also, I copied most of PostgresServiceSpec, I'm getting this error from isContainerReady:
    Nov 03, 2017 9:53:02 AM org.postgresql.Driver connect
    SEVERE: Connection error: 
    org.postgresql.util.PSQLException: The connection attempt failed.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)
        at org.postgresql.Driver.makeConnection(Driver.java:450)
        at org.postgresql.Driver.connect(Driver.java:252)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.alexitc.coinalerts.controllers.PostgresReadyChecker.$anonfun$apply$2(UsersControllerSpec.scala:270)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
        at scala.util.Try$.apply(Try.scala:209)
        at com.alexitc.coinalerts.controllers.PostgresReadyChecker.$anonfun$apply$1(UsersControllerSpec.scala:267)
        at com.alexitc.coinalerts.controllers.PostgresReadyChecker.$anonfun$apply$1$adapted(UsersControllerSpec.scala:266)
        at scala.util.Success.$anonfun$map$1(Try.scala:251)
        at scala.util.Success.map(Try.scala:209)
        at scala.concurrent.Future.$anonfun$map$1(Future.scala:287)
        at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
        at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.io.EOFException
        at org.postgresql.core.PGStream.receiveChar(PGStream.java:290)
        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:418)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222)
        ... 20 more
    I've tried the same spec from docker-it-scala project and it just works
    have any of you experienced something similar? any advices?
    Francis De Brabandere
    @francisdb
    enable logging on the container .withLogLineReceiver(LogLineReceiver(withErr = true, s => println(s”PG $s")))
    that should give you an idea what is going on inside the container
    if nothing is wrong there it could be a port mapping issue
    Calvin Brown
    @calvinbrown085
    Hi all, i'm trying to spin up a postgres container, i'm seeing caused by java.util.concurrent.TimeoutException: Futures timed out after [40 seconds]
    It seems like it's just not spinning up the container
    Francis De Brabandere
    @francisdb
    enable logging on the container .withLogLineReceiver(LogLineReceiver(withErr = true, s => println(s”PG $s")))
    that should give you an idea what is going on inside the container
    Paul Cleary
    @pauljamescleary
    Do you by any chance support port mappings to udp?
    Paul Cleary
    @pauljamescleary
    So, going through the code for a bit, doesn't look like here is udp support
    I was able to fork the docker-it-scala repo, and make a bunch of modifications to it to indicate that a port binding is udp
    using the spotify docker client
    It spits back "Bind for 0.0.0.0:5300 failed: port is already allocated"
    Paul Cleary
    @pauljamescleary
    Seems like docker-java client directly supports this
    Unclear what is going wrong with the docker spotify client
    Krunoslav Uzelac
    @Reeebuuk
    hi guys, have a little issue with whisk it seems, I'm trying to run this conf
         image: seegno/bitcoind:latest
         command:
           -printtoconsole
           -regtest=1
           -rest
           -rpcuser=foo
           -rpcpassword=bar
           -rpcallowip=0.0.0.0/0
           -rpcport=8332
           -server=1
           -logips
           -debug=rpc
         ports:
           - 8332:8332

    ``` val BitcoinDaemonPort = 8332

    val bitcoinContainer: DockerContainer = DockerContainer("seegno/bitcoind:latest")
    .withPorts(BitcoinDaemonPort -> Some(BitcoinDaemonPort))
    .withCommand(
    "printtoconsole",
    "regtest=1",
    "rest",
    "rpcuser=foo",
    "rpcpassword=bar",
    "rpcallowip=0.0.0.0/0",
    "rpcport=8332",
    "server=1",
    "logips",
    "debug=rpc"
    )
    .withReadyChecker(DockerReadyChecker.LogLineContains("msghand thread start")) ```

    but it doesn't even bootup the image
    if I comment out the withCommand section it will load the container
    but cannot see any errors in logs or anywhere
    any suggestions? :)
    Krunoslav Uzelac
    @Reeebuuk
    This message was deleted
    Michael Ahlers
    @michaelahlers
    Is it possible to discover which (random) ports Docker has bound to the localhost, or is it required to specify them using withPorts? (I'd rather not do the latter since whatever I come up will be less robust.)
    Michael Ahlers
    @michaelahlers
    Answered my own question: using DockerKit.getContainerState.
    Jonas SPRENGER
    @JonasSprenger
    Hi @michaelahlers , I don't understand, DockerKit is a trait I don't find a companion object! Because I'm also interested to get the hostport chosen randomly.
    Actually get it with
    val container: DockerContainer = ???
    val ports: Future[Map[Int, Int]] = container.getPorts()
    Cameron Cheek
    @cam_cheek_twitter
    Hi. Trying to get a simple example up and running with a Postgres container. I've copied the DockerPostgresService from the examples and am doing the following to see if the containers spins up as expected. Just times out. I've tried the LogLineReceiver and it doesn't show anything either. Am I missing something?
    class BaseIntegrationTest extends FunSpec with Matchers with DockerPostgresService {
    
      override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(
        DefaultDockerClient.fromEnv().build()
      )
    
      describe("Test") {
        it("a") {
          val a = Await.result(isContainerReady(postgresContainer), Duration(60, TimeUnit.SECONDS))
          assert(a)
        }
      }
    }
    Alexis Hernandez
    @AlexITC
    Alexis Hernandez
    @AlexITC
    have any of you used docker-it-scala successfully on windows?
    Michal Szturo
    @michal-szturo

    I encountered a similar problem while connecting to container using modified example DockerPostgresService. I receive connection error, but after that everything is set up and all tests pass. Here's the snippet from logs:

    PG [f387ecb6533263922aa7619d8c719a044df627a360ba18bfb0cfbac815f67a5f] ok
    running bootstrap script ... 
    Jul 05, 2019 11:16:00 AM org.postgresql.Driver connect
    SEVERE: Connection error: 
    org.postgresql.util.PSQLException: The connection attempt failed.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)
        at org.postgresql.Driver.makeConnection(Driver.java:450)
        at org.postgresql.Driver.connect(Driver.java:252)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at docker.services.PostgresReadyChecker.$anonfun$apply$2(DockerPostgresService.scala:52)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.scala:17)
        at scala.util.Try$.apply(Try.scala:212)
        at docker.services.PostgresReadyChecker.$anonfun$apply$1(DockerPostgresService.scala:48)
        at docker.services.PostgresReadyChecker.$anonfun$apply$1$adapted(DockerPostgresService.scala:47)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:430)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.io.EOFException
        at org.postgresql.core.PGStream.receiveChar(PGStream.java:290)
        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:418)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222)
        ... 15 more
    
    PG [f387ecb6533263922aa7619d8c719a044df627a360ba18bfb0cfbac815f67a5f] ok

    And my DockerPostgresService implementation:

    package docker.services
    
    import java.sql.DriverManager
    
    import com.whisk.docker._
    import com.whisk.docker.impl.spotify.DockerKitSpotify
    import com.typesafe.config.{Config, ConfigFactory}
    
    import scala.concurrent.{ExecutionContext, Future}
    import scala.util.Try
    
    trait DockerPostgresService extends DockerKitSpotify {
    
      import scala.concurrent.duration._
    
      lazy val config: Config = ConfigFactory.load()
      lazy val dockerConfig: Config = config.getConfig("docker.postgres")
    
      val ImageName: String = dockerConfig.getString("image-name")
      val PostgresAdvertisedPort: Int = dockerConfig.getInt("port-maps.default-postgres-port.internal")
      val PostgresExposedPort: Int = dockerConfig.getInt("port-maps.default-postgres-port.external")
    
      val PostgresUser = "postgres"
      val PostgresPassword = "postgres"
    
      val postgresContainer: DockerContainer = DockerContainer(ImageName)
        .withPorts((PostgresAdvertisedPort, Some(PostgresExposedPort)))
        .withEnv(s"POSTGRES_USER=$PostgresUser", s"POSTGRES_PASSWORD=$PostgresPassword")
        .withReadyChecker(
          new PostgresReadyChecker(PostgresUser, PostgresPassword, Some(PostgresExposedPort))
            .looped(15, 1.second)
        )
        .withLogLineReceiver(LogLineReceiver(withErr = true, s => println(s"PG $s")))
    
      override def dockerContainers: List[DockerContainer] =
        postgresContainer :: super.dockerContainers
    }
    
    class PostgresReadyChecker(user: String, password: String, port: Option[Int] = None)
      extends DockerReadyChecker {
    
      override def apply(container: DockerContainerState)(
        implicit docker: DockerCommandExecutor,
        ec: ExecutionContext): Future[Boolean] =
        container
          .getPorts()
          .map(ports =>
            Try {
              Class.forName("org.postgresql.Driver")
              val url = s"jdbc:postgresql://${docker.host}:${port.getOrElse(ports.values.head)}/postgres"
              Option(
                DriverManager.getConnection(url, user, password)
              ).map(_.close).isDefined
            }.getOrElse(false))
    }
    Alexis Hernandez
    @AlexITC
    that logged error depends on the postgres driver, in some versions it is logged and there is no way to disable it, in latest versions, I think it is disabled, the reason is that dokcker-it-scala tries to connect to the instance for checking whether it is ready
    Alexis Hernandez
    @AlexITC
    Anyone has run tests successfully on circleci? we are having issues with it while docker-it-scala launches the containers, on travisci, it just works
    swathirajashekar
    @swathirajashekar

    @here I am trying to using docker-it-scala with elastic search.
    My build.sbt dependencies looks like below

    "com.whisk" %% "docker-testkit-scalatest" % "0.9.8" % Test,
      "com.whisk" %% "docker-testkit-impl-spotify" % "0.9.8" % Test,
      "com.github.docker-java" % "docker-java" % "3.0.13" % Test

    And My ElasticSearchTestSpec Looks like below

    import org.log4s.getLogger
    import com.whisk.docker.impl.spotify.DockerKitSpotify
    import com.whisk.docker.scalatest.DockerTestKit
    import com.whisk.docker.{DockerContainer, DockerKit, DockerPortMapping, DockerReadyChecker}
    import org.scalatest.{BeforeAndAfterAll, TestSuite}
    import org.scalatest.concurrent.ScalaFutures
    import org.scalatest.time.{Second, Seconds, Span}
    
    import scala.concurrent.duration._
    
    trait DockerElasticsearchService extends DockerKit {
      val DefaultElasticsearchHttpPort = 9200
      val DefaultElasticsearchClientPort = 9300
    
      val elasticsearchContainer: DockerContainer = DockerContainer("docker.elastic.co/elasticsearch/elasticsearch:6.0.1")
        .withPortMapping(
          DefaultElasticsearchHttpPort -> DockerPortMapping(Some(DefaultElasticsearchHttpPort)),
          DefaultElasticsearchClientPort -> DockerPortMapping(Some(DefaultElasticsearchClientPort)))
        .withEnv("discovery.type=single-node")
        .withReadyChecker(
          DockerReadyChecker
            .HttpResponseCode(DefaultElasticsearchHttpPort, "/", Some("0.0.0.0"))
            .within(100.millis)
            .looped(20, 1250.millis))
    
      abstract override def dockerContainers: List[DockerContainer] =
        elasticsearchContainer :: super.dockerContainers
    }
    
    trait ElasticSearchTestSpec extends TestSuite with BeforeAndAfterAll with DockerElasticsearchService with ScalaFutures with DockerTestKit with DockerKitDockerJava {
    
      val log = getLogger
      implicit val pc = PatienceConfig(Span(20, Seconds), Span(1, Second))
    
      override def beforeAll(): Unit = {
        super.beforeAll()
        val ready = isContainerReady(elasticsearchContainer).futureValue
        ready match {
          case true => log.info("Elastic Search Container is ready")
          case false => log.info("Elastic Search Container is not ready")
        }
      }
    
      lazy val es_url = s"0.0.0.0/${DefaultElasticsearchHttpPort}"
    }

    I am not able to resolve DockerKitDockerJava Should I add any pther library to build.abt? without that, I am getting error java.util.concurrent.TimeoutException: Futures timed out after [10 seconds]