From 0274491b7d0f88ac863e493f881488b596b5ff80 Mon Sep 17 00:00:00 2001 From: hantmac Date: Fri, 13 Sep 2024 11:21:15 +0800 Subject: [PATCH 01/23] feat: support databend module --- modules/databend/Makefile | 5 + modules/databend/databend.go | 141 +++++++++++++++++++++++ modules/databend/databend_test.go | 80 +++++++++++++ modules/databend/examples_test.go | 86 ++++++++++++++ modules/databend/go.mod | 51 +++++++++ modules/databend/go.sum | 182 ++++++++++++++++++++++++++++++ 6 files changed, 545 insertions(+) create mode 100644 modules/databend/Makefile create mode 100644 modules/databend/databend.go create mode 100644 modules/databend/databend_test.go create mode 100644 modules/databend/examples_test.go create mode 100644 modules/databend/go.mod create mode 100644 modules/databend/go.sum diff --git a/modules/databend/Makefile b/modules/databend/Makefile new file mode 100644 index 0000000000..a8ea6a7163 --- /dev/null +++ b/modules/databend/Makefile @@ -0,0 +1,5 @@ +include ../../commons-test.mk + +.PHONY: test +test: + $(MAKE) test-databend diff --git a/modules/databend/databend.go b/modules/databend/databend.go new file mode 100644 index 0000000000..b73940a00d --- /dev/null +++ b/modules/databend/databend.go @@ -0,0 +1,141 @@ +package databend + +import ( + "context" + "fmt" + "strings" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" +) + +const ( + databendUser = "databend" + defaultUser = "databend" + defaultPassword = "databend" + defaultDatabaseName = "default" +) + +// DatabendContainer represents the Databend container type used in the module +type DatabendContainer struct { + testcontainers.Container + username string + password string + database string +} + +func WithDefaultCredentials() testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) error { + username := req.Env["QUERY_DEFAULT_USER"] + password := req.Env["QUERY_DEFAULT_PASSWORD"] + if len(password) == 0 { + password = defaultPassword + } + if len(username) == 0 { + username = defaultUser + } + return nil + } +} + +// Run creates an instance of the Databend container type +func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*DatabendContainer, error) { + req := testcontainers.ContainerRequest{ + Image: img, + ExposedPorts: []string{"8000/tcp"}, + Env: map[string]string{ + "QUERY_DEFAULT_USER": defaultUser, + "QUERY_DEFAULT_PASSWORD": defaultPassword, + }, + WaitingFor: wait.ForLog("port: 8000 Databend Query Server"), + } + + genericContainerReq := testcontainers.GenericContainerRequest{ + ContainerRequest: req, + Started: true, + } + + opts = append(opts, WithDefaultCredentials()) + + for _, opt := range opts { + if err := opt.Customize(&genericContainerReq); err != nil { + return nil, err + } + } + + username, ok := req.Env["QUERY_DEFAULT_USER"] + if !ok { + username = defaultUser + } + password := req.Env["QUERY_DEFAULT_PASSWORD"] + + if len(password) == 0 && password == "" && !strings.EqualFold(defaultUser, username) { + return nil, fmt.Errorf("empty password and user") + } + + container, err := testcontainers.GenericContainer(ctx, genericContainerReq) + var c *DatabendContainer + if container != nil { + c = &DatabendContainer{ + Container: container, + password: password, + username: username, + database: defaultDatabaseName, + } + } + + if err != nil { + return c, fmt.Errorf("generic container: %w", err) + } + + return c, nil +} + +// MustConnectionString panics if the address cannot be determined. +func (c *DatabendContainer) MustConnectionString(ctx context.Context, args ...string) string { + addr, err := c.ConnectionString(ctx, args...) + if err != nil { + panic(err) + } + return addr +} + +func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string) (string, error) { + containerPort, err := c.MappedPort(ctx, "8000/tcp") + if err != nil { + return "", err + } + + host, err := c.Host(ctx) + if err != nil { + return "", err + } + + extraArgs := "" + if len(args) > 0 { + extraArgs = strings.Join(args, "&") + } + if extraArgs != "" { + extraArgs = "?" + extraArgs + } + + // databend://databend:databend@localhost:8000/default?sslmode=disable + connectionString := fmt.Sprintf("databend://%s:%s@%s:%s/%s%s", c.username, c.password, host, containerPort.Port(), c.database, extraArgs) + return connectionString, nil +} + +func WithUsername(username string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) error { + req.Env["QUERY_DEFAULT_USER"] = username + + return nil + } +} + +func WithPassword(password string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) error { + req.Env["QUERY_DEFAULT_PASSWORD"] = password + + return nil + } +} diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go new file mode 100644 index 0000000000..dd7fa19a34 --- /dev/null +++ b/modules/databend/databend_test.go @@ -0,0 +1,80 @@ +package databend_test + +import ( + "context" + "database/sql" + "testing" + + "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" + + "github.com/testcontainers/testcontainers-go/modules/databend" +) + +func TestDatabend(t *testing.T) { + ctx := context.Background() + + ctr, err := databend.Run(ctx, "datafuselabs/databend:v1.2.615") + testcontainers.CleanupContainer(t, ctr) + require.NoError(t, err) + + // perform assertions + // connectionString { + connectionString, err := ctr.ConnectionString(ctx, "sslmode=disable") + // } + require.NoError(t, err) + + mustConnectionString := ctr.MustConnectionString(ctx, "sslmode=disable") + require.Equal(t, connectionString, mustConnectionString) + + db, err := sql.Open("databend", connectionString) + require.NoError(t, err) + defer db.Close() + + err = db.Ping() + require.NoError(t, err) + + _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + + " `col_1` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL, \n" + + ")") + require.NoError(t, err) +} + +func TestDatabendWithNonRootUserAndEmptyPassword(t *testing.T) { + ctx := context.Background() + + ctr, err := databend.Run(ctx, + "datafuselabs/databend:v1.2.615", + databend.WithUsername("databend"), + databend.WithPassword("databend")) + testcontainers.CleanupContainer(t, ctr) + require.EqualError(t, err, "empty password can be used only with the root user") +} + +func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { + ctx := context.Background() + + ctr, err := databend.Run(ctx, + "datafuselabs/databend:v1.2.615", + databend.WithUsername("databend")) + testcontainers.CleanupContainer(t, ctr) + require.NoError(t, err) + + // perform assertions + connectionString, _ := ctr.ConnectionString(ctx) + + db, err := sql.Open("databend", connectionString) + require.NoError(t, err) + defer db.Close() + + err = db.Ping() + require.NoError(t, err) + + _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + + " `col_1` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL, \n" + + " PRIMARY KEY (`col_1`, `col_2`) \n" + + ")") + require.NoError(t, err) +} diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go new file mode 100644 index 0000000000..032e038432 --- /dev/null +++ b/modules/databend/examples_test.go @@ -0,0 +1,86 @@ +package databend_test + +import ( + "context" + "database/sql" + "fmt" + "log" + + "github.com/testcontainers/testcontainers-go" + + "github.com/testcontainers/testcontainers-go/modules/databend" +) + +func ExampleRun() { + ctx := context.Background() + + databendContainer, err := databend.Run(ctx, + "datafuselabs/databend:v1.2.615", + databend.WithUsername("root"), + databend.WithPassword("password"), + ) + defer func() { + if err := testcontainers.TerminateContainer(databendContainer); err != nil { + log.Printf("failed to terminate container: %s", err) + } + }() + if err != nil { + log.Printf("failed to start container: %s", err) + return + } + // } + + state, err := databendContainer.State(ctx) + if err != nil { + log.Printf("failed to get container state: %s", err) + return + } + + fmt.Println(state.Running) +} + +func ExampleRun_connect() { + ctx := context.Background() + + databendContainer, err := databend.Run(ctx, + "datafuselabs/databend:v1.2.615", + databend.WithUsername("root"), + databend.WithPassword("password"), + ) + defer func() { + if err := testcontainers.TerminateContainer(databendContainer); err != nil { + log.Printf("failed to terminate container: %s", err) + } + }() + if err != nil { + log.Printf("failed to start container: %s", err) + return + } + + connectionString, err := databendContainer.ConnectionString(ctx) + if err != nil { + log.Printf("failed to get connection string: %s", err) + return + } + + db, err := sql.Open("databend", connectionString) + if err != nil { + log.Printf("failed to connect to Databend: %s", err) + return + } + defer db.Close() + + if err = db.Ping(); err != nil { + log.Printf("failed to ping Databend: %s", err) + return + } + var i int + row, err := db.Query("select 1") + err = row.Scan(&i) + if err != nil { + log.Printf("failed to scan row: %s", err) + return + } + + fmt.Println(i) +} diff --git a/modules/databend/go.mod b/modules/databend/go.mod new file mode 100644 index 0000000000..79585875ec --- /dev/null +++ b/modules/databend/go.mod @@ -0,0 +1,51 @@ +module github.com/testcontainers/testcontainers-go/modules/databend + +go 1.22 + +require github.com/testcontainers/testcontainers-go v0.33.0 + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/containerd/containerd v1.7.18 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/containerd/platforms v0.2.1 // indirect + github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/docker v27.1.1+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/klauspost/compress v1.17.4 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/sys/user v0.1.0 // indirect + github.com/moby/term v0.5.0 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/shirou/gopsutil/v3 v3.23.12 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/sys v0.21.0 // indirect +) diff --git a/modules/databend/go.sum b/modules/databend/go.sum new file mode 100644 index 0000000000..08c4267927 --- /dev/null +++ b/modules/databend/go.sum @@ -0,0 +1,182 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= +github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= +github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= +github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= +github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= +github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= +github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= +github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= +github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= +github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= +go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20230920204549-e6e6cdab5c13 h1:vlzZttNJGVqTsRFU9AmdnrcO1Znh8Ew9kCD//yjigk0= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= From 1a51a84a5afdef0030354c5226d2a23a449e7be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Sep 2024 13:54:54 +0200 Subject: [PATCH 02/23] chore: add project scaffolding --- modules/databend/go.mod | 11 ++++++++++- modules/databend/go.sum | 13 +++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/databend/go.mod b/modules/databend/go.mod index 79585875ec..f57ec24250 100644 --- a/modules/databend/go.mod +++ b/modules/databend/go.mod @@ -2,7 +2,10 @@ module github.com/testcontainers/testcontainers-go/modules/databend go 1.22 -require github.com/testcontainers/testcontainers-go v0.33.0 +require ( + github.com/stretchr/testify v1.9.0 + github.com/testcontainers/testcontainers-go v0.33.0 +) require ( dario.cat/mergo v1.0.0 // indirect @@ -13,6 +16,7 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/docker v27.1.1+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect @@ -24,6 +28,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/klauspost/compress v1.17.4 // indirect + github.com/kr/text v0.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect @@ -35,6 +40,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/shirou/gopsutil/v3 v3.23.12 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect @@ -48,4 +54,7 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/sys v0.21.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/testcontainers/testcontainers-go => ../.. diff --git a/modules/databend/go.sum b/modules/databend/go.sum index 08c4267927..1fe56b0aea 100644 --- a/modules/databend/go.sum +++ b/modules/databend/go.sum @@ -16,6 +16,7 @@ github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpS github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -52,6 +53,10 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -78,6 +83,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= @@ -89,14 +96,14 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= -github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -175,6 +182,8 @@ google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvy google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 8473e23cf741f2cb054ba99534ec3621d9b33f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Sep 2024 13:56:19 +0200 Subject: [PATCH 03/23] chore: more file --- .github/workflows/ci.yml | 4 +- .vscode/.testcontainers-go.code-workspace | 4 ++ docs/modules/databend.md | 55 +++++++++++++++++++++++ mkdocs.yml | 1 + sonar-project.properties | 2 +- 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 docs/modules/databend.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f326e9c1da..451397ea44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,7 +94,7 @@ jobs: matrix: go-version: [1.22.x, 1.x] platform: [ubuntu-latest] - module: [artemis, azurite, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, dolt, elasticsearch, gcloud, grafana-lgtm, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, valkey, vault, vearch, weaviate] + module: [artemis, azurite, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, databend, dolt, elasticsearch, gcloud, grafana-lgtm, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, valkey, vault, vearch, weaviate] uses: ./.github/workflows/ci-test-go.yml with: go-version: ${{ matrix.go-version }} @@ -129,7 +129,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.1 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/.vscode/.testcontainers-go.code-workspace b/.vscode/.testcontainers-go.code-workspace index 156da3891d..b355235ac2 100644 --- a/.vscode/.testcontainers-go.code-workspace +++ b/.vscode/.testcontainers-go.code-workspace @@ -49,6 +49,10 @@ "name": "module / couchbase", "path": "../modules/couchbase" }, + { + "name": "module / databend", + "path": "../modules/databend" + }, { "name": "module / dolt", "path": "../modules/dolt" diff --git a/docs/modules/databend.md b/docs/modules/databend.md new file mode 100644 index 0000000000..73b297ab6c --- /dev/null +++ b/docs/modules/databend.md @@ -0,0 +1,55 @@ +# Databend + +Not available until the next release of testcontainers-go :material-tag: main + +## Introduction + +The Testcontainers module for Databend. + +## Adding this module to your project dependencies + +Please run the following command to add the Databend module to your Go dependencies: + +``` +go get github.com/testcontainers/testcontainers-go/modules/databend +``` + +## Usage example + + +[Creating a Databend container](../../modules/databend/examples_test.go) inside_block:runDatabendContainer + + +## Module Reference + +### Run function + +- Not available until the next release of testcontainers-go :material-tag: main + +!!!info + The `RunContainer(ctx, opts...)` function is deprecated and will be removed in the next major release of _Testcontainers for Go_. + +The Databend module exposes one entrypoint function to create the Databend container, and this function receives three parameters: + +```golang +func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*DatabendContainer, error) +``` + +- `context.Context`, the Go context. +- `string`, the Docker image to use. +- `testcontainers.ContainerCustomizer`, a variadic argument for passing options. + +### Container Options + +When starting the Databend container, you can pass options in a variadic way to configure it. + +#### Image + +If you need to set a different Databend Docker image, you can set a valid Docker image as the second argument in the `Run` function. +E.g. `Run(context.Background(), "datafuselabs/databend:v1.2.615")`. + +{% include "../features/common_functional_options.md" %} + +### Container Methods + +The Databend container exposes the following methods: diff --git a/mkdocs.yml b/mkdocs.yml index d48a9dff17..3aa4af31b7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -74,6 +74,7 @@ nav: - modules/cockroachdb.md - modules/consul.md - modules/couchbase.md + - modules/databend.md - modules/dolt.md - modules/elasticsearch.md - modules/gcloud.md diff --git a/sonar-project.properties b/sonar-project.properties index aaa203e905..5a6dd117bb 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,4 +18,4 @@ sonar.test.inclusions=**/*_test.go sonar.test.exclusions=**/vendor/** sonar.go.coverage.reportPaths=**/coverage.out -sonar.go.tests.reportPaths=TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/azurite/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/chroma/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/consul/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/dolt/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/grafana-lgtm/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/influxdb/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/milvus/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/ollama/TEST-unit.xml,modules/openfga/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/opensearch/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/qdrant/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/registry/TEST-unit.xml,modules/surrealdb/TEST-unit.xml,modules/valkey/TEST-unit.xml,modules/vault/TEST-unit.xml,modules/vearch/TEST-unit.xml,modules/weaviate/TEST-unit.xml +sonar.go.tests.reportPaths=TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/azurite/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/chroma/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/consul/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/databend/TEST-unit.xml,modules/dolt/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/grafana-lgtm/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/influxdb/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/milvus/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/ollama/TEST-unit.xml,modules/openfga/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/opensearch/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/qdrant/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/registry/TEST-unit.xml,modules/surrealdb/TEST-unit.xml,modules/valkey/TEST-unit.xml,modules/vault/TEST-unit.xml,modules/vearch/TEST-unit.xml,modules/weaviate/TEST-unit.xml From 6eddbaf50f34f807bf3d6e263b7a3c4d5d99bf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Sep 2024 14:24:52 +0200 Subject: [PATCH 04/23] chore: run make lint --- modules/databend/databend_test.go | 2 +- modules/databend/examples_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index dd7fa19a34..f4feb9c937 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" ) diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 032e038432..fb4f07f652 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -7,7 +7,6 @@ import ( "log" "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/modules/databend" ) From af447e3d44c329505b1fe91a154b00476cc1645f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Sep 2024 14:33:52 +0200 Subject: [PATCH 05/23] fix: proper pinned version --- .github/workflows/ci.yml | 2 +- modulegen/_template/ci.yml.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 451397ea44..e7dcb44618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,7 +129,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/modulegen/_template/ci.yml.tmpl b/modulegen/_template/ci.yml.tmpl index e4fd047b24..46fc3e3906 100644 --- a/modulegen/_template/ci.yml.tmpl +++ b/modulegen/_template/ci.yml.tmpl @@ -129,7 +129,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 From 4d3f40524b2c63daf6bfbecdcbdc5dfffb51a57d Mon Sep 17 00:00:00 2001 From: hantmac Date: Fri, 13 Sep 2024 20:51:17 +0800 Subject: [PATCH 06/23] fix comment --- modules/databend/databend.go | 6 ++---- modules/databend/examples_test.go | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index b73940a00d..22803e1157 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -29,10 +29,10 @@ func WithDefaultCredentials() testcontainers.CustomizeRequestOption { username := req.Env["QUERY_DEFAULT_USER"] password := req.Env["QUERY_DEFAULT_PASSWORD"] if len(password) == 0 { - password = defaultPassword + req.Env["QUERY_DEFAULT_PASSWORD"] = defaultPassword } if len(username) == 0 { - username = defaultUser + req.Env["QUERY_DEFAULT_USER"] = defaultUser } return nil } @@ -127,7 +127,6 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string func WithUsername(username string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) error { req.Env["QUERY_DEFAULT_USER"] = username - return nil } } @@ -135,7 +134,6 @@ func WithUsername(username string) testcontainers.CustomizeRequestOption { func WithPassword(password string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) error { req.Env["QUERY_DEFAULT_PASSWORD"] = password - return nil } } diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index fb4f07f652..21290b1366 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -15,8 +15,8 @@ func ExampleRun() { databendContainer, err := databend.Run(ctx, "datafuselabs/databend:v1.2.615", - databend.WithUsername("root"), - databend.WithPassword("password"), + databend.WithUsername("databend"), + databend.WithPassword("databend"), ) defer func() { if err := testcontainers.TerminateContainer(databendContainer); err != nil { @@ -75,6 +75,10 @@ func ExampleRun_connect() { } var i int row, err := db.Query("select 1") + if err != nil { + log.Printf("failed to query: %s", err) + return + } err = row.Scan(&i) if err != nil { log.Printf("failed to scan row: %s", err) From efd6342addfa6def61bad2569948d1b56952eed0 Mon Sep 17 00:00:00 2001 From: hantmac Date: Fri, 13 Sep 2024 23:39:28 +0800 Subject: [PATCH 07/23] add the detail documents --- docs/modules/databend.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/modules/databend.md b/docs/modules/databend.md index 73b297ab6c..6608c04d1c 100644 --- a/docs/modules/databend.md +++ b/docs/modules/databend.md @@ -50,6 +50,26 @@ E.g. `Run(context.Background(), "datafuselabs/databend:v1.2.615")`. {% include "../features/common_functional_options.md" %} +#### Set username, password + +If you need to set a different user/password, you can use `WithUsername`, `WithPassword` options. + +!!!info +The default values for the username is `databend`, for password is `databend` and for the default database name is `default`. + ### Container Methods The Databend container exposes the following methods: + +#### ConnectionString + +This method returns the connection string to connect to the Databend container, using the default `8000` port. +It's possible to pass extra parameters to the connection string, e.g. `sslmode=disable`. + + +[Get connection string](../../modules/databend/databend_test.go) inside_block:connectionString + + +#### MustGetConnectionString + +`MustConnectionString` panics if the address cannot be determined. From ff632e7c6d3de00b892aae0d5f60bec931837dcf Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 14 Sep 2024 08:55:56 +0800 Subject: [PATCH 08/23] Update modules/databend/databend.go Co-authored-by: Steven Hartland --- modules/databend/databend.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 22803e1157..4f43407754 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -69,8 +69,8 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom } password := req.Env["QUERY_DEFAULT_PASSWORD"] - if len(password) == 0 && password == "" && !strings.EqualFold(defaultUser, username) { - return nil, fmt.Errorf("empty password and user") + if password == "" && username == "" { + return nil, errors.New("empty password and user") } container, err := testcontainers.GenericContainer(ctx, genericContainerReq) From 1a09c9ae948bb7e89d208998591b16377b22c1ac Mon Sep 17 00:00:00 2001 From: hantmac Date: Sat, 14 Sep 2024 09:32:39 +0800 Subject: [PATCH 09/23] fix review comment --- docs/modules/databend.md | 7 ++---- modules/databend/databend.go | 42 ++++++++++++++++--------------- modules/databend/databend_test.go | 3 +-- modules/databend/examples_test.go | 22 ++++++++-------- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/docs/modules/databend.md b/docs/modules/databend.md index 6608c04d1c..a5b024d0ac 100644 --- a/docs/modules/databend.md +++ b/docs/modules/databend.md @@ -26,9 +26,6 @@ go get github.com/testcontainers/testcontainers-go/modules/databend - Not available until the next release of testcontainers-go :material-tag: main -!!!info - The `RunContainer(ctx, opts...)` function is deprecated and will be removed in the next major release of _Testcontainers for Go_. - The Databend module exposes one entrypoint function to create the Databend container, and this function receives three parameters: ```golang @@ -50,9 +47,9 @@ E.g. `Run(context.Background(), "datafuselabs/databend:v1.2.615")`. {% include "../features/common_functional_options.md" %} -#### Set username, password +#### Set username, password, and database name -If you need to set a different user/password, you can use `WithUsername`, `WithPassword` options. +If you need to set a different user/password/database, you can use `WithUsername`, `WithPassword`, `WithDatabase` options. !!!info The default values for the username is `databend`, for password is `databend` and for the default database name is `default`. diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 4f43407754..4618c78bb4 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -2,6 +2,7 @@ package databend import ( "context" + "errors" "fmt" "strings" @@ -24,18 +25,15 @@ type DatabendContainer struct { database string } -func WithDefaultCredentials() testcontainers.CustomizeRequestOption { - return func(req *testcontainers.GenericContainerRequest) error { - username := req.Env["QUERY_DEFAULT_USER"] - password := req.Env["QUERY_DEFAULT_PASSWORD"] - if len(password) == 0 { - req.Env["QUERY_DEFAULT_PASSWORD"] = defaultPassword - } - if len(username) == 0 { - req.Env["QUERY_DEFAULT_USER"] = defaultUser - } - return nil - } +var _ testcontainers.ContainerCustomizer = (*DatabendOption)(nil) + +// DatabendOption is an option for the Databend container. +type DatabendOption func(*DatabendContainer) + +// Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface. +func (o DatabendOption) Customize(*testcontainers.GenericContainerRequest) error { + // NOOP to satisfy interface. + return nil } // Run creates an instance of the Databend container type @@ -47,7 +45,10 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom "QUERY_DEFAULT_USER": defaultUser, "QUERY_DEFAULT_PASSWORD": defaultPassword, }, - WaitingFor: wait.ForLog("port: 8000 Databend Query Server"), + WaitingFor: wait.ForAll( + wait.ForLog("port: 8000 Databend Query Server"), + wait.ForListeningPort("8000/tcp"), + ), } genericContainerReq := testcontainers.GenericContainerRequest{ @@ -55,20 +56,14 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom Started: true, } - opts = append(opts, WithDefaultCredentials()) - for _, opt := range opts { if err := opt.Customize(&genericContainerReq); err != nil { return nil, err } } - username, ok := req.Env["QUERY_DEFAULT_USER"] - if !ok { - username = defaultUser - } + username := req.Env["QUERY_DEFAULT_USER"] password := req.Env["QUERY_DEFAULT_PASSWORD"] - if password == "" && username == "" { return nil, errors.New("empty password and user") } @@ -137,3 +132,10 @@ func WithPassword(password string) testcontainers.CustomizeRequestOption { return nil } } + +// WithDatabase sets the name of the database to use. +func WithDatabase(database string) DatabendOption { + return func(d *DatabendContainer) { + d.database = database + } +} diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index f4feb9c937..e3cfc05766 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -49,7 +49,7 @@ func TestDatabendWithNonRootUserAndEmptyPassword(t *testing.T) { databend.WithUsername("databend"), databend.WithPassword("databend")) testcontainers.CleanupContainer(t, ctr) - require.EqualError(t, err, "empty password can be used only with the root user") + require.Error(t, err) } func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { @@ -74,7 +74,6 @@ func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + " `col_1` VARCHAR(128) NOT NULL, \n" + " `col_2` VARCHAR(128) NOT NULL, \n" + - " PRIMARY KEY (`col_1`, `col_2`) \n" + ")") require.NoError(t, err) } diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 21290b1366..748c64d505 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -5,12 +5,15 @@ import ( "database/sql" "fmt" "log" + "testing" + + "github.com/stretchr/testify/assert" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" ) -func ExampleRun() { +func TestExampleRun(t *testing.T) { ctx := context.Background() databendContainer, err := databend.Run(ctx, @@ -27,7 +30,6 @@ func ExampleRun() { log.Printf("failed to start container: %s", err) return } - // } state, err := databendContainer.State(ctx) if err != nil { @@ -36,15 +38,17 @@ func ExampleRun() { } fmt.Println(state.Running) + assert.Equal(t, true, state.Running) } -func ExampleRun_connect() { +func TestExampleRun_connect(t *testing.T) { ctx := context.Background() databendContainer, err := databend.Run(ctx, "datafuselabs/databend:v1.2.615", databend.WithUsername("root"), databend.WithPassword("password"), + databend.WithDatabase("test"), ) defer func() { if err := testcontainers.TerminateContainer(databendContainer); err != nil { @@ -75,15 +79,9 @@ func ExampleRun_connect() { } var i int row, err := db.Query("select 1") - if err != nil { - log.Printf("failed to query: %s", err) - return - } + assert.NoError(t, err) err = row.Scan(&i) - if err != nil { - log.Printf("failed to scan row: %s", err) - return - } + assert.NoError(t, err) - fmt.Println(i) + assert.Equal(t, 1, i) } From b2815777d90e999205840c0bc3a252fd90be6201 Mon Sep 17 00:00:00 2001 From: hantmac Date: Sat, 14 Sep 2024 15:38:04 +0800 Subject: [PATCH 10/23] fix --- modules/databend/databend.go | 2 ++ modules/databend/examples_test.go | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 4618c78bb4..f3fb658e84 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -119,6 +119,7 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string return connectionString, nil } +// WithUsername sets the username for the Databend container. func WithUsername(username string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) error { req.Env["QUERY_DEFAULT_USER"] = username @@ -126,6 +127,7 @@ func WithUsername(username string) testcontainers.CustomizeRequestOption { } } +// WithPassword sets the password for the Databend container. func WithPassword(password string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) error { req.Env["QUERY_DEFAULT_PASSWORD"] = password diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 748c64d505..b75391989a 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -5,15 +5,12 @@ import ( "database/sql" "fmt" "log" - "testing" - - "github.com/stretchr/testify/assert" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" ) -func TestExampleRun(t *testing.T) { +func ExampleRun() { ctx := context.Background() databendContainer, err := databend.Run(ctx, @@ -38,10 +35,12 @@ func TestExampleRun(t *testing.T) { } fmt.Println(state.Running) - assert.Equal(t, true, state.Running) + + // Output: + // true } -func TestExampleRun_connect(t *testing.T) { +func ExampleRun_connect() { ctx := context.Background() databendContainer, err := databend.Run(ctx, @@ -79,9 +78,18 @@ func TestExampleRun_connect(t *testing.T) { } var i int row, err := db.Query("select 1") - assert.NoError(t, err) + if err != nil { + log.Printf("failed to query Databend: %s", err) + return + } err = row.Scan(&i) - assert.NoError(t, err) + if err != nil { + log.Printf("failed to scan result: %s", err) + return + } + + fmt.Println(i) - assert.Equal(t, 1, i) + // Output: + // true } From 77c4c422e7bbe043c15edb04fb89d572a288c2ba Mon Sep 17 00:00:00 2001 From: hantmac Date: Sat, 14 Sep 2024 15:58:35 +0800 Subject: [PATCH 11/23] default database --- modules/databend/databend.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index f3fb658e84..0aa509366c 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -113,6 +113,9 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string if extraArgs != "" { extraArgs = "?" + extraArgs } + if c.database == "" { + c.database = defaultDatabaseName + } // databend://databend:databend@localhost:8000/default?sslmode=disable connectionString := fmt.Sprintf("databend://%s:%s@%s:%s/%s%s", c.username, c.password, host, containerPort.Port(), c.database, extraArgs) From 19fd929a80df7fc109ac04408d6ca31c29ff10fc Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 15 Sep 2024 09:17:31 +0800 Subject: [PATCH 12/23] Update modules/databend/databend_test.go Co-authored-by: Steven Hartland --- modules/databend/databend_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index e3cfc05766..3fb553433e 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -62,7 +62,8 @@ func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { require.NoError(t, err) // perform assertions - connectionString, _ := ctr.ConnectionString(ctx) + connectionString, err := ctr.ConnectionString(ctx) + require.NoError(t, err) db, err := sql.Open("databend", connectionString) require.NoError(t, err) From bbbc0b456855f1d14a9a04eef31f05ddd15648ca Mon Sep 17 00:00:00 2001 From: hantmac Date: Sun, 15 Sep 2024 09:18:18 +0800 Subject: [PATCH 13/23] fix review comments --- modules/databend/databend.go | 1 - modules/databend/databend_test.go | 4 ++-- modules/databend/examples_test.go | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 0aa509366c..170f805173 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -46,7 +46,6 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom "QUERY_DEFAULT_PASSWORD": defaultPassword, }, WaitingFor: wait.ForAll( - wait.ForLog("port: 8000 Databend Query Server"), wait.ForListeningPort("8000/tcp"), ), } diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index e3cfc05766..e0064032c7 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -46,8 +46,8 @@ func TestDatabendWithNonRootUserAndEmptyPassword(t *testing.T) { ctr, err := databend.Run(ctx, "datafuselabs/databend:v1.2.615", - databend.WithUsername("databend"), - databend.WithPassword("databend")) + databend.WithUsername("test"), + databend.WithPassword("")) testcontainers.CleanupContainer(t, ctr) require.Error(t, err) } diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index b75391989a..41d2091eea 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -15,8 +15,9 @@ func ExampleRun() { databendContainer, err := databend.Run(ctx, "datafuselabs/databend:v1.2.615", - databend.WithUsername("databend"), - databend.WithPassword("databend"), + databend.WithUsername("test1"), + databend.WithPassword("pass1"), + databend.WithDatabase("test1"), ) defer func() { if err := testcontainers.TerminateContainer(databendContainer); err != nil { @@ -91,5 +92,5 @@ func ExampleRun_connect() { fmt.Println(i) // Output: - // true + // 1 } From f1bd4f0a8898eb4de9c0b01836876fe81632e854 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 15 Sep 2024 09:32:40 +0800 Subject: [PATCH 14/23] Update modules/databend/databend.go Co-authored-by: Steven Hartland --- modules/databend/databend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 170f805173..1ef83de846 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -97,7 +97,7 @@ func (c *DatabendContainer) MustConnectionString(ctx context.Context, args ...st func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string) (string, error) { containerPort, err := c.MappedPort(ctx, "8000/tcp") if err != nil { - return "", err + return "", fmt.Errorf("mapped port: %w", err) } host, err := c.Host(ctx) From dd1a66c0b0740e2e70dc8ce7b2b317c3504786a2 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 15 Sep 2024 09:33:01 +0800 Subject: [PATCH 15/23] Update modules/databend/databend.go Co-authored-by: Steven Hartland --- modules/databend/databend.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 1ef83de846..70ba129b59 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -122,6 +122,8 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string } // WithUsername sets the username for the Databend container. +// WithUsername is [Run] option that configures the default query user by setting +// the `QUERY_DEFAULT_USER` container environment variable. func WithUsername(username string) testcontainers.CustomizeRequestOption { return func(req *testcontainers.GenericContainerRequest) error { req.Env["QUERY_DEFAULT_USER"] = username From fdd7ad2d44e41fa4c2e7484765e789279a626100 Mon Sep 17 00:00:00 2001 From: hantmac Date: Sun, 15 Sep 2024 22:47:45 +0800 Subject: [PATCH 16/23] fix comment --- modules/databend/databend.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 70ba129b59..7f4e04bbce 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -45,9 +45,7 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom "QUERY_DEFAULT_USER": defaultUser, "QUERY_DEFAULT_PASSWORD": defaultPassword, }, - WaitingFor: wait.ForAll( - wait.ForListeningPort("8000/tcp"), - ), + WaitingFor: wait.ForListeningPort("8000/tcp"), } genericContainerReq := testcontainers.GenericContainerRequest{ @@ -113,7 +111,7 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string extraArgs = "?" + extraArgs } if c.database == "" { - c.database = defaultDatabaseName + return "", errors.New("database name is empty") } // databend://databend:databend@localhost:8000/default?sslmode=disable From 4eebd6e5be34f235b864e0a077d52494aa06fbcc Mon Sep 17 00:00:00 2001 From: hantmac Date: Mon, 16 Sep 2024 22:07:32 +0800 Subject: [PATCH 17/23] fix databend-go module --- modules/databend/databend_test.go | 2 ++ modules/databend/examples_test.go | 2 ++ modules/databend/go.mod | 3 +++ modules/databend/go.sum | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index 3b0e4e8ad5..a356610a28 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -7,6 +7,8 @@ import ( "github.com/stretchr/testify/require" + _ "github.com/datafuselabs/databend-go" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" ) diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 41d2091eea..fcdc0aee8c 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -8,6 +8,8 @@ import ( "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" + + _ "github.com/datafuselabs/databend-go" ) func ExampleRun() { diff --git a/modules/databend/go.mod b/modules/databend/go.mod index f57ec24250..dff6be0d9f 100644 --- a/modules/databend/go.mod +++ b/modules/databend/go.mod @@ -3,6 +3,7 @@ module github.com/testcontainers/testcontainers-go/modules/databend go 1.22 require ( + github.com/datafuselabs/databend-go v0.7.0 github.com/stretchr/testify v1.9.0 github.com/testcontainers/testcontainers-go v0.33.0 ) @@ -10,7 +11,9 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/BurntSushi/toml v1.2.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/avast/retry-go v3.0.0+incompatible // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/containerd/containerd v1.7.18 // indirect github.com/containerd/log v0.1.0 // indirect diff --git a/modules/databend/go.sum b/modules/databend/go.sum index 1fe56b0aea..ff2bf473a8 100644 --- a/modules/databend/go.sum +++ b/modules/databend/go.sum @@ -4,8 +4,12 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= +github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= @@ -19,6 +23,8 @@ github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHf github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/datafuselabs/databend-go v0.7.0 h1:wPND9I8r/FfcY/nAPo8yeZbh5PMga3ICSDIaq8/eP3o= +github.com/datafuselabs/databend-go v0.7.0/go.mod h1:h/sGUBZs7EqJgqnZ3XB0KHfyUlpGvfNrw2lWcdDJVIw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -104,6 +110,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= +github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= From 8b729bf1da5d822ea4507a32f9db894d69c09861 Mon Sep 17 00:00:00 2001 From: hantmac Date: Mon, 16 Sep 2024 22:21:16 +0800 Subject: [PATCH 18/23] fix databend tests --- modules/databend/databend_test.go | 25 +++++++++---------------- modules/databend/examples_test.go | 12 ++---------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index a356610a28..3be099d4f7 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -38,23 +38,12 @@ func TestDatabend(t *testing.T) { _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + " `col_1` VARCHAR(128) NOT NULL, \n" + - " `col_2` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL \n" + ")") require.NoError(t, err) } -func TestDatabendWithNonRootUserAndEmptyPassword(t *testing.T) { - ctx := context.Background() - - ctr, err := databend.Run(ctx, - "datafuselabs/databend:v1.2.615", - databend.WithUsername("test"), - databend.WithPassword("")) - testcontainers.CleanupContainer(t, ctr) - require.Error(t, err) -} - -func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { +func TestDatabendWithDefaultUserAndPassword(t *testing.T) { ctx := context.Background() ctr, err := databend.Run(ctx, @@ -64,19 +53,23 @@ func TestDatabendWithRootUserAndEmptyPassword(t *testing.T) { require.NoError(t, err) // perform assertions - connectionString, err := ctr.ConnectionString(ctx) + connectionString, err := ctr.ConnectionString(ctx, "sslmode=disable") require.NoError(t, err) db, err := sql.Open("databend", connectionString) require.NoError(t, err) defer db.Close() - err = db.Ping() require.NoError(t, err) + var i int + row := db.QueryRow("select 1") + err = row.Scan(&i) + require.NoError(t, err) + _, err = db.Exec("CREATE TABLE IF NOT EXISTS a_table ( \n" + " `col_1` VARCHAR(128) NOT NULL, \n" + - " `col_2` VARCHAR(128) NOT NULL, \n" + + " `col_2` VARCHAR(128) NOT NULL \n" + ")") require.NoError(t, err) } diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index fcdc0aee8c..5ecfe37a39 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -62,7 +62,7 @@ func ExampleRun_connect() { return } - connectionString, err := databendContainer.ConnectionString(ctx) + connectionString, err := databendContainer.ConnectionString(ctx, "sslmode=disable") if err != nil { log.Printf("failed to get connection string: %s", err) return @@ -75,16 +75,8 @@ func ExampleRun_connect() { } defer db.Close() - if err = db.Ping(); err != nil { - log.Printf("failed to ping Databend: %s", err) - return - } var i int - row, err := db.Query("select 1") - if err != nil { - log.Printf("failed to query Databend: %s", err) - return - } + row := db.QueryRow("select 1") err = row.Scan(&i) if err != nil { log.Printf("failed to scan result: %s", err) From 0db99065c295127c70948cd66c4883eda844ab9a Mon Sep 17 00:00:00 2001 From: hantmac Date: Tue, 17 Sep 2024 11:55:09 +0800 Subject: [PATCH 19/23] fix golangci-lint --- modules/databend/databend_test.go | 3 +-- modules/databend/examples_test.go | 4 ++-- modules/databend/go.mod | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/databend/databend_test.go b/modules/databend/databend_test.go index 3be099d4f7..58ac71e327 100644 --- a/modules/databend/databend_test.go +++ b/modules/databend/databend_test.go @@ -5,9 +5,8 @@ import ( "database/sql" "testing" - "github.com/stretchr/testify/require" - _ "github.com/datafuselabs/databend-go" + "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 5ecfe37a39..4af498e1c8 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -6,10 +6,10 @@ import ( "fmt" "log" + _ "github.com/datafuselabs/databend-go" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/databend" - - _ "github.com/datafuselabs/databend-go" ) func ExampleRun() { diff --git a/modules/databend/go.mod b/modules/databend/go.mod index dff6be0d9f..182f764bf2 100644 --- a/modules/databend/go.mod +++ b/modules/databend/go.mod @@ -1,6 +1,6 @@ module github.com/testcontainers/testcontainers-go/modules/databend -go 1.22 +go 1.22.0 require ( github.com/datafuselabs/databend-go v0.7.0 From b78a4cf3cdf7f16c45e6ffb58a86cb378fd2568b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 18 Sep 2024 19:32:05 +0800 Subject: [PATCH 20/23] Update modules/databend/databend.go Co-authored-by: Steven Hartland --- modules/databend/databend.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 7f4e04bbce..dab32e45e8 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -105,10 +105,7 @@ func (c *DatabendContainer) ConnectionString(ctx context.Context, args ...string extraArgs := "" if len(args) > 0 { - extraArgs = strings.Join(args, "&") - } - if extraArgs != "" { - extraArgs = "?" + extraArgs + extraArgs = "?" + strings.Join(args, "&") } if c.database == "" { return "", errors.New("database name is empty") From 74dead1d8b38979038805e7150e1d594830ac325 Mon Sep 17 00:00:00 2001 From: hantmac Date: Thu, 19 Sep 2024 11:09:14 +0800 Subject: [PATCH 21/23] remove WithDatabase --- modules/databend/databend.go | 7 ------- modules/databend/examples_test.go | 2 -- 2 files changed, 9 deletions(-) diff --git a/modules/databend/databend.go b/modules/databend/databend.go index 7f4e04bbce..d95b78942f 100644 --- a/modules/databend/databend.go +++ b/modules/databend/databend.go @@ -136,10 +136,3 @@ func WithPassword(password string) testcontainers.CustomizeRequestOption { return nil } } - -// WithDatabase sets the name of the database to use. -func WithDatabase(database string) DatabendOption { - return func(d *DatabendContainer) { - d.database = database - } -} diff --git a/modules/databend/examples_test.go b/modules/databend/examples_test.go index 4af498e1c8..ac284ef009 100644 --- a/modules/databend/examples_test.go +++ b/modules/databend/examples_test.go @@ -19,7 +19,6 @@ func ExampleRun() { "datafuselabs/databend:v1.2.615", databend.WithUsername("test1"), databend.WithPassword("pass1"), - databend.WithDatabase("test1"), ) defer func() { if err := testcontainers.TerminateContainer(databendContainer); err != nil { @@ -50,7 +49,6 @@ func ExampleRun_connect() { "datafuselabs/databend:v1.2.615", databend.WithUsername("root"), databend.WithPassword("password"), - databend.WithDatabase("test"), ) defer func() { if err := testcontainers.TerminateContainer(databendContainer); err != nil { From 7f7bcce54deee7560cc1713bc88deca5a5440c16 Mon Sep 17 00:00:00 2001 From: hantmac Date: Thu, 19 Sep 2024 11:11:20 +0800 Subject: [PATCH 22/23] fix --- docs/modules/databend.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/modules/databend.md b/docs/modules/databend.md index a5b024d0ac..450595a264 100644 --- a/docs/modules/databend.md +++ b/docs/modules/databend.md @@ -47,9 +47,9 @@ E.g. `Run(context.Background(), "datafuselabs/databend:v1.2.615")`. {% include "../features/common_functional_options.md" %} -#### Set username, password, and database name +#### Set username, password -If you need to set a different user/password/database, you can use `WithUsername`, `WithPassword`, `WithDatabase` options. +If you need to set a different user/password/database, you can use `WithUsername`, `WithPassword` options. !!!info The default values for the username is `databend`, for password is `databend` and for the default database name is `default`. From 0922ab7e3c5e60e450aa8ebeebe8f36c58eaafce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 19 Sep 2024 10:32:43 +0200 Subject: [PATCH 23/23] chore: rollback pinned version We'll tackle that in a separate PR --- modulegen/_template/ci.yml.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modulegen/_template/ci.yml.tmpl b/modulegen/_template/ci.yml.tmpl index 46fc3e3906..e4fd047b24 100644 --- a/modulegen/_template/ci.yml.tmpl +++ b/modulegen/_template/ci.yml.tmpl @@ -129,7 +129,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.1 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0