Skip to content

Commit

Permalink
chore: update testContainers usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 committed Sep 13, 2024
1 parent 098e087 commit dc82365
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 71 deletions.
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ require (
github.com/google/uuid v1.6.0
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.33.0
github.com/testcontainers/testcontainers-go/modules/chroma v0.31.0
github.com/testcontainers/testcontainers-go/modules/milvus v0.31.0
github.com/testcontainers/testcontainers-go/modules/mongodb v0.31.0
github.com/testcontainers/testcontainers-go/modules/mysql v0.31.0
github.com/testcontainers/testcontainers-go/modules/opensearch v0.31.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.31.0
github.com/testcontainers/testcontainers-go/modules/qdrant v0.31.0
github.com/testcontainers/testcontainers-go/modules/redis v0.31.0
github.com/testcontainers/testcontainers-go/modules/weaviate v0.31.0
github.com/testcontainers/testcontainers-go/modules/chroma v0.33.0
github.com/testcontainers/testcontainers-go/modules/milvus v0.33.0
github.com/testcontainers/testcontainers-go/modules/mongodb v0.33.0
github.com/testcontainers/testcontainers-go/modules/mysql v0.33.0
github.com/testcontainers/testcontainers-go/modules/opensearch v0.33.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.33.0
github.com/testcontainers/testcontainers-go/modules/qdrant v0.33.0
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0
github.com/testcontainers/testcontainers-go/modules/weaviate v0.33.0
)

