Skip to content

Commit

Permalink
Added workaround for running tests locally
Browse files Browse the repository at this point in the history
  • Loading branch information
vgarvardt committed May 13, 2021
1 parent fbc39dd commit 1429524
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions checks/http/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -25,5 +26,8 @@ func getURL(t *testing.T) string {
httpURL, ok := os.LookupEnv(httpURLEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
httpURL = strings.Replace(httpURL, "0.0.0.0:", "127.0.0.1:", 1)

return httpURL
}
4 changes: 4 additions & 0 deletions checks/mongo/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mongo
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -25,5 +26,8 @@ func getDSN(t *testing.T) string {
mongoDSN, ok := os.LookupEnv(mgDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mongoDSN = strings.Replace(mongoDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mongoDSN
}
4 changes: 4 additions & 0 deletions checks/mysql/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"os"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -72,6 +73,9 @@ func getDSN(t *testing.T) string {
mysqlDSN, ok := os.LookupEnv(mysqlDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mysqlDSN = strings.Replace(mysqlDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mysqlDSN
}

Expand Down
4 changes: 4 additions & 0 deletions checks/postgres/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"os"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -69,6 +70,9 @@ func getDSN(t *testing.T) string {
pgDSN, ok := os.LookupEnv(pgDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
pgDSN = strings.Replace(pgDSN, "0.0.0.0:", "127.0.0.1:", 1)

return pgDSN
}

Expand Down
4 changes: 4 additions & 0 deletions checks/rabbitmq/aliveness_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rabbitmq
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -27,5 +28,8 @@ func getURL(t *testing.T) string {
httpURL, ok := os.LookupEnv(httpURLEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
httpURL = strings.Replace(httpURL, "0.0.0.0:", "127.0.0.1:", 1)

return httpURL
}
4 changes: 4 additions & 0 deletions checks/rabbitmq/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rabbitmq
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -37,5 +38,8 @@ func getDSN(t *testing.T) string {
mqDSN, ok := os.LookupEnv(mqDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mqDSN = strings.Replace(mqDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mqDSN
}
4 changes: 4 additions & 0 deletions checks/redis/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package redis
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -25,5 +26,8 @@ func getDSN(t *testing.T) string {
redisDSN, ok := os.LookupEnv(rdDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
redisDSN = strings.Replace(redisDSN, "0.0.0.0:", "127.0.0.1:", 1)

return redisDSN
}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,42 @@ services:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5

rabbit:
image: rabbitmq:3.6-management-alpine
ports:
- "5672"
- "15672"
healthcheck:
test: [ "CMD", "rabbitmqctl", "status" ]
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:3.2-alpine
ports:
- "6379"
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 5

mongo:
image: mongo:3
ports:
- "27017"
healthcheck:
test: "mongo localhost:27017/test --quiet --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'"
interval: 10s
timeout: 5s
retries: 5

mysql:
image: mysql:5.7
Expand All @@ -44,6 +64,11 @@ services:
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
interval: 10s
timeout: 5s
retries: 5

memcached:
image: memcached:1.6.9-alpine
Expand Down

0 comments on commit 1429524

Please sign in to comment.