Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vearch module #2560

Merged
merged 11 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
matrix:
go-version: [1.21.x, 1.x]
platform: [ubuntu-latest]
module: [artemis, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, dolt, elasticsearch, gcloud, 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, vault, weaviate]
module: [artemis, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, dolt, elasticsearch, gcloud, 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, vault, vearch, weaviate]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand Down
4 changes: 4 additions & 0 deletions .vscode/.testcontainers-go.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"name": "module / vault",
"path": "../modules/vault"
},
{
"name": "module / vearch",
"path": "../modules/vearch"
},
{
"name": "module / weaviate",
"path": "../modules/weaviate"
Expand Down
57 changes: 57 additions & 0 deletions docs/modules/vearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Vearch

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 Vearch.

## Adding this module to your project dependencies

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

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

## Usage example

<!--codeinclude-->
[Creating a Vearch container](../../modules/vearch/examples_test.go) inside_block:runVearchContainer
<!--/codeinclude-->

## Module reference

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

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

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

### Container Options

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

#### Image

If you need to set a different Vearch Docker image, you can use `testcontainers.WithImage` with a valid Docker image
for Vearch. E.g. `testcontainers.WithImage("vearch/vearch:latest")`.

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

### Container Methods

The Vearch container exposes the following methods:

#### REST Endpoint

This method returns the REST endpoint of the Vearch container, using the default `9001` port.

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


1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ nav:
- modules/registry.md
- modules/surrealdb.md
- modules/vault.md
- modules/vearch.md
- modules/weaviate.md
- Examples:
- examples/index.md
Expand Down
5 changes: 5 additions & 0 deletions modules/vearch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include ../../commons-test.mk

.PHONY: test
test:
$(MAKE) test-vearch
85 changes: 85 additions & 0 deletions modules/vearch/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[global]
# the name will validate join cluster by same name
name = "vearch"
# specify which resources to use to create space
resource_name = "default"
# you data save to disk path ,If you are in a production environment, You'd better set absolute paths
data = ["datas/","datas1/"]
# log path , If you are in a production environment, You'd better set absolute paths
log = "logs/"
# default log type for any model
level = "debug"
# master <-> ps <-> router will use this key to send or receive data
signkey = "secret"
# skip auth for master and router
skip_auth = true
# tell Vearch whether it should manage it's own instance of etcd or not
self_manage_etcd = false
# automatically remove the failed node and recover when new nodes join
auto_recover_ps = false
# support access etcd basic auth,depend on self_manage_etcd = true
support_etcd_auth = false
# ensure leader-follow raft data synchronization is consistent
raft_consistent = false

# self_manage_etcd = true,means manage etcd by yourself,need provide additional configuration
[etcd]
# etcd server ip or domain
address = ["127.0.0.1"]
# advertise_client_urls AND listen_client_urls
etcd_client_port = 2379
# provider username and password,if you turn on auth
user_name = "root"
password = ""

# if you are master you'd better set all config for router and ps and router and ps use default config it so cool
[[masters]]
# name machine name for cluster
name = "m1"
# ip or domain
address = "127.0.0.1"
# api port for http server
api_port = 8817
# port for etcd server
etcd_port = 2378
# listen_peer_urls List of comma separated URLs to listen on for peer traffic.
# advertise_peer_urls List of this member's peer URLs to advertise to the rest of the cluster. The URLs needed to be a comma-separated list.
etcd_peer_port = 2390
# List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
# advertise_client_urls AND listen_client_urls
etcd_client_port = 2370
# init cluster state
cluster_state = "new"
pprof_port = 6062
# monitor
monitor_port = 8818

[router]
# port for server
port = 9001
# rpc_port = 9002
pprof_port = 6061
plugin_path = "plugin"
allow_origins = ["http://google.com"]

[ps]
# port for server
rpc_port = 8081
ps_heartbeat_timeout = 5 # seconds
# raft config begin
raft_heartbeat_port = 8898
raft_replicate_port = 8899
heartbeat-interval = 200 # ms
raft_retain_logs = 20000000
raft_replica_concurrency = 1
raft_snap_concurrency = 1
raft_truncate_count = 500000
# when behind leader this value, will stop the server for search
raft_diff_count = 10000
pprof_port = 6060
# if set true, this ps only use in db meta config
private = false
# seconds
flush_time_interval = 600
flush_count_threshold = 200000
37 changes: 37 additions & 0 deletions modules/vearch/examples_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package vearch_test

import (
"context"
"fmt"
"log"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/vearch"
)

func ExampleRunContainer() {
ctx := context.Background()

vearchContainer, err := vearch.RunContainer(ctx, testcontainers.WithImage("vearch/vearch:latest"))
if err != nil {
log.Fatalf("failed to start container: %s", err)
}

// Clean up the container
defer func() {
if err := vearchContainer.Terminate(ctx); err != nil {
log.Fatalf("failed to terminate container: %s", err) // nolint:gocritic
}
}()
// }

state, err := vearchContainer.State(ctx)
if err != nil {
log.Fatalf("failed to get container state: %s", err) // nolint:gocritic
}

fmt.Println(state.Running)

// Output:
// true
}
57 changes: 57 additions & 0 deletions modules/vearch/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module github.com/testcontainers/testcontainers-go/modules/vearch

go 1.22.0

require github.com/testcontainers/testcontainers-go v0.31.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.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.15 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.5+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.16.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // 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/mod v0.16.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)

replace github.com/testcontainers/testcontainers-go => ../..
Loading