-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
545 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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--> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include ../../commons-test.mk | ||
|
||
.PHONY: test | ||
test: | ||
$(MAKE) test-vearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => ../.. |
Oops, something went wrong.