chore(deps): Bump github.com/testcontainers/testcontainers-go from 0.26.0 to 0.27.0 (#14608)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh Powers <powersj@fastmail.com>
This commit is contained in:
dependabot[bot] 2024-01-23 17:57:15 +01:00 committed by GitHub
parent 4a05bef582
commit 29f7d04172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 62 additions and 65 deletions

2
go.mod
View File

@ -177,7 +177,7 @@ require (
github.com/srebhan/protobufquery v0.0.0-20230803132024-ae4c0d878e55 github.com/srebhan/protobufquery v0.0.0-20230803132024-ae4c0d878e55
github.com/stretchr/testify v1.8.4 github.com/stretchr/testify v1.8.4
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
github.com/testcontainers/testcontainers-go v0.26.0 github.com/testcontainers/testcontainers-go v0.27.0
github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09 github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09
github.com/thomasklein94/packer-plugin-libvirt v0.5.0 github.com/thomasklein94/packer-plugin-libvirt v0.5.0
github.com/tidwall/gjson v1.17.0 github.com/tidwall/gjson v1.17.0

4
go.sum
View File

@ -2154,8 +2154,8 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o=
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw=
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0=
github.com/testcontainers/testcontainers-go v0.26.0 h1:uqcYdoOHBy1ca7gKODfBd9uTHVK3a7UL848z09MVZ0c= github.com/testcontainers/testcontainers-go v0.27.0 h1:IeIrJN4twonTDuMuBNQdKZ+K97yd7VrmNGu+lDpYcDk=
github.com/testcontainers/testcontainers-go v0.26.0/go.mod h1:ICriE9bLX5CLxL9OFQ2N+2N+f+803LNJ1utJb1+Inx0= github.com/testcontainers/testcontainers-go v0.27.0/go.mod h1:+HgYZcd17GshBUZv9b+jKFJ198heWPQq3KQIp2+N+7U=
github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09 h1:jqohCgCKphLrxHl6crzKJbmlmo8GYUNpTiw/Ib+AFLo= github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09 h1:jqohCgCKphLrxHl6crzKJbmlmo8GYUNpTiw/Ib+AFLo=
github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09/go.mod h1:MBqGe6sHltLHRmjk1K1axtIboCjjATh3+oZObcWYFMg= github.com/testcontainers/testcontainers-go/modules/kafka v0.26.1-0.20231116140448-68d5f8983d09/go.mod h1:MBqGe6sHltLHRmjk1K1axtIboCjjATh3+oZObcWYFMg=
github.com/thomasklein94/packer-plugin-libvirt v0.5.0 h1:aj2HLHZZM/ClGLIwVp9rrgh+2TOU/w4EiaZHAwCpOgs= github.com/thomasklein94/packer-plugin-libvirt v0.5.0 h1:aj2HLHZZM/ClGLIwVp9rrgh+2TOU/w4EiaZHAwCpOgs=

View File

@ -192,7 +192,7 @@ func TestDovecotContainerIntegration(t *testing.T) {
container := testutil.Container{ container := testutil.Container{
Image: "dovecot/dovecot", Image: "dovecot/dovecot",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
BindMounts: map[string]string{ Files: map[string]string{
"/etc/dovecot/dovecot.conf": testdata, "/etc/dovecot/dovecot.conf": testdata,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(

View File

@ -293,7 +293,7 @@ func TestOpenLDAPStartTLSIntegration(t *testing.T) {
"LDAP_TLS_CERT_FILE": "server.crt", "LDAP_TLS_CERT_FILE": "server.crt",
"LDAP_TLS_KEY_FILE": "server.key", "LDAP_TLS_KEY_FILE": "server.key",
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/server.pem": pkiPaths.ServerPem, "/server.pem": pkiPaths.ServerPem,
"/server.crt": pkiPaths.ServerCert, "/server.crt": pkiPaths.ServerCert,
"/server.key": pkiPaths.ServerKey, "/server.key": pkiPaths.ServerKey,
@ -401,7 +401,7 @@ func TestOpenLDAPLDAPSIntegration(t *testing.T) {
"LDAP_TLS_CERT_FILE": "server.crt", "LDAP_TLS_CERT_FILE": "server.crt",
"LDAP_TLS_KEY_FILE": "server.key", "LDAP_TLS_KEY_FILE": "server.key",
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/server.pem": pkiPaths.ServerPem, "/server.pem": pkiPaths.ServerPem,
"/server.crt": pkiPaths.ServerCert, "/server.crt": pkiPaths.ServerCert,
"/server.key": pkiPaths.ServerKey, "/server.key": pkiPaths.ServerKey,

View File

@ -120,7 +120,7 @@ func TestOpenldapStartTLSIntegration(t *testing.T) {
"LDAP_TLS_CERT_FILE": "server.crt", "LDAP_TLS_CERT_FILE": "server.crt",
"LDAP_TLS_KEY_FILE": "server.key", "LDAP_TLS_KEY_FILE": "server.key",
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/server.pem": tlsPem, "/server.pem": tlsPem,
"/server.crt": tlsCert, "/server.crt": tlsCert,
"/server.key": tlsKey, "/server.key": tlsKey,
@ -181,7 +181,7 @@ func TestOpenldapLDAPSIntegration(t *testing.T) {
"LDAP_TLS_CERT_FILE": "server.crt", "LDAP_TLS_CERT_FILE": "server.crt",
"LDAP_TLS_KEY_FILE": "server.key", "LDAP_TLS_KEY_FILE": "server.key",
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/server.pem": tlsPem, "/server.pem": tlsPem,
"/server.crt": tlsCert, "/server.crt": tlsCert,
"/server.key": tlsKey, "/server.key": tlsKey,
@ -237,7 +237,7 @@ func TestOpenldapInvalidSSLIntegration(t *testing.T) {
"LDAP_TLS_CERT_FILE": "server.crt", "LDAP_TLS_CERT_FILE": "server.crt",
"LDAP_TLS_KEY_FILE": "server.key", "LDAP_TLS_KEY_FILE": "server.key",
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/server.pem": tlsPem, "/server.pem": tlsPem,
"/server.crt": tlsCert, "/server.crt": tlsCert,
"/server.key": tlsKey, "/server.key": tlsKey,

View File

@ -98,7 +98,7 @@ func TestRadiusIntegration(t *testing.T) {
container := testutil.Container{ container := testutil.Container{
Image: "freeradius/freeradius-server", Image: "freeradius/freeradius-server",
ExposedPorts: []string{"1812/udp"}, ExposedPorts: []string{"1812/udp"},
BindMounts: map[string]string{ Files: map[string]string{
"/etc/raddb/clients.conf": testdata, "/etc/raddb/clients.conf": testdata,
"/etc/raddb/mods-config/files/authorize": testdataa, "/etc/raddb/mods-config/files/authorize": testdataa,
"/etc/raddb/radiusd.conf": testdataaa, "/etc/raddb/radiusd.conf": testdataaa,

View File

@ -11,7 +11,7 @@ import (
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/network"
"github.com/testcontainers/testcontainers-go/wait" "github.com/testcontainers/testcontainers-go/wait"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
@ -19,7 +19,6 @@ import (
) )
const masterName = "mymaster" const masterName = "mymaster"
const networkName = "telegraf-test-redis-sentinel"
const sentinelServicePort = "26379" const sentinelServicePort = "26379"
func TestRedisSentinelConnectIntegration(t *testing.T) { func TestRedisSentinelConnectIntegration(t *testing.T) {
@ -28,24 +27,18 @@ func TestRedisSentinelConnectIntegration(t *testing.T) {
} }
ctx := context.Background() ctx := context.Background()
net, err := testcontainers.GenericNetwork(ctx, testcontainers.GenericNetworkRequest{ net, err := network.New(ctx, network.WithCheckDuplicate())
NetworkRequest: testcontainers.NetworkRequest{
Name: networkName,
Attachable: true,
CheckDuplicate: true,
},
})
require.NoError(t, err) require.NoError(t, err)
defer func() { defer func() {
require.NoError(t, net.Remove(ctx), "terminating network failed") require.NoError(t, net.Remove(ctx), "terminating network failed")
}() }()
redis := createRedisContainer() redis := createRedisContainer(net.Name)
err = redis.Start() err = redis.Start()
require.NoError(t, err, "failed to start container") require.NoError(t, err, "failed to start container")
defer redis.Terminate() defer redis.Terminate()
firstSentinel := createSentinelContainer(redis.Name, wait.ForAll( firstSentinel := createSentinelContainer(redis.Name, net.Name, wait.ForAll(
wait.ForLog("+monitor master"), wait.ForLog("+monitor master"),
wait.ForListeningPort(nat.Port(sentinelServicePort)), wait.ForListeningPort(nat.Port(sentinelServicePort)),
)) ))
@ -53,7 +46,7 @@ func TestRedisSentinelConnectIntegration(t *testing.T) {
require.NoError(t, err, "failed to start container") require.NoError(t, err, "failed to start container")
defer firstSentinel.Terminate() defer firstSentinel.Terminate()
secondSentinel := createSentinelContainer(redis.Name, wait.ForAll( secondSentinel := createSentinelContainer(redis.Name, net.Name, wait.ForAll(
wait.ForLog("+sentinel sentinel"), wait.ForLog("+sentinel sentinel"),
wait.ForListeningPort(nat.Port(sentinelServicePort)), wait.ForListeningPort(nat.Port(sentinelServicePort)),
)) ))
@ -356,7 +349,7 @@ func TestRedisSentinelInfoAll(t *testing.T) {
testutil.RequireMetricsEqual(t, expectedMetrics, actualMetrics) testutil.RequireMetricsEqual(t, expectedMetrics, actualMetrics)
} }
func createRedisContainer() testutil.Container { func createRedisContainer(networkName string) testutil.Container {
return testutil.Container{ return testutil.Container{
Image: "redis:7.0-alpine", Image: "redis:7.0-alpine",
Name: "telegraf-test-redis-sentinel-redis", Name: "telegraf-test-redis-sentinel-redis",
@ -369,7 +362,7 @@ func createRedisContainer() testutil.Container {
} }
} }
func createSentinelContainer(redisAddress string, waitingFor wait.Strategy) testutil.Container { func createSentinelContainer(redisAddress string, networkName string, waitingFor wait.Strategy) testutil.Container {
return testutil.Container{ return testutil.Container{
Image: "bitnami/redis-sentinel:7.0", Image: "bitnami/redis-sentinel:7.0",
ExposedPorts: []string{sentinelServicePort}, ExposedPorts: []string{sentinelServicePort},

View File

@ -40,7 +40,7 @@ func TestMariaDBIntegration(t *testing.T) {
database := "foo" database := "foo"
// Determine the test-data mountpoint // Determine the test-data mountpoint
testdata, err := filepath.Abs("testdata/mariadb") testdata, err := filepath.Abs("testdata/mariadb/expected.sql")
require.NoError(t, err, "determining absolute path of test-data failed") require.NoError(t, err, "determining absolute path of test-data failed")
container := testutil.Container{ container := testutil.Container{
@ -50,8 +50,8 @@ func TestMariaDBIntegration(t *testing.T) {
"MYSQL_ROOT_PASSWORD": passwd, "MYSQL_ROOT_PASSWORD": passwd,
"MYSQL_DATABASE": database, "MYSQL_DATABASE": database,
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": testdata, "/docker-entrypoint-initdb.d/expected.sql": testdata,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
wait.ForLog("mariadbd: ready for connections.").WithOccurrence(2), wait.ForLog("mariadbd: ready for connections.").WithOccurrence(2),
@ -139,7 +139,7 @@ func TestPostgreSQLIntegration(t *testing.T) {
database := "foo" database := "foo"
// Determine the test-data mountpoint // Determine the test-data mountpoint
testdata, err := filepath.Abs("testdata/postgres") testdata, err := filepath.Abs("testdata/postgres/expected.sql")
require.NoError(t, err, "determining absolute path of test-data failed") require.NoError(t, err, "determining absolute path of test-data failed")
container := testutil.Container{ container := testutil.Container{
@ -149,8 +149,8 @@ func TestPostgreSQLIntegration(t *testing.T) {
"POSTGRES_PASSWORD": passwd, "POSTGRES_PASSWORD": passwd,
"POSTGRES_DB": database, "POSTGRES_DB": database,
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": testdata, "/docker-entrypoint-initdb.d/expected.sql": testdata,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
wait.ForLog("database system is ready to accept connections").WithOccurrence(2), wait.ForLog("database system is ready to accept connections").WithOccurrence(2),
@ -237,14 +237,14 @@ func TestClickHouseIntegration(t *testing.T) {
user := "default" user := "default"
// Determine the test-data mountpoint // Determine the test-data mountpoint
testdata, err := filepath.Abs("testdata/clickhouse") testdata, err := filepath.Abs("testdata/clickhouse/expected.sql")
require.NoError(t, err, "determining absolute path of test-data failed") require.NoError(t, err, "determining absolute path of test-data failed")
container := testutil.Container{ container := testutil.Container{
Image: "yandex/clickhouse-server", Image: "yandex/clickhouse-server",
ExposedPorts: []string{port, "8123"}, ExposedPorts: []string{port, "8123"},
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": testdata, "/docker-entrypoint-initdb.d/expected.sql": testdata,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
wait.NewHTTPStrategy("/").WithPort(nat.Port("8123")), wait.NewHTTPStrategy("/").WithPort(nat.Port("8123")),

View File

@ -140,7 +140,7 @@ func TestIntegration_BasicGathering(t *testing.T) {
ctr := testutil.Container{ ctr := testutil.Container{
Image: "niasar/supervisor:stretch-3.3", Image: "niasar/supervisor:stretch-3.3",
ExposedPorts: []string{supervisorPort}, ExposedPorts: []string{supervisorPort},
BindMounts: map[string]string{ Files: map[string]string{
"/etc/supervisor/supervisord.conf": supervisorConfig, "/etc/supervisor/supervisord.conf": supervisorConfig,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(

View File

@ -56,15 +56,15 @@ func TestConnectAndWriteIntegrationSCRAMAuth(t *testing.T) {
t.Skip("Skipping integration test in short mode") t.Skip("Skipping integration test in short mode")
} }
initdb, err := filepath.Abs("testdata/auth_scram") initdb, err := filepath.Abs("testdata/auth_scram/setup.js")
require.NoError(t, err) require.NoError(t, err)
servicePort := "27017" servicePort := "27017"
container := testutil.Container{ container := testutil.Container{
Image: "mongo", Image: "mongo",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": initdb, "/docker-entrypoint-initdb.d/setup.js": initdb,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
wait.NewHTTPStrategy("/").WithPort(nat.Port(servicePort)), wait.NewHTTPStrategy("/").WithPort(nat.Port(servicePort)),
@ -146,7 +146,7 @@ func TestConnectAndWriteIntegrationX509Auth(t *testing.T) {
pki := testutil.NewPKI("../../../testutil/pki") pki := testutil.NewPKI("../../../testutil/pki")
// bind mount files // bind mount files
initdb, err := filepath.Abs("testdata/auth_x509") initdb, err := filepath.Abs("testdata/auth_x509/setup.js")
require.NoError(t, err) require.NoError(t, err)
cacert, err := filepath.Abs(pki.CACertPath()) cacert, err := filepath.Abs(pki.CACertPath())
require.NoError(t, err) require.NoError(t, err)
@ -157,10 +157,10 @@ func TestConnectAndWriteIntegrationX509Auth(t *testing.T) {
container := testutil.Container{ container := testutil.Container{
Image: "mongo", Image: "mongo",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": initdb, "/docker-entrypoint-initdb.d/setup.js": initdb,
"/cacert.pem": cacert, "/cacert.pem": cacert,
"/server.pem": serverpem, "/server.pem": serverpem,
}, },
Entrypoint: []string{ Entrypoint: []string{
"docker-entrypoint.sh", "docker-entrypoint.sh",

View File

@ -30,7 +30,7 @@ func launchTestContainer(t *testing.T) *testutil.Container {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }
@ -146,7 +146,7 @@ func TestIntegrationMQTTv3(t *testing.T) {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }
@ -298,7 +298,7 @@ func TestIntegrationMQTTLayoutNonBatch(t *testing.T) {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }
@ -385,7 +385,7 @@ func TestIntegrationMQTTLayoutBatch(t *testing.T) {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }
@ -475,7 +475,7 @@ func TestIntegrationMQTTLayoutField(t *testing.T) {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }
@ -590,7 +590,7 @@ func TestIntegrationMQTTLayoutHomieV4(t *testing.T) {
Image: "eclipse-mosquitto:2", Image: "eclipse-mosquitto:2",
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(servicePort), WaitingFor: wait.ForListeningPort(servicePort),
BindMounts: map[string]string{ Files: map[string]string{
"/mosquitto/config/mosquitto.conf": conf, "/mosquitto/config/mosquitto.conf": conf,
}, },
} }

View File

@ -159,7 +159,7 @@ func TestMysqlIntegration(t *testing.T) {
t.Skip("Skipping integration test in short mode") t.Skip("Skipping integration test in short mode")
} }
initdb, err := filepath.Abs("testdata/mariadb/initdb") initdb, err := filepath.Abs("testdata/mariadb/initdb/script.sql")
require.NoError(t, err) require.NoError(t, err)
// initdb/script.sql creates this database // initdb/script.sql creates this database
@ -178,9 +178,9 @@ func TestMysqlIntegration(t *testing.T) {
Env: map[string]string{ Env: map[string]string{
"MARIADB_ROOT_PASSWORD": password, "MARIADB_ROOT_PASSWORD": password,
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": initdb, "/docker-entrypoint-initdb.d/script.sql": initdb,
"/out": outDir, "/out": outDir,
}, },
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
@ -244,7 +244,7 @@ func TestPostgresIntegration(t *testing.T) {
t.Skip("Skipping integration test in short mode") t.Skip("Skipping integration test in short mode")
} }
initdb, err := filepath.Abs("testdata/postgres/initdb") initdb, err := filepath.Abs("testdata/postgres/initdb/init.sql")
require.NoError(t, err) require.NoError(t, err)
// initdb/init.sql creates this database // initdb/init.sql creates this database
@ -262,9 +262,9 @@ func TestPostgresIntegration(t *testing.T) {
Env: map[string]string{ Env: map[string]string{
"POSTGRES_PASSWORD": password, "POSTGRES_PASSWORD": password,
}, },
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": initdb, "/docker-entrypoint-initdb.d/script.sql": initdb,
"/out": outDir, "/out": outDir,
}, },
ExposedPorts: []string{servicePort}, ExposedPorts: []string{servicePort},
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
@ -330,7 +330,7 @@ func TestClickHouseIntegration(t *testing.T) {
t.Skip("Skipping integration test in short mode") t.Skip("Skipping integration test in short mode")
} }
initdb, err := filepath.Abs("testdata/clickhouse/initdb") initdb, err := filepath.Abs("testdata/clickhouse/initdb/init.sql")
require.NoError(t, err) require.NoError(t, err)
// initdb/init.sql creates this database // initdb/init.sql creates this database
@ -345,9 +345,9 @@ func TestClickHouseIntegration(t *testing.T) {
container := testutil.Container{ container := testutil.Container{
Image: "yandex/clickhouse-server", Image: "yandex/clickhouse-server",
ExposedPorts: []string{servicePort, "8123"}, ExposedPorts: []string{servicePort, "8123"},
BindMounts: map[string]string{ Files: map[string]string{
"/docker-entrypoint-initdb.d": initdb, "/docker-entrypoint-initdb.d/script.sql": initdb,
"/out": outDir, "/out": outDir,
}, },
WaitingFor: wait.ForAll( WaitingFor: wait.ForAll(
wait.NewHTTPStrategy("/").WithPort(nat.Port("8123")), wait.NewHTTPStrategy("/").WithPort(nat.Port("8123")),

View File

@ -23,9 +23,9 @@ func (g *TestLogConsumer) Accept(l testcontainers.Log) {
} }
type Container struct { type Container struct {
BindMounts map[string]string
Entrypoint []string Entrypoint []string
Env map[string]string Env map[string]string
Files map[string]string
HostConfigModifier func(*dockercontainer.HostConfig) HostConfigModifier func(*dockercontainer.HostConfig)
ExposedPorts []string ExposedPorts []string
Cmd []string Cmd []string
@ -46,17 +46,21 @@ type Container struct {
func (c *Container) Start() error { func (c *Container) Start() error {
c.ctx = context.Background() c.ctx = context.Background()
containerMounts := make([]testcontainers.ContainerMount, 0, len(c.BindMounts)) files := make([]testcontainers.ContainerFile, 0, len(c.Files))
for k, v := range c.BindMounts { for k, v := range c.Files {
containerMounts = append(containerMounts, testcontainers.BindMount(v, testcontainers.ContainerMountTarget(k))) files = append(files, testcontainers.ContainerFile{
ContainerFilePath: k,
HostFilePath: v,
FileMode: 0o755,
})
} }
req := testcontainers.GenericContainerRequest{ req := testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{ ContainerRequest: testcontainers.ContainerRequest{
Mounts: testcontainers.Mounts(containerMounts...),
Entrypoint: c.Entrypoint, Entrypoint: c.Entrypoint,
Env: c.Env, Env: c.Env,
ExposedPorts: c.ExposedPorts, ExposedPorts: c.ExposedPorts,
Files: files,
HostConfigModifier: c.HostConfigModifier, HostConfigModifier: c.HostConfigModifier,
Cmd: c.Cmd, Cmd: c.Cmd,
Image: c.Image, Image: c.Image,