You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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:
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?
The text was updated successfully, but these errors were encountered: