Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Docker Compose with V2 Not Found in Path Error #278

Open
joesan opened this issue Mar 26, 2024 · 1 comment
Open

Local Docker Compose with V2 Not Found in Path Error #278

joesan opened this issue Mar 26, 2024 · 1 comment

Comments

@joesan
Copy link

joesan commented Mar 26, 2024

I'm having a Scala project where in the test folder, I have the resources folder and in that folder I have the docker-compose-mqtt.yaml file that is supposed to start a mqtt broker as a docker container. I have a test class like this below:

class MqttClientFactoryTest extends AsyncFunSuite
    with Matchers with TestContainersForAll {

  implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global

  override type Containers = DockerComposeContainer

  override def startContainers(): DockerComposeContainer = {
    DockerComposeContainer
      .Def(
        composeFiles = new File(
          this.getClass.getClassLoader
            .getResource("docker-compose-mqtt.yaml")
            .getFile
        ),
        exposedServices = Seq(ExposedService(name = "mqtt5", port = 1883))
      )
      .start()
  }

  test("mosquitto container") {
    withContainers { container =>
      val client: Mqtt5AsyncClient = Mqtt5Client
        .builder()
        .identifier(UUID.randomUUID().toString)
        .serverHost("broker.hivemq.com")
        .buildAsync()

      client
        .connect()
        .thenCompose(_ =>
          client
            .publishWith()
            .topic("test/topic")
            .payload("some random message!!!".getBytes)
            .send()
        )
        .asScala
        .map(_ => 1 should be(1))

      client
        .subscribeWith()
        .topicFilter("test/topic")
        .qos(MqttQos.EXACTLY_ONCE)
        .callback(x => println(new String(x.getPayloadAsBytes)))
        .send()
        .asScala
        .map(_ => 1 should be(1))
    }
  }
}

When I ran it, it failed with the message below:

Exception encountered when invoking run on a nested suite - Local Docker Compose not found. Is docker-compose on the PATH?

org.testcontainers.containers.ContainerLaunchException: Local Docker Compose not found. Is docker-compose on the PATH?
	at org.testcontainers.containers.LocalDockerCompose.invoke(LocalDockerCompose.java:61)
	at org.testcontainers.containers.ComposeDelegate.runWithCompose(ComposeDelegate.java:254)
	at org.testcontainers.containers.ComposeDelegate.createServices(ComposeDelegate.java:163)
	at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:137)
	at com.dimafeng.testcontainers.DockerComposeContainer.start(DockerComposeContainer.scala:185)
	at com.dimafeng.testcontainers.ContainerDef.start(ContainerDef.scala:14)
	at com.dimafeng.testcontainers.ContainerDef.start$(ContainerDef.scala:12)
	at com.dimafeng.testcontainers.DockerComposeContainer$Def.start(DockerComposeContainer.scala:88)
	at com.openelectrons.ocpp.gateway.mqtt.MqttClientFactoryTest.startContainers(MqttClientFactoryTest.scala:25)
What is the desired approach here to run this as a unit test?
@joesan
Copy link
Author

joesan commented Mar 26, 2024

It is looking for the older docker-compose as it can be seen from the screenshot below:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant