Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
NOISSUE - Revert Mosquitto broker version in MQTT tests (#2063)
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <[email protected]>
  • Loading branch information
dborovcanin authored Jan 24, 2024
1 parent 79ef28a commit 24d3804
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
11 changes: 8 additions & 3 deletions pkg/messaging/mqtt/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
mqttpubsub "github.com/absmach/magistrala/pkg/messaging/mqtt"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
)

var (
Expand All @@ -30,8 +31,6 @@ const (
username = "magistrala-mqtt"
qos = 2
port = "1883/tcp"
broker = "eclipse-mosquitto"
brokerVersion = "2.0.18"
brokerTimeout = 30 * time.Second
poolMaxWait = 120 * time.Second
)
Expand All @@ -42,7 +41,13 @@ func TestMain(m *testing.M) {
log.Fatalf("Could not connect to docker: %s", err)
}

container, err := pool.Run(broker, brokerVersion, nil)
container, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "eclipse-mosquitto",
Tag: "1.6.15",
}, func(config *docker.HostConfig) {
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
if err != nil {
log.Fatalf("Could not start container: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion readers/mongodb/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestMain(m *testing.M) {

container, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "mongo",
Tag: "6.0.13",
Tag: "7.0.5",
Env: []string{
"MONGO_INITDB_DATABASE=test",
},
Expand Down
9 changes: 8 additions & 1 deletion things/cache/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/go-redis/redis/v8"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
)

var (
Expand All @@ -25,7 +26,13 @@ func TestMain(m *testing.M) {
log.Fatalf("Could not connect to docker: %s", err)
}

container, err := pool.Run("redis", "7.2.0-alpine", nil)
container, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "redis",
Tag: "7.2.4-alpine",
}, func(config *docker.HostConfig) {
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
if err != nil {
log.Fatalf("Could not start container: %s", err)
}
Expand Down
9 changes: 8 additions & 1 deletion twins/events/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/go-redis/redis/v8"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
)

var (
Expand All @@ -25,7 +26,13 @@ func TestMain(m *testing.M) {
log.Fatalf("Could not connect to docker: %s", err)
}

container, err := pool.Run("redis", "7.2.0-alpine", nil)
container, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "redis",
Tag: "7.2.4-alpine",
}, func(config *docker.HostConfig) {
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
if err != nil {
log.Fatalf("Could not start container: %s", err)
}
Expand Down
17 changes: 11 additions & 6 deletions twins/mongodb/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ package mongodb_test
import (
"context"
"fmt"
"log"
"os"
"testing"

"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
Expand All @@ -22,13 +24,16 @@ func TestMain(m *testing.M) {
testLog.Error(fmt.Sprintf("Could not connect to docker: %s", err))
}

cfg := []string{
"MONGO_INITDB_DATABASE=test",
}

container, err := pool.Run("mongo", "7.0.5", cfg)
container, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "mongo",
Tag: "7.0.5",
Env: []string{"MONGO_INITDB_DATABASE=test"},
}, func(config *docker.HostConfig) {
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
if err != nil {
testLog.Error(fmt.Sprintf("Could not start container: %s", err))
log.Fatalf("Could not start container: %s", err)
}

port = container.GetPort("27017/tcp")
Expand Down

0 comments on commit 24d3804

Please sign in to comment.