Merge branch 'master' into workflow-dev

This commit is contained in:
Bernd Verst 2022-09-16 13:36:13 -07:00 committed by GitHub
commit b8be7ecf5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1640 additions and 29 deletions

View File

@ -48,6 +48,7 @@ jobs:
- state.cassandra
- bindings.alicloud.dubbo
- bindings.kafka
- bindings.redis
- secretstores.local.env
- secretstores.local.file
- bindings.rabbitmq

View File

@ -163,7 +163,7 @@ func (r *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ
if len(keys) == 0 {
var err error
if items, err = r.getAll(ctx); err != nil {
if items, err = r.getAll(ctx, req); err != nil {
return &configuration.GetResponse{}, err
}
} else {
@ -173,8 +173,9 @@ func (r *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ
ctx,
key,
&azappconfig.GetSettingOptions{
Label: to.Ptr("*"),
})
Label: r.getLabelFromMetadata(req.Metadata),
},
)
if err != nil {
return &configuration.GetResponse{}, err
}
@ -196,13 +197,18 @@ func (r *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ
}, nil
}
func (r *ConfigurationStore) getAll(ctx context.Context) (map[string]*configuration.Item, error) {
func (r *ConfigurationStore) getAll(ctx context.Context, req *configuration.GetRequest) (map[string]*configuration.Item, error) {
items := make(map[string]*configuration.Item, 0)
labelFilter := r.getLabelFromMetadata(req.Metadata)
if labelFilter == nil {
labelFilter = to.Ptr("*")
}
revPgr := r.client.NewListRevisionsPager(
azappconfig.SettingSelector{
KeyFilter: to.Ptr("*"),
LabelFilter: to.Ptr("*"),
LabelFilter: labelFilter,
Fields: azappconfig.AllSettingFields(),
},
nil)
@ -228,6 +234,14 @@ func (r *ConfigurationStore) getAll(ctx context.Context) (map[string]*configurat
return items, nil
}
func (r *ConfigurationStore) getLabelFromMetadata(metadata map[string]string) *string {
if s, ok := metadata["label"]; ok && s != "" {
return to.Ptr(s)
}
return nil
}
func (r *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) {
return "", fmt.Errorf("Subscribe is not implemented by this configuration store")
}

View File

@ -26,9 +26,9 @@ git clone https://github.com/dapr/components-contrib.git dapr/components-contrib
### Write new component
1. Create your component directory in the right component directory
2. Copy component files from the reference component to your component directory
3. Add go unit-test for your component
1. Create your component directory in the right component directory.
2. Copy component files from the reference component to your component directory.
3. Add Go unit test files for your component.
4. Add [conformance tests](/tests/conformance/README.md) for your component.
| Type | Directory | Reference | Docs |
@ -54,19 +54,18 @@ make lint
## Validating with Dapr core
1. Make sure you clone the `dapr/dapr` and `dapr/component-contrib` repositories side-by-side
2. Replace github.com/dapr/components-contrib reference to the locally-cloned component-contrib
1. Make sure you clone the `dapr/dapr` and `dapr/components-contrib` repositories side-by-side, within the same folder.
1. Replace `github.com/dapr/components-contrib` with a reference to the locally-cloned `components-contrib`:
```bash
go mod edit -replace github.com/dapr/components-contrib=../components-contrib
```
3. Import your component to dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L33)
4. Register your component in dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L357-L406)(e.g. binding)
5. Build debuggable dapr binary
1. Register your components by creating a file (in the `dapr/dapr` repo) in [`cmd/daprd/components`](https://github.com/dapr/dapr/tree/master/cmd/daprd/components), similar to the ones in the folder (one file per component).
1. Build debuggable dapr binary
```bash
make modtidy-all
make DEBUG=1 build
```
6. Replace the installed daprd with the test binary (then dapr cli will use the test binary)
1. Replace the installed `daprd` with the test binary (the Dapr CLI will then use the test binary):
```bash
# Back up the current daprd
cp ~/.dapr/bin/daprd ~/.dapr/bin/daprd.bak
@ -76,24 +75,24 @@ make lint
> Windows debuggable binary: `.\dist\windows_amd64\debug\daprd`
> macOS (Intel) debuggable binary: `./dist/darwin_amd64/debug/daprd`
> macOS (Apple Silicon) debuggable binary: `./dist/darwin_arm64/debug/daprd`
7. Prepare your test app (e.g. kafka sample app: https://github.com/dapr/quickstarts/tree/master/bindings/nodeapp/)
8. Create YAML for bindings in './components' under app's directory (e.g. kafka example: https://github.com/dapr/quickstarts/blob/master/bindings/components/kafka_bindings.yaml)
9. Run your test app using Dapr cli
10. Make sure your component is loaded successfully in daprd log
1. Prepare your test app (e.g. kafka sample app: https://github.com/dapr/quickstarts/tree/master/bindings/nodeapp/)
1. Create a YAML for the component in './components' under app's directory (e.g. kafka example: https://github.com/dapr/quickstarts/blob/master/bindings/components/kafka_bindings.yaml)
1. Run your test app using Dapr CLI.
1. Make sure your component is loaded successfully in the daprd log.
## Submit your component
1. Create a Pull Request to add your component in [component-contrib](https://github.com/dapr/components-contrib/pulls) repo
2. Get the approval from maintainers
3. Fetch the latest dapr/dapr repo
4. Update component-contrib in dapr/dapr's `go.mod` and ensure that component-contrib is updated to the latest version
1. Get the approval from maintainers
1. Fetch the latest `dapr/dapr` repo
1. Update components-contrib in `dapr/dapr`'s `go.mod` and ensure that `components-contrib` is updated to the latest version
```bash
# In the folder where the dapr/dapr repo was cloned
go get -u github.com/dapr/components-contrib@master
make modtidy-all
```
5. Import your component to dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L33)
6. Register your component in dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L357-L406)(e.g. binding)
7. Create a pullrequest in [dapr/dapr](https://github.com/dapr/dapr/pulls)
1. Register your components by creating a file (in the `dapr/dapr` repo) in [`cmd/daprd/components`](https://github.com/dapr/dapr/tree/master/cmd/daprd/components), similar to the ones in the folder (one file per component).
1. Create a pull request in [dapr/dapr](https://github.com/dapr/dapr/pulls).
## Version 2 and beyond of a component
@ -107,8 +106,7 @@ API versioning of Dapr components follows the same approach as [Go modules](http
In most cases, breaking changes can be avoided by using backward compatible `metadata` fields. When breaking changes cannot be avoided, here are the steps for creating the next major version of a component:
1. Create a version subdirectory for the next major version (e.g. `bindings/redis/v2`, `bindings/redis/v3`, etc.)
2. Copy any code into the new subdirectory that should be preserved from the previous version
3. Submit your component as described in the previous section
4. Import your component to Dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L33) *without removing the package for the previous version*
5. Register your component in Dapr [cmd/daprd/main.go](https://github.com/dapr/dapr/blob/9b07bc23e7321b609b44fe31c554d25a2a4cdcd0/cmd/daprd/main.go#L357-L406) like before, but append its new major version to the name (e.g. `redis/v2`)
6. Validate your component as described previously
1. Copy any code into the new subdirectory that should be preserved from the previous version
1. Submit your component as described in the previous section
1. Register your components by creating a **new** file (in the `dapr/dapr` repo) in [`cmd/daprd/components`](https://github.com/dapr/dapr/tree/master/cmd/daprd/components), *without removing the file for the previous version*. This time, append the new major version to the name, e.g. `redis/v2`.
1. Validate your component as described previously

View File

@ -0,0 +1,24 @@
# RabbitMQ Binding Certification
The purpose of this module is to provide tests that certify the Redis Binding as a stable component.
## Test plan
* Verify that data is getting stored in Redis.
* Create the component spec.
* Run dapr application to store data in Redis component as output binding.
* Ensure that connection to redis is established.
* Read stored data from Redis and verify that the data inserted is present.
* Verify that data is successfully retrieved during a network interruption.
* Create the component spec.
* Run dapr application to store data in Redis component as output binding.
* Insert data in the Redis component as output binding before network interruption.
* Check if the data is accessible after the network is up again.
* Restart the Redis server.
* Check if the data is accessible after the server is up again.
* Verify that the client is able to successfully retry during connection issues.
* Create the component spec.
* Run dapr application to store data in Redis component as output binding.
* Restart the Redis server.
* Insert data into the Redis store as output binding during the server restart.
* Check if the data is accessible after the server is up again.

View File

@ -0,0 +1,22 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redisBinding
initTimeout: 5m
spec:
type: bindings.redis
version: v1
ignoreErrors: true
metadata:
- name: redisHost
value: "localhost:6379"
- name: redisPassword
value: ""
- name: dialTimeout
value: "10s"
- name: redisMaxRetries
value: "5"
- name: redisMinRetryInterval
value: "100ms"
- name: redisMaxRetryInterval
value: "3s"

View File

@ -0,0 +1,12 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redisBinding
spec:
type: bindings.redis
version: v1
metadata:
- name: redisHost
value: "localhost:6379"
- name: redisPassword
value: ""

View File

@ -0,0 +1,4 @@
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: redisbindingconfig

View File

@ -0,0 +1,7 @@
version: "3.3"
services:
redis:
image: 'redislabs/redisearch:latest'
ports:
- '6379:6379'
command: redis-server

View File

@ -0,0 +1,135 @@
module github.com/dapr/components-contrib/tests/certification/bindings/redis
go 1.19
require (
github.com/dapr/components-contrib v1.8.2
github.com/dapr/components-contrib/tests/certification v0.0.0-20220908221803-2b5650c2faa4
github.com/dapr/dapr v1.8.4-0.20220829184035-996cc622ad0c
github.com/dapr/go-sdk v1.4.0
github.com/dapr/kit v0.0.2
github.com/go-redis/redis/v8 v8.11.5
github.com/stretchr/testify v1.8.0
)
require (
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect
github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fasthttp/router v1.3.8 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/cel-go v0.9.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grandcat/zeroconf v0.0.0-20190424104450-85eadb44205c // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/hashicorp/consul/api v1.11.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.9.6 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/openzipkin/zipkin-go v0.4.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.35.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/statsd_exporter v0.22.3 // indirect
github.com/savsgio/gotils v0.0.0-20210217112953-d4a072536008 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/tylertreat/comcast v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.34.0 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.7.0 // indirect
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
golang.org/x/tools v0.1.11 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220622171453-ea41d75dfa0f // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.23.0 // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/apimachinery v0.23.0 // indirect
k8s.io/client-go v0.23.0 // indirect
k8s.io/component-base v0.23.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
sigs.k8s.io/controller-runtime v0.11.0 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
replace github.com/dapr/components-contrib => ../../../..
replace github.com/dapr/components-contrib/tests/certification => ../..
replace github.com/dapr/go-sdk => github.com/hunter007/dapr-go-sdk v1.3.1-0.20220709114046-2f2dc4f9a684
replace github.com/dapr/dapr => github.com/1046102779/dapr v1.5.2-0.20220829014128-56ac94bfadd1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,178 @@
package redisbinding_test
import (
"fmt"
"github.com/dapr/components-contrib/bindings"
bindingRedis "github.com/dapr/components-contrib/bindings/redis"
"github.com/dapr/components-contrib/tests/certification/embedded"
"github.com/dapr/components-contrib/tests/certification/flow"
"github.com/dapr/components-contrib/tests/certification/flow/dockercompose"
"github.com/dapr/components-contrib/tests/certification/flow/network"
"github.com/dapr/components-contrib/tests/certification/flow/retry"
"github.com/dapr/components-contrib/tests/certification/flow/sidecar"
bindingsLoader "github.com/dapr/dapr/pkg/components/bindings"
"github.com/dapr/dapr/pkg/runtime"
daprTesting "github.com/dapr/dapr/pkg/testing"
daprClient "github.com/dapr/go-sdk/client"
"github.com/dapr/kit/logger"
"github.com/go-redis/redis/v8"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
const (
sidecarName = "redisBindingSidecar"
bindingName = "redisBinding"
dockerComposeYAML = "docker-compose.yml"
dataInserted = "Hello: World!"
keyName = "customKey"
)
func TestRedisBinding(t *testing.T) {
log := logger.NewLogger("dapr.components")
ports, _ := daprTesting.GetFreePorts(2)
grpcPort := ports[0]
httpPort := ports[1]
testInvokeCreate := func(ctx flow.Context) error {
client, clientErr := daprClient.NewClientWithPort(fmt.Sprintf("%d", grpcPort))
if clientErr != nil {
panic(clientErr)
}
defer client.Close()
invokeRequest := &daprClient.InvokeBindingRequest{
Name: bindingName,
Operation: string(bindings.CreateOperation),
Data: []byte(dataInserted),
Metadata: map[string]string{"key": keyName},
}
err := client.InvokeOutputBinding(ctx, invokeRequest)
assert.NoError(t, err)
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379", // host:port of the redis server
Password: "", // no password set
DB: 0, // use default DB
})
val, err := rdb.Get(ctx, keyName).Result()
assert.NoError(t, err)
assert.Equal(t, dataInserted, val)
err = rdb.Close()
if err != nil {
return err
}
return nil
}
checkRedisConnection := func(ctx flow.Context) error {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379", // host:port of the redis server
Password: "", // no password set
DB: 0, // use default DB
})
if err := rdb.Ping(ctx).Err(); err != nil {
return nil
} else {
log.Info("Setup for Redis done")
}
err := rdb.Close()
if err != nil {
return err
}
return nil
}
testCheckInsertedData := func(ctx flow.Context) error {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379", // host:port of the redis server
Password: "", // no password set
DB: 0, // use default DB
})
val, err := rdb.Get(ctx, keyName).Result()
assert.NoError(t, err)
assert.Equal(t, dataInserted, val)
err = rdb.Close()
if err != nil {
return err
}
return nil
}
flow.New(t, "Test Redis Output Binding CREATE operation").
Step(dockercompose.Run("redis", dockerComposeYAML)).
Step("Waiting for Redis Readiness...", retry.Do(time.Second*3, 10, checkRedisConnection)).
Step(sidecar.Run(sidecarName,
embedded.WithoutApp(),
embedded.WithComponentsPath("components/standard"),
embedded.WithDaprGRPCPort(grpcPort),
embedded.WithDaprHTTPPort(httpPort),
componentRuntimeOptions(),
)).
Step("Waiting for the component to start", flow.Sleep(10*time.Second)).
Step("Insert data into the redis data store and check if the insertion was successful", testInvokeCreate).
Run()
flow.New(t, "Test Redis Output Binding after reconnecting to network").
Step(dockercompose.Run("redis", dockerComposeYAML)).
Step("Waiting for Redis Readiness...", retry.Do(time.Second*3, 10, checkRedisConnection)).
Step(sidecar.Run(sidecarName,
embedded.WithoutApp(),
embedded.WithComponentsPath("components/standard"),
embedded.WithDaprGRPCPort(grpcPort),
embedded.WithDaprHTTPPort(httpPort),
componentRuntimeOptions(),
)).
Step("Waiting for the component to start", flow.Sleep(10*time.Second)).
Step("Insert data into the redis data store before network interruption", testInvokeCreate).
Step("Interrupt network", network.InterruptNetwork(5*time.Second, nil, nil, "6379:6379")).
Step("Wait for the network to come back up", flow.Sleep(5*time.Second)).
Step("Check if the data is accessible after the network is up again", testCheckInsertedData).
Step("Stop Redis server", dockercompose.Stop("redis", dockerComposeYAML)).
Step("Start Redis server", dockercompose.Start("redis", dockerComposeYAML)).
Step("Waiting for the component to start", flow.Sleep(10*time.Second)).
Step("Check if the data is accessible after server is up again", testCheckInsertedData).
Run()
flow.New(t, "Test Redis Output Binding with retryOptions after restarting Redis").
Step(dockercompose.Run("redis", dockerComposeYAML)).
Step("Waiting for Redis Readiness...", retry.Do(time.Second*3, 10, checkRedisConnection)).
Step(sidecar.Run(sidecarName,
embedded.WithoutApp(),
embedded.WithComponentsPath("components/retryOptions"),
embedded.WithDaprGRPCPort(grpcPort),
embedded.WithDaprHTTPPort(httpPort),
componentRuntimeOptions(),
)).
Step("Waiting for the component to start", flow.Sleep(10*time.Second)).
Step("Stop Redis server", dockercompose.Stop("redis", dockerComposeYAML)).
Step("Start Redis server", dockercompose.Start("redis", dockerComposeYAML)).
//After restarting Redis, it usually takes a couple of seconds for the container to start but
//since we have retry strategies and connection timeouts configured, the client will retry if it is
//not able to establish a connection to the Redis server
Step("Insert data into the redis data store during the server restart", testInvokeCreate).
Step("Check if the data is accessible after the server is up again", testCheckInsertedData).
Run()
}
func componentRuntimeOptions() []runtime.Option {
log := logger.NewLogger("dapr.components")
bindingsRegistry := bindingsLoader.NewRegistry()
bindingsRegistry.Logger = log
bindingsRegistry.RegisterOutputBinding(func(l logger.Logger) bindings.OutputBinding {
return bindingRedis.NewRedis(l)
}, "redis")
return []runtime.Option{
runtime.WithBindings(bindingsRegistry),
}
}