require (
Expand Down
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -674,24 +674,24 @@ github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fx
github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
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/testcontainers/testcontainers-go/modules/chroma v0.31.0 h1:fB/04gfZ9iqm9FO6tEgB8RKU/Dbkc1Opdhp47uiCDSM=
github.com/testcontainers/testcontainers-go/modules/chroma v0.31.0/go.mod h1:dYvKTWVnJ58YizDYX2txYwDG4FvudYUmx37tvbza90o=
github.com/testcontainers/testcontainers-go/modules/milvus v0.31.0 h1:0wTakit4o9Yn0VNkzDOY5hV1LeKcw2W7gxcLa3el2x0=
github.com/testcontainers/testcontainers-go/modules/milvus v0.31.0/go.mod h1:ta9EDZd+lKBMU7enljbNu5H1G495fnT0dw7hmsCPWa0=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.31.0 h1:0ZAEX50NNK/TVRqDls4aQUmokRcYzstKzmF3DCfFK+Y=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.31.0/go.mod h1:n5KbYAdzD8xJrNVGdPvSacJtwZ4D0Q/byTMI5vR/dk8=
github.com/testcontainers/testcontainers-go/modules/mysql v0.31.0 h1:790+S8ewZYCbG+o8IiFlZ8ZZ33XbNO6zV9qhU6xhlRk=
github.com/testcontainers/testcontainers-go/modules/mysql v0.31.0/go.mod h1:REFmO+lSG9S6uSBEwIMZCxeI36uhScjTwChYADeO3JA=
github.com/testcontainers/testcontainers-go/modules/opensearch v0.31.0 h1:sgo2PJb8oCK7ogJjRxAkidXmt+gPzwtyhZpaxSI5wDo=
github.com/testcontainers/testcontainers-go/modules/opensearch v0.31.0/go.mod h1:l4Z7QqGpdk4wTTQk8J8CZ75pfqAz1dizm+LECOLuNVw=
github.com/testcontainers/testcontainers-go/modules/postgres v0.31.0 h1:isAwFS3KNKRbJMbWv+wolWqOFUECmjYZ+sIRZCIBc/E=
github.com/testcontainers/testcontainers-go/modules/postgres v0.31.0/go.mod h1:ZNYY8vumNCEG9YI59A9d6/YaMY49uwRhmeU563EzFGw=
github.com/testcontainers/testcontainers-go/modules/qdrant v0.31.0 h1:5bYvi8lSqDnJrO1w5W3AFaSsRe4ZDv4TPj1tsaBEz20=
github.com/testcontainers/testcontainers-go/modules/qdrant v0.31.0/go.mod h1:/3GyFMTSiem1j5mfI/96MufdNvB3A8Xqa+xnV4CUR4A=
github.com/testcontainers/testcontainers-go/modules/redis v0.31.0 h1:5X6GhOdLwV86zcW8sxppJAMtsDC9u+r9tb3biBc9GKs=
github.com/testcontainers/testcontainers-go/modules/redis v0.31.0/go.mod h1:dKi5xBwy1k4u8yb3saQHu7hMEJwewHXxzbcMAuLiA6o=
github.com/testcontainers/testcontainers-go/modules/weaviate v0.31.0 h1:iVJX9O12GHRhqPgIuz/eE8BsNEwyrUMJnWgduBt8quc=
github.com/testcontainers/testcontainers-go/modules/weaviate v0.31.0/go.mod h1:WNc2XhLphiLdNJdjJZvUtRj08ThLY8FL60y7FQSJTPQ=
github.com/testcontainers/testcontainers-go/modules/chroma v0.33.0 h1:gelkS3qem1+hTZv7R/PNr89AiaIgcxhHNqSM6f5UG/g=
github.com/testcontainers/testcontainers-go/modules/chroma v0.33.0/go.mod h1:MoykG4ksnUufSOg6U6Svmtap0fAnu8+cm8bLWK8v208=
github.com/testcontainers/testcontainers-go/modules/milvus v0.33.0 h1:YFK+stkj7zxCW2qOi1dCt0shZwsZ3vUVUHqTmgd/Z5s=
github.com/testcontainers/testcontainers-go/modules/milvus v0.33.0/go.mod h1:lbSrWVzh/mxfOmQsGYCT1rg4xSIxpoiNrO1UE+0PVKU=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.33.0 h1:iXVA84s5hKMS5gn01GWOYHE3ymy/2b+0YkpFeTxB2XY=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.33.0/go.mod h1:R6tMjTojRiaoo89fh/hf7tOmfzohdqSU17R9DwSVSog=
github.com/testcontainers/testcontainers-go/modules/mysql v0.33.0 h1:1JN7YEEepTMJmGI2hW678IiiYoLM5HDp3vbCPmUokJ8=
github.com/testcontainers/testcontainers-go/modules/mysql v0.33.0/go.mod h1:9tZZwRW5s3RaI5X0Wnc+GXNJFXqbkKmob2nBHbfA/5E=
github.com/testcontainers/testcontainers-go/modules/opensearch v0.33.0 h1:2m2UfQ0qG0WBILpLVZdd6sK2HWXhgl5zBFEXedAgox8=
github.com/testcontainers/testcontainers-go/modules/opensearch v0.33.0/go.mod h1:T0w7tOUNNnkLOUPtAazrzfhZHEOhtMedPoLNZfHALTE=
github.com/testcontainers/testcontainers-go/modules/postgres v0.33.0 h1:c+Gt+XLJjqFAejgX4hSpnHIpC9eAhvgI/TFWL/PbrFI=
github.com/testcontainers/testcontainers-go/modules/postgres v0.33.0/go.mod h1:I4DazHBoWDyf69ByOIyt3OdNjefiUx372459txOpQ3o=
github.com/testcontainers/testcontainers-go/modules/qdrant v0.33.0 h1:GnZ9rMF8YXK0DvIPH8kpjzuUoUMBMQPmD8YTiEMSaU4=
github.com/testcontainers/testcontainers-go/modules/qdrant v0.33.0/go.mod h1:IdAqn56O9sxXJuY3txV7QAwP/vpu0sxC6SFJoqY/vyw=
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0 h1:S/QvMOwpr00MM2aWH+krzP73Erlp/Ug0dr2rkgZYI5s=
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0/go.mod h1:gudb3+6uZ9SsAysOVoLs7nazbjGlkHegBW8nqPXvDMI=
github.com/testcontainers/testcontainers-go/modules/weaviate v0.33.0 h1:K9+hhX7I+TobvbetQJSViAuxnq89VMm+BRHgAqiYVTE=
github.com/testcontainers/testcontainers-go/modules/weaviate v0.33.0/go.mod h1:VVD7q7mzPaBtDd06awExJ4J2eXdvEoMJXYl9eZqF30E=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
Expand Down
5 changes: 2 additions & 3 deletions memory/mongo/mongo_chat_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/mongodb"
"github.com/tmc/langchaingo/llms"
)

