diff options
author | Valery Piashchynski <[email protected]> | 2021-06-24 15:31:15 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-24 15:31:15 +0300 |
commit | fdff0ffe41b45d0e919eccc683104987898a4faf (patch) | |
tree | 79b242b1af7d283eedfb0ac124e48c5fa47ef461 /tests | |
parent | ce53a8e149b76f15e8a5dd88ac3b953798d57e8b (diff) |
- Add Clear method to the storages
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/broadcast/broadcast_plugin_test.go | 6 | ||||
-rw-r--r-- | tests/plugins/kv/storage_plugin_test.go | 192 |
2 files changed, 196 insertions, 2 deletions
diff --git a/tests/plugins/broadcast/broadcast_plugin_test.go b/tests/plugins/broadcast/broadcast_plugin_test.go index 2cd4b451..0ec813f3 100644 --- a/tests/plugins/broadcast/broadcast_plugin_test.go +++ b/tests/plugins/broadcast/broadcast_plugin_test.go @@ -205,7 +205,8 @@ func TestBroadcastSameSubscriber(t *testing.T) { cfg, &broadcast.Plugin{}, &rpcPlugin.Plugin{}, - mockLogger, + &logger.ZapLogger{}, + // mockLogger, &server.Plugin{}, &redis.Plugin{}, &websockets.Plugin{}, @@ -314,7 +315,8 @@ func TestBroadcastSameSubscriberGlobal(t *testing.T) { cfg, &broadcast.Plugin{}, &rpcPlugin.Plugin{}, - mockLogger, + &logger.ZapLogger{}, + // mockLogger, &server.Plugin{}, &redis.Plugin{}, &websockets.Plugin{}, diff --git a/tests/plugins/kv/storage_plugin_test.go b/tests/plugins/kv/storage_plugin_test.go index 1e466e06..6169fad5 100644 --- a/tests/plugins/kv/storage_plugin_test.go +++ b/tests/plugins/kv/storage_plugin_test.go @@ -575,6 +575,54 @@ func testRPCMethods(t *testing.T) { err = client.Call("kv.Has", keysDel, ret) assert.NoError(t, err) assert.Len(t, ret.GetItems(), 0) + + dataClear := &payload.Request{ + Storage: "boltdb-rr", + Items: []*payload.Item{ + { + Key: "a", + Value: []byte("aa"), + }, + { + Key: "b", + Value: []byte("bb"), + }, + { + Key: "c", + Value: []byte("cc"), + }, + { + Key: "d", + Value: []byte("dd"), + }, + { + Key: "e", + Value: []byte("ee"), + }, + }, + } + + clear := &payload.Request{Storage: "boltdb-rr"} + + ret = &payload.Response{} + // Register 3 keys with values + err = client.Call("kv.Set", dataClear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 5) // should be 5 + + ret = &payload.Response{} + err = client.Call("kv.Clear", clear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 0) // should be 5 + } func TestMemcached(t *testing.T) { @@ -790,6 +838,55 @@ func testRPCMethodsMemcached(t *testing.T) { err = client.Call("kv.Has", keysDel, ret) assert.NoError(t, err) assert.Len(t, ret.GetItems(), 0) + + dataClear := &payload.Request{ + Storage: "memcached-rr", + Items: []*payload.Item{ + { + Key: "a", + Value: []byte("aa"), + }, + { + Key: "b", + Value: []byte("bb"), + }, + { + Key: "c", + Value: []byte("cc"), + }, + { + Key: "d", + Value: []byte("dd"), + }, + { + Key: "e", + Value: []byte("ee"), + }, + }, + } + + clear := &payload.Request{Storage: "memcached-rr"} + + ret = &payload.Response{} + // Register 3 keys with values + err = client.Call("kv.Set", dataClear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 5) // should be 5 + + ret = &payload.Response{} + err = client.Call("kv.Clear", clear, ret) + assert.NoError(t, err) + + time.Sleep(time.Second * 2) + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 0) // should be 5 + } func TestInMemory(t *testing.T) { @@ -1004,6 +1101,54 @@ func testRPCMethodsInMemory(t *testing.T) { err = client.Call("kv.Has", keysDel, ret) assert.NoError(t, err) assert.Len(t, ret.GetItems(), 0) + + dataClear := &payload.Request{ + Storage: "memory-rr", + Items: []*payload.Item{ + { + Key: "a", + Value: []byte("aa"), + }, + { + Key: "b", + Value: []byte("bb"), + }, + { + Key: "c", + Value: []byte("cc"), + }, + { + Key: "d", + Value: []byte("dd"), + }, + { + Key: "e", + Value: []byte("ee"), + }, + }, + } + + clear := &payload.Request{Storage: "memory-rr"} + + ret = &payload.Response{} + // Register 3 keys with values + err = client.Call("kv.Set", dataClear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 5) // should be 5 + + ret = &payload.Response{} + err = client.Call("kv.Clear", clear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 0) // should be 5 + } func TestRedis(t *testing.T) { @@ -1354,4 +1499,51 @@ func testRPCMethodsRedis(t *testing.T) { err = client.Call("kv.Has", keysDel, ret) assert.NoError(t, err) assert.Len(t, ret.GetItems(), 0) + + dataClear := &payload.Request{ + Storage: "redis-rr", + Items: []*payload.Item{ + { + Key: "a", + Value: []byte("aa"), + }, + { + Key: "b", + Value: []byte("bb"), + }, + { + Key: "c", + Value: []byte("cc"), + }, + { + Key: "d", + Value: []byte("dd"), + }, + { + Key: "e", + Value: []byte("ee"), + }, + }, + } + + clear := &payload.Request{Storage: "redis-rr"} + + ret = &payload.Response{} + // Register 3 keys with values + err = client.Call("kv.Set", dataClear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 5) // should be 5 + + ret = &payload.Response{} + err = client.Call("kv.Clear", clear, ret) + assert.NoError(t, err) + + ret = &payload.Response{} + err = client.Call("kv.Has", dataClear, ret) + assert.NoError(t, err) + assert.Len(t, ret.GetItems(), 0) // should be 5 } |