summaryrefslogtreecommitdiff
path: root/tests/plugins/kv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/kv')
-rw-r--r--tests/plugins/kv/configs/.rr-boltdb.yaml21
-rw-r--r--tests/plugins/kv/configs/.rr-in-memory.yaml13
-rw-r--r--tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml24
-rw-r--r--tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml22
-rw-r--r--tests/plugins/kv/configs/.rr-kv-init.yaml49
-rw-r--r--tests/plugins/kv/configs/.rr-memcached.yaml15
-rw-r--r--tests/plugins/kv/configs/.rr-redis-global.yaml14
-rw-r--r--tests/plugins/kv/configs/.rr-redis-no-config.yaml10
-rw-r--r--tests/plugins/kv/configs/.rr-redis.yaml15
-rw-r--r--tests/plugins/kv/storage_plugin_test.go55
10 files changed, 111 insertions, 127 deletions
diff --git a/tests/plugins/kv/configs/.rr-boltdb.yaml b/tests/plugins/kv/configs/.rr-boltdb.yaml
index 81b47715..7a8aee4e 100644
--- a/tests/plugins/kv/configs/.rr-boltdb.yaml
+++ b/tests/plugins/kv/configs/.rr-boltdb.yaml
@@ -1,15 +1,16 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-rr:
- driver: boltdb
- dir: "."
- file: "rr.db"
- bucket: "test"
- permissions: 0666
- interval: 1 # seconds
+ boltdb-rr:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "rr.db"
+ bucket: "test"
+ permissions: 0666
+ interval: 1 # seconds
diff --git a/tests/plugins/kv/configs/.rr-in-memory.yaml b/tests/plugins/kv/configs/.rr-in-memory.yaml
index b3b01f46..0452d8bc 100644
--- a/tests/plugins/kv/configs/.rr-in-memory.yaml
+++ b/tests/plugins/kv/configs/.rr-in-memory.yaml
@@ -1,11 +1,12 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- memory-rr:
- driver: memory
- interval: 1
+ memory-rr:
+ driver: memory
+ config:
+ interval: 1
diff --git a/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml b/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
index 471e5c77..476369c5 100644
--- a/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
@@ -1,17 +1,19 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-south:
- driver: boltdb
- file: "rr.db"
- permissions: 755
+ boltdb-south:
+ driver: boltdb
+ config:
+ file: "rr.db"
+ permissions: 755
- boltdb-africa:
- driver: boltdb
- file: "africa.db"
- permissions: 755
+ boltdb-africa:
+ driver: boltdb
+ config:
+ file: "africa.db"
+ permissions: 755
diff --git a/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml b/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
index b46bcb1c..e7728972 100644
--- a/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
@@ -1,16 +1,18 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-south:
- driver: boltdb
- file: "rr.db"
+ boltdb-south:
+ driver: boltdb
+ config:
+ file: "rr.db"
- boltdb-africa:
- driver: boltdb
- file: "africa.db"
- permissions: 0777
+ boltdb-africa:
+ driver: boltdb
+ config:
+ file: "africa.db"
+ permissions: 0777
diff --git a/tests/plugins/kv/configs/.rr-kv-init.yaml b/tests/plugins/kv/configs/.rr-kv-init.yaml
index 6407c7ad..10cf6491 100644
--- a/tests/plugins/kv/configs/.rr-kv-init.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-init.yaml
@@ -1,30 +1,35 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- default:
- driver: memory
+ default:
+ driver: memory
+ config:
+ interval: 60
- boltdb-south:
- driver: boltdb
- dir: "."
- file: "rr.db"
- bucket: "rr"
- permissions: 0666
- interval: 1
+ boltdb-south:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "rr.db"
+ bucket: "rr"
+ permissions: 0666
+ interval: 1
- boltdb-africa:
- driver: boltdb
- dir: "."
- file: "africa.db"
- bucket: "rr"
- permissions: 0666
- interval: 1
+ boltdb-africa:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "africa.db"
+ bucket: "rr"
+ permissions: 0666
+ interval: 1
- memcached:
- driver: memcached
- addr: [ "127.0.0.1:11211" ]
+ memcached:
+ driver: memcached
+ config:
+ addr: ["127.0.0.1:11211"]
diff --git a/tests/plugins/kv/configs/.rr-memcached.yaml b/tests/plugins/kv/configs/.rr-memcached.yaml
index da5d59c6..ef8de2ab 100644
--- a/tests/plugins/kv/configs/.rr-memcached.yaml
+++ b/tests/plugins/kv/configs/.rr-memcached.yaml
@@ -1,12 +1,13 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- memcached-rr:
- driver: memcached
- addr:
- - "127.0.0.1:11211"
+ memcached-rr:
+ driver: memcached
+ config:
+ addr:
+ - "127.0.0.1:11211"
diff --git a/tests/plugins/kv/configs/.rr-redis-global.yaml b/tests/plugins/kv/configs/.rr-redis-global.yaml
index a4979879..27377835 100644
--- a/tests/plugins/kv/configs/.rr-redis-global.yaml
+++ b/tests/plugins/kv/configs/.rr-redis-global.yaml
@@ -1,14 +1,14 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
redis-rr:
- addrs:
- - '127.0.0.1:6379'
+ addrs:
+ - "127.0.0.1:6379"
kv:
- redis-rr:
- driver: redis
+ redis-rr:
+ driver: redis
diff --git a/tests/plugins/kv/configs/.rr-redis-no-config.yaml b/tests/plugins/kv/configs/.rr-redis-no-config.yaml
index 9cf06374..56113f13 100644
--- a/tests/plugins/kv/configs/.rr-redis-no-config.yaml
+++ b/tests/plugins/kv/configs/.rr-redis-no-config.yaml
@@ -1,10 +1,10 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- redis-rr:
- driver: redis
+ redis-rr:
+ driver: redis
diff --git a/tests/plugins/kv/configs/.rr-redis.yaml b/tests/plugins/kv/configs/.rr-redis.yaml
index 522e365a..f9b967d5 100644
--- a/tests/plugins/kv/configs/.rr-redis.yaml
+++ b/tests/plugins/kv/configs/.rr-redis.yaml
@@ -1,12 +1,13 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- redis-rr:
- driver: redis
- addrs:
- - '127.0.0.1:6379'
+ redis-rr:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6379"
diff --git a/tests/plugins/kv/storage_plugin_test.go b/tests/plugins/kv/storage_plugin_test.go
index e757a9e6..c10e4726 100644
--- a/tests/plugins/kv/storage_plugin_test.go
+++ b/tests/plugins/kv/storage_plugin_test.go
@@ -10,6 +10,7 @@ import (
"testing"
"time"
+ "github.com/golang/mock/gomock"
endure "github.com/spiral/endure/pkg/container"
goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc"
"github.com/spiral/roadrunner/v2/plugins/boltdb"
@@ -21,6 +22,7 @@ import (
"github.com/spiral/roadrunner/v2/plugins/redis"
rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc"
payload "github.com/spiral/roadrunner/v2/proto/kv/v1beta"
+ "github.com/spiral/roadrunner/v2/tests/mocks"
"github.com/stretchr/testify/assert"
)
@@ -1293,12 +1295,21 @@ func TestRedisNoConfig(t *testing.T) {
Prefix: "rr",
}
+ controller := gomock.NewController(t)
+ mockLogger := mocks.NewMockLogger(controller)
+
+ mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes()
+ mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes()
+ mockLogger.EXPECT().Debug("Started RPC service", "address", "tcp://127.0.0.1:6001", "plugins", []string{"kv"}).AnyTimes()
+
+ mockLogger.EXPECT().Error(`can't find local or global configuration, this section will be skipped`, "local: ", "kv.redis-rr.config", "global: ", "redis-rr").Times(1)
+
err = cont.RegisterAll(
cfg,
&kv.Plugin{},
&redis.Plugin{},
&rpcPlugin.Plugin{},
- &logger.ZapLogger{},
+ mockLogger,
&memory.Plugin{},
)
assert.NoError(t, err)
@@ -1308,48 +1319,8 @@ func TestRedisNoConfig(t *testing.T) {
t.Fatal(err)
}
- ch, err := cont.Serve()
+ _, err = cont.Serve()
assert.NoError(t, err)
-
- sig := make(chan os.Signal, 1)
- signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
-
- wg := &sync.WaitGroup{}
- wg.Add(1)
-
- stopCh := make(chan struct{}, 1)
-
- go func() {
- defer wg.Done()
- for {
- select {
- case e := <-ch:
- assert.Fail(t, "error", e.Error.Error())
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- case <-sig:
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- case <-stopCh:
- // timeout
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- }
- }
- }()
-
- time.Sleep(time.Second * 1)
- t.Run("REDIS", testRPCMethodsRedis)
- stopCh <- struct{}{}
- wg.Wait()
}
func testRPCMethodsRedis(t *testing.T) {