func runTestContainer() (string, error) {
ctx := context.Background()

mongoContainer, err := mongodb.RunContainer(
mongoContainer, err := mongodb.Run(
ctx,
testcontainers.WithImage("mongo:7.0.8"),
"mongo:7.0.8",
mongodb.WithUsername("test"),
mongodb.WithPassword("test"),
)
Expand Down
5 changes: 2 additions & 3 deletions tools/sqldatabase/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/mysql"
"github.com/tmc/langchaingo/tools/sqldatabase"
_ "github.com/tmc/langchaingo/tools/sqldatabase/mysql"
Expand All @@ -23,9 +22,9 @@ func Test(t *testing.T) {
// export LANGCHAINGO_TEST_MYSQL=user:p@ssw0rd@tcp(localhost:3306)/test
mysqlURI := os.Getenv("LANGCHAINGO_TEST_MYSQL")
if mysqlURI == "" {
mysqlContainer, err := mysql.RunContainer(
mysqlContainer, err := mysql.Run(
context.Background(),
testcontainers.WithImage("mysql:8.3.0"),
"mysql:8.3.0",
mysql.WithDatabase("test"),
mysql.WithUsername("user"),
mysql.WithPassword("p@ssw0rd"),
Expand Down
4 changes: 2 additions & 2 deletions tools/sqldatabase/postgresql/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func Test(t *testing.T) {
// export LANGCHAINGO_TEST_POSTGRESQL=postgres://db_user:mysecretpassword@localhost:5438/test?sslmode=disable
pgURI := os.Getenv("LANGCHAINGO_TEST_POSTGRESQL")
if pgURI == "" {
pgContainer, err := postgres.RunContainer(
pgContainer, err := postgres.Run(
context.Background(),
testcontainers.WithImage("postgres:16.2"),
"postgres:16.2",
postgres.WithDatabase("test"),
postgres.WithUsername("db_user"),
postgres.WithPassword("p@mysecretpassword"),
Expand Down
3 changes: 1 addition & 2 deletions vectorstores/chroma/chroma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
chromatypes "github.com/amikos-tech/chroma-go/types"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
tcchroma "github.com/testcontainers/testcontainers-go/modules/chroma"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/embeddings"
Expand Down Expand Up @@ -569,7 +568,7 @@ func getValues(t *testing.T) (string, string) {

chromaURL := os.Getenv(chroma.ChromaURLKeyEnvVarName)
if chromaURL == "" {
chromaContainer, err := tcchroma.RunContainer(context.Background(), testcontainers.WithImage("chromadb/chroma:0.4.24"))
chromaContainer, err := tcchroma.Run(context.Background(), "chromadb/chroma:0.4.24")
if err != nil && strings.Contains(err.Error(), "Cannot connect to the Docker daemon") {
t.Skip("Docker not available")
}
Expand Down
3 changes: 1 addition & 2 deletions vectorstores/milvus/milvus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/milvus-io/milvus-sdk-go/v2/client"
"github.com/milvus-io/milvus-sdk-go/v2/entity"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
tcmilvus "github.com/testcontainers/testcontainers-go/modules/milvus"
"github.com/tmc/langchaingo/embeddings"
"github.com/tmc/langchaingo/llms"
Expand Down Expand Up @@ -46,7 +45,7 @@ func getNewStore(t *testing.T, opts ...Option) (Store, error) {

url := os.Getenv("MILVUS_URL")
if url == "" {
milvusContainer, err := tcmilvus.RunContainer(context.Background(), testcontainers.WithImage("milvusdb/milvus:v2.4.0-rc.1-latest"))
milvusContainer, err := tcmilvus.Run(context.Background(), "milvusdb/milvus:v2.4.0-rc.1-latest")
if err != nil && strings.Contains(err.Error(), "Cannot connect to the Docker daemon") {
t.Skip("Docker not available")
}
Expand Down
3 changes: 1 addition & 2 deletions vectorstores/opensearch/opensearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/google/uuid"
opensearchgo "github.com/opensearch-project/opensearch-go"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
tcopensearch "github.com/testcontainers/testcontainers-go/modules/opensearch"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/embeddings"
Expand All @@ -33,7 +32,7 @@ func getEnvVariables(t *testing.T) (string, string, string) {

opensearchEndpoint := os.Getenv("OPENSEARCH_ENDPOINT")
if opensearchEndpoint == "" {
openseachContainer, err := tcopensearch.RunContainer(context.Background(), testcontainers.WithImage("opensearchproject/opensearch:2.11.1"))
openseachContainer, err := tcopensearch.Run(context.Background(), "opensearchproject/opensearch:2.11.1")
if err != nil && strings.Contains(err.Error(), "Cannot connect to the Docker daemon") {
t.Skip("Docker not available")
}
Expand Down
4 changes: 2 additions & 2 deletions vectorstores/pgvector/pgvector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func preCheckEnvSetting(t *testing.T) string {

pgvectorURL := os.Getenv("PGVECTOR_CONNECTION_STRING")
if pgvectorURL == "" {
pgVectorContainer, err := tcpostgres.RunContainer(
pgVectorContainer, err := tcpostgres.Run(
context.Background(),
testcontainers.WithImage("docker.io/pgvector/pgvector:pg16"),
"docker.io/pgvector/pgvector:pg16",
tcpostgres.WithDatabase("db_test"),
tcpostgres.WithUsername("user"),
tcpostgres.WithPassword("passw0rd!"),
Expand Down
3 changes: 1 addition & 2 deletions vectorstores/qdrant/qdrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/google/uuid"
qc "github.com/qdrant/go-client/qdrant"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
tcqdrant "github.com/testcontainers/testcontainers-go/modules/qdrant"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/embeddings"
Expand Down Expand Up @@ -357,7 +356,7 @@ func getValues(t *testing.T) string {
t.Skip("OPENAI_API_KEY not set")
}

qdrantContainer, err := tcqdrant.RunContainer(context.Background(), testcontainers.WithImage("qdrant/qdrant:v1.11.3"))
qdrantContainer, err := tcqdrant.Run(context.Background(), "qdrant/qdrant:v1.11.3")
if err != nil && strings.Contains(err.Error(), "Cannot connect to the Docker daemon") {
t.Skip("Docker not available")
}
Expand Down
48 changes: 24 additions & 24 deletions vectorstores/redisvector/redis_vector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,27 +487,27 @@ func getEmbedding(model string, connectionStr ...string) (llms.Model, *embedding
return llms.Model(llm), e
}

/**
func runOllamaTestContainer(model string) (*tcollama.OllamaContainer, string) {
ctx := context.Background()
ollamaContainer, err := tcollama.RunContainer(
ctx,
testcontainers.WithImage("ollama/ollama:0.1.31"),
)
if err != nil {
log.Fatalf("failed to start container: %s", err)
}
_, _, err = ollamaContainer.Exec(ctx, []string{"ollama", "pull", model})
if err != nil {
log.Fatalf("failed to pull model %s: %s", model, err)
}
connectionStr, err := ollamaContainer.ConnectionString(ctx)
if err != nil {
log.Fatalf("failed to get connection string: %s", err) // nolint:gocritic
}
return ollamaContainer, connectionStr
}
*/
// /**
// func runOllamaTestContainer(model string) (*tcollama.OllamaContainer, string) {
// ctx := context.Background()

// ollamaContainer, err := tcollama.Run(
// ctx,
// "ollama/ollama:0.1.31",
// )
// if err != nil {
// log.Fatalf("failed to start container: %s", err)
// }

// _, _, err = ollamaContainer.Exec(ctx, []string{"ollama", "pull", model})
// if err != nil {
// log.Fatalf("failed to pull model %s: %s", model, err)
// }

// connectionStr, err := ollamaContainer.ConnectionString(ctx)
// if err != nil {
// log.Fatalf("failed to get connection string: %s", err) // nolint:gocritic
// }
// return ollamaContainer, connectionStr
// }
// */
3 changes: 1 addition & 2 deletions vectorstores/weaviate/weaviate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
tcweaviate "github.com/testcontainers/testcontainers-go/modules/weaviate"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/embeddings"
Expand All @@ -26,7 +25,7 @@ func getValues(t *testing.T) (string, string) {
scheme := os.Getenv("WEAVIATE_SCHEME")
host := os.Getenv("WEAVIATE_HOST")
if scheme == "" || host == "" {
weaviateContainer, err := tcweaviate.RunContainer(context.Background(), testcontainers.WithImage("semitechnologies/weaviate:1.25.4"))
weaviateContainer, err := tcweaviate.Run(context.Background(), "semitechnologies/weaviate:1.25.4")
if err != nil && strings.Contains(err.Error(), "Cannot connect to the Docker daemon") {
t.Skip("Docker not available")
}
Expand Down

0 comments on commit dc82365

Please sign in to comment.