Skip to content

Commit

Permalink
feat: add vector database modules (Qdrant, Weaviate, Chroma, pgvector…
Browse files Browse the repository at this point in the history
…, OpenSearch, Milvus) (#2245)

* fix: add nolint to the examples template

* chore: bootstrap qdrant module

* feat: add container methods for endpoints

REST, gRPC and webUI

* chore: add a full example using the gRPC client

* fix: lint

* fix: use inner t

* chore: reduce network flakines on GH hosted runners

OS-neutral interface to disable TCP/UDP offload to fix flaky networking on GitHub-hosted runners

See https://github.com/smorimoto/tune-github-hosted-runner-network/blob/main/action.yml

* Revert "chore: reduce network flakines on GH hosted runners"

This reverts commit 7ce031e.

* chore: try with daemon host

* chore: hardcode 127.0.0.1 for testing on GH action

* chore: print container logs on error

* Revert "chore: hardcode 127.0.0.1 for testing on GH action"

This reverts commit b602505.

* Revert "chore: try with daemon host"

This reverts commit 67a5abf.

* chore: wait for the listening ports to be available

* feat: new weaviate module

* chore: add default values for the weviate module

* chore: remove helper test method in qdrant

* feat: add method to connect to the REST endpoint of weaviate

* chore: add example for creating an weaviate client

* docs: document weaviate methods

* chore: bootstrap Chroma module

* feat: support for passing env vars to modules

* chore: add container method to get the base URL

* chore: add example on how to connect to Chroma

* docs: document weaviate client

* chore: include heartbeat in the wait strategies

* chore: add example for collections

* Revert "feat: support for passing env vars to modules"

This reverts commit ac97472.

* feat: include pgvector to postgres module

* fix: wrong value

* feat: bootstrap opensearch module

* chore: configure opensearch

* chore: implement options and methods for opensearch

* chore: bootstrap milvus

* chore: improve container lifecycle and defaults for embed etcd

* chore: add full example for creating collections

* fix: lint

* chore: rename to HttpHostAddress
  • Loading branch information
mdelapenya authored Feb 20, 2024
1 parent 91f6f59 commit c84e479
Show file tree
Hide file tree
Showing 45 changed files with 3,740 additions and 8 deletions.
35 changes: 35 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/chroma
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/clickhouse
schedule:
Expand Down Expand Up @@ -149,6 +156,13 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/milvus
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/minio
schedule:
Expand Down Expand Up @@ -205,6 +219,13 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/opensearch
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/postgres
schedule:
Expand All @@ -219,6 +240,13 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/qdrant
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/rabbitmq
schedule:
Expand Down Expand Up @@ -247,3 +275,10 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/weaviate
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
matrix:
go-version: [1.20.x, 1.x]
platform: [ubuntu-latest]
module: [artemis, cassandra, clickhouse, cockroachdb, compose, consul, couchbase, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, postgres, pulsar, rabbitmq, redis, redpanda, vault]
module: [artemis, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, vault, weaviate]
exclude:
- go-version: 1.20.x
module: compose
Expand Down
22 changes: 21 additions & 1 deletion .vscode/.testcontainers-go.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"name": "module / cassandra",
"path": "../modules/cassandra"
},
{
"name": "module / chroma",
"path": "../modules/chroma"
},
{
"name": "module / clickhouse",
"path": "../modules/clickhouse"
Expand Down Expand Up @@ -73,6 +77,10 @@
"name": "module / mariadb",
"path": "../modules/mariadb"
},
{
"name": "module / milvus",
"path": "../modules/milvus"
},
{
"name": "module / minio",
"path": "../modules/minio"
Expand Down Expand Up @@ -105,6 +113,10 @@
"name": "module / openldap",
"path": "../modules/openldap"
},
{
"name": "module / opensearch",
"path": "../modules/opensearch"
},
{
"name": "module / postgres",
"path": "../modules/postgres"
Expand All @@ -113,6 +125,10 @@
"name": "module / pulsar",
"path": "../modules/pulsar"
},
{
"name": "module / qdrant",
"path": "../modules/qdrant"
},
{
"name": "module / rabbitmq",
"path": "../modules/rabbitmq"
Expand All @@ -129,9 +145,13 @@
"name": "module / vault",
"path": "../modules/vault"
},
{
"name": "module / weaviate",
"path": "../modules/weaviate"
},
{
"name": "modulegen",
"path": "../modulegen"
}
]
}
}
84 changes: 84 additions & 0 deletions docs/modules/chroma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Chroma

Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>

## Introduction

The Testcontainers module for Chroma.

## Adding this module to your project dependencies

Please run the following command to add the Chroma module to your Go dependencies:

```
go get github.com/testcontainers/testcontainers-go/modules/chroma
```

## Usage example

<!--codeinclude-->
[Creating a Chroma container](../../modules/chroma/examples_test.go) inside_block:runChromaContainer
<!--/codeinclude-->

## Module reference

The Chroma module exposes one entrypoint function to create the Chroma container, and this function receives two parameters:

```golang
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*ChromaContainer, error)
```

- `context.Context`, the Go context.
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.

### Container Options

When starting the Chroma container, you can pass options in a variadic way to configure it.

#### Image

If you need to set a different Chroma Docker image, you can use `testcontainers.WithImage` with a valid Docker image
for Chroma. E.g. `testcontainers.WithImage("chromadb/chroma:0.4.22.dev44")`.

{% include "../features/common_functional_options.md" %}

### Container Methods

The Chroma container exposes the following methods:

#### REST Endpoint

This method returns the REST endpoint of the Chroma container, using the default `8000` port.

<!--codeinclude-->
[Get REST endpoint](../../modules/chroma/chroma_test.go) inside_block:restEndpoint
<!--/codeinclude-->

## Examples

### Getting a Chroma client

The following example demonstrates how to create a Chroma client using the Chroma module.

First of all, you need to import the Chroma module and the Swagger client:

```golang
import (
chromago "github.com/amikos-tech/chroma-go"
chromaopenapi "github.com/amikos-tech/chroma-go/swagger"
)
```

Then, you can create a Chroma client using the Chroma module:

<!--codeinclude-->
[Get the client](../../modules/chroma/examples_test.go) inside_block:createClient
<!--/codeinclude-->

### Working with Collections

<!--codeinclude-->
[Create Collection](../../modules/chroma/examples_test.go) inside_block:createCollection
[List Collections](../../modules/chroma/examples_test.go) inside_block:listCollections
[Delete Collection](../../modules/chroma/examples_test.go) inside_block:deleteCollection
<!--/codeinclude-->
65 changes: 65 additions & 0 deletions docs/modules/milvus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Milvus

Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>

## Introduction

The Testcontainers module for Milvus.

## Adding this module to your project dependencies

Please run the following command to add the Milvus module to your Go dependencies:

```
go get github.com/testcontainers/testcontainers-go/modules/milvus
```

## Usage example

<!--codeinclude-->
[Creating a Milvus container](../../modules/milvus/examples_test.go) inside_block:runMilvusContainer
<!--/codeinclude-->

## Module reference

The Milvus module exposes one entrypoint function to create the Milvus container, and this function receives two parameters:

```golang
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*MilvusContainer, error)
```

- `context.Context`, the Go context.
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.

### Container Options

When starting the Milvus container, you can pass options in a variadic way to configure it.

#### Image

If you need to set a different Milvus Docker image, you can use `testcontainers.WithImage` with a valid Docker image
for Milvus. E.g. `testcontainers.WithImage("milvusdb/milvus:v2.3.9")`.

{% include "../features/common_functional_options.md" %}

### Container Methods

The Milvus container exposes the following methods:

#### ConnectionString

This method returns the connection string to connect to the Milvus container, using the default `19530` port.

<!--codeinclude-->
[Get connection string](../../modules/milvus/milvus_test.go) inside_block:connectionString
<!--/codeinclude-->

## Examples

### Creating collections

This example shows the usage of the Milvus module to create and retrieve collections.

<!--codeinclude-->
[Create collections](../../modules/milvus/examples_test.go) inside_block:createCollections
<!--/codeinclude-->
67 changes: 67 additions & 0 deletions docs/modules/opensearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# OpenSearch

Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>

## Introduction

The Testcontainers module for OpenSearch.

## Adding this module to your project dependencies

Please run the following command to add the OpenSearch module to your Go dependencies:

```
go get github.com/testcontainers/testcontainers-go/modules/opensearch
```

## Usage example

<!--codeinclude-->
[Creating a OpenSearch container](../../modules/opensearch/examples_test.go) inside_block:runOpenSearchContainer
<!--/codeinclude-->

## Module reference

The OpenSearch module exposes one entrypoint function to create the OpenSearch container, and this function receives two parameters:

```golang
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*OpenSearchContainer, error)
```

- `context.Context`, the Go context.
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.

### Container Options

When starting the OpenSearch container, you can pass options in a variadic way to configure it.

#### Image

If you need to set a different OpenSearch Docker image, you can use `testcontainers.WithImage` with a valid Docker image
for OpenSearch. E.g. `testcontainers.WithImage("opensearchproject/opensearch:2.11.1")`.

{% include "../features/common_functional_options.md" %}

#### User and password

If you need to set a different password to request authorization when performing HTTP requests to the container, you can use the `WithUsername` and `WithPassword` options. By default, the username is set to `admin`, and the password is set to `admin`.

<!--codeinclude-->
[Custom Credentials](../../modules/opensearch/examples_test.go) inside_block:runOpenSearchContainer
<!--/codeinclude-->

### Container Methods

The OpenSearch container exposes the following methods:

#### Address

The `Address` method returns the location where the OpenSearch container is listening.
It returns a string with the format `http://<host>:<port>`.

!!!warning
TLS is not supported at the moment.

<!--codeinclude-->
[Connecting using HTTP](../../modules/opensearch/opensearch_test.go) inside_block:httpConnection
<!--/codeinclude-->
6 changes: 2 additions & 4 deletions docs/modules/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ It's possible to pass extra parameters to the connection string, e.g. `sslmode=d

### Postgres variants

It's possible to use the Postgres container with Timescale or Postgis, to name a few. You simply need to update the image name and the wait strategy.
It's possible to use the Postgres container with PGVector, Timescale or Postgis, to name a few. You simply need to update the image name and the wait strategy.
<!--codeinclude-->
[Image for PGVector](../../modules/postgres/postgres_test.go) inside_block:pgvector
[Image for Timescale](../../modules/postgres/postgres_test.go) inside_block:timescale
<!--/codeinclude-->
<!--codeinclude-->
[Image for Postgis](../../modules/postgres/postgres_test.go) inside_block:postgis
<!--/codeinclude-->
Expand Down
Loading

0 comments on commit c84e479

Please sign in to comment.