summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-11 15:52:11 +0300
committerValery Piashchynski <[email protected]>2021-06-11 15:52:11 +0300
commit4c6a04f16399ab353d81d1820877b764ad2d20c5 (patch)
tree64a257391fd2ee975f31d9c2ead1dcced59d63c7
parentb99bfbe21a0f44b1a16b9110d779719fc637127c (diff)
Update tests
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r--go.mod6
-rw-r--r--go.sum21
-rw-r--r--plugins/websockets/rpc.go5
-rw-r--r--tests/plugins/websockets/websocket_plugin_test.go33
4 files changed, 29 insertions, 36 deletions
diff --git a/go.mod b/go.mod
index ed6eed96..43d207ef 100644
--- a/go.mod
+++ b/go.mod
@@ -16,17 +16,15 @@ require (
github.com/json-iterator/go v1.1.11
github.com/klauspost/compress v1.13.0
github.com/prometheus/client_golang v1.10.0
- github.com/savsgio/gotils v0.0.0-20210316171653-c54912823645 // indirect
github.com/shirou/gopsutil v3.21.3+incompatible
github.com/spf13/viper v1.7.1
// SPIRAL ====
github.com/spiral/endure v1.0.1
github.com/spiral/errors v1.0.11
- github.com/spiral/goridge/v3 v3.1.0
+ github.com/spiral/goridge/v3 v3.1.3
// ===========
github.com/stretchr/testify v1.7.0
- github.com/tklauser/go-sysconf v0.3.4 // indirect
- github.com/valyala/fasthttp v1.24.0 // indirect
+ github.com/tklauser/go-sysconf v0.3.6 // indirect
github.com/valyala/tcplisten v1.0.0
github.com/yookoala/gofast v0.6.0
go.etcd.io/bbolt v1.3.5
diff --git a/go.sum b/go.sum
index 69e4c84d..7205a389 100644
--- a/go.sum
+++ b/go.sum
@@ -354,9 +354,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
+github.com/savsgio/gotils v0.0.0-20200608150037-a5f6f5aef16c h1:2nF5+FZ4/qp7pZVL7fR6DEaSTzuDmNaFTyqp92/hwF8=
github.com/savsgio/gotils v0.0.0-20200608150037-a5f6f5aef16c/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
-github.com/savsgio/gotils v0.0.0-20210316171653-c54912823645 h1:ug9pfpEqVhvazyl1GezkQ9M/XdWsQn3VSx0s4qfH82I=
-github.com/savsgio/gotils v0.0.0-20210316171653-c54912823645/go.mod h1:CN0/b5o0sSBi9K8fZTUamBG5NZXO0I64vTh9L3Mzhn0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shirou/gopsutil v3.21.3+incompatible h1:uenXGGa8ESCQq+dbgtl916dmg6PSAz2cXov0uORQ9v8=
github.com/shirou/gopsutil v3.21.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
@@ -387,11 +386,10 @@ github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
github.com/spiral/endure v1.0.1 h1:JHXHHPDiet5Cfx8i2KiC+ayqACmK5Sw0fxNE/QpIuWM=
github.com/spiral/endure v1.0.1/go.mod h1:+gB0/jI9tXdHgv0x4P9vXLER8fLgwt9a7aPi0QZeJHE=
github.com/spiral/errors v1.0.9/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o=
-github.com/spiral/errors v1.0.10/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o=
github.com/spiral/errors v1.0.11 h1:TGG+t3mNouLuRW54Ph7nHo4X3u4WhbxqEQmnIybi7Go=
github.com/spiral/errors v1.0.11/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o=
-github.com/spiral/goridge/v3 v3.1.0 h1:zbNCQaLj+QyM1e/uQP2RHbiZSlxJJvuLAE7GGA3EeYo=
-github.com/spiral/goridge/v3 v3.1.0/go.mod h1:yL47qBzJ1ic89PpfROyTnLjR9XplaEmvXhnJSrooeGw=
+github.com/spiral/goridge/v3 v3.1.3 h1:mjKLxWBmCN2ZErkA1mTkQAMbYjWQK8cb7DluQA/9wjU=
+github.com/spiral/goridge/v3 v3.1.3/go.mod h1:swcWZW7nP+KU9rgyRf6w7CfNDCWRC/vePE2+AKtoqjk=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
@@ -404,10 +402,10 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
-github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M=
-github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek=
-github.com/tklauser/numcpus v0.2.1 h1:ct88eFm+Q7m2ZfXJdan1xYoXKlmwsfP+k88q05KvlZc=
-github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8=
+github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4=
+github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
+github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
+github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
@@ -415,9 +413,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.14.0/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE=
+github.com/valyala/fasthttp v1.23.0 h1:0ufwSD9BhWa6f8HWdmdq4FHQ23peRo3Ng/Qs8m5NcFs=
github.com/valyala/fasthttp v1.23.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU=
-github.com/valyala/fasthttp v1.24.0 h1:AAiG4oLDUArTb7rYf9oO2bkGooOqCaUF6a2u8asBP3I=
-github.com/valyala/fasthttp v1.24.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
@@ -571,9 +568,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
diff --git a/plugins/websockets/rpc.go b/plugins/websockets/rpc.go
index 80697fa2..341e0b2a 100644
--- a/plugins/websockets/rpc.go
+++ b/plugins/websockets/rpc.go
@@ -41,7 +41,7 @@ func (r *rpc) Publish(in *websocketsv1.Request, out *websocketsv1.Response) erro
}
}
- out.Ok = false
+ out.Ok = true
return nil
}
@@ -63,12 +63,13 @@ func (r *rpc) PublishAsync(in *websocketsv1.Request, out *websocketsv1.Response)
for i := 0; i < msgLen; i++ {
bb, err := proto.Marshal(in.GetMessages()[i])
if err != nil {
+ out.Ok = false
return errors.E(op, err)
}
r.plugin.PublishAsync(bb)
}
- out.Ok = false
+ out.Ok = true
return nil
}
diff --git a/tests/plugins/websockets/websocket_plugin_test.go b/tests/plugins/websockets/websocket_plugin_test.go
index c1fd5f3e..3ef144eb 100644
--- a/tests/plugins/websockets/websocket_plugin_test.go
+++ b/tests/plugins/websockets/websocket_plugin_test.go
@@ -241,7 +241,7 @@ func RPCWsMemoryPubAsync(t *testing.T) {
// subscription done
assert.Equal(t, `{"topic":"@join","payload":["foo","foo2"]}`, retMsg)
- publishAsync("", "memory", "foo")
+ publishAsync(t, "", "memory", "foo")
// VERIFY a makeMessage
_, msg, err = c.ReadMessage()
@@ -266,11 +266,11 @@ func RPCWsMemoryPubAsync(t *testing.T) {
assert.Equal(t, `{"topic":"@leave","payload":["foo"]}`, retMsg)
// TRY TO PUBLISH TO UNSUBSCRIBED TOPIC
- publishAsync("", "memory", "foo")
+ publishAsync(t, "", "memory", "foo")
go func() {
time.Sleep(time.Second * 5)
- publishAsync2("", "memory", "foo2")
+ publishAsync2(t, "", "memory", "foo2")
}()
// should be only makeMessage from the subscribed foo2 topic
@@ -344,7 +344,7 @@ func RPCWsMemory(t *testing.T) {
go func() {
time.Sleep(time.Second * 5)
- publish2("", "memory", "foo2")
+ publish2(t, "", "memory", "foo2")
}()
// should be only makeMessage from the subscribed foo2 topic
@@ -416,7 +416,7 @@ func RPCWsRedis(t *testing.T) {
go func() {
time.Sleep(time.Second * 5)
- publish2("", "redis", "foo2")
+ publish2(t, "", "redis", "foo2")
}()
// should be only makeMessage from the subscribed foo2 topic
@@ -784,7 +784,7 @@ func RPCWsMemoryAllow(t *testing.T) {
go func() {
time.Sleep(time.Second * 5)
- publish2("", "memory", "foo2")
+ publish2(t, "", "memory", "foo2")
}()
// should be only makeMessage from the subscribed foo2 topic
@@ -812,7 +812,7 @@ func publish(command string, broker string, topics ...string) {
}
}
-func publishAsync(command string, broker string, topics ...string) {
+func publishAsync(t *testing.T, command string, broker string, topics ...string) {
conn, err := net.Dial("tcp", "127.0.0.1:6001")
if err != nil {
panic(err)
@@ -822,12 +822,11 @@ func publishAsync(command string, broker string, topics ...string) {
ret := &websocketsv1.Response{}
err = client.Call("websockets.PublishAsync", makeMessage(command, broker, []byte("hello, PHP"), topics...), ret)
- if err != nil {
- panic(err)
- }
+ assert.NoError(t, err)
+ assert.True(t, ret.Ok)
}
-func publishAsync2(command string, broker string, topics ...string) {
+func publishAsync2(t *testing.T, command string, broker string, topics ...string) {
conn, err := net.Dial("tcp", "127.0.0.1:6001")
if err != nil {
panic(err)
@@ -837,12 +836,11 @@ func publishAsync2(command string, broker string, topics ...string) {
ret := &websocketsv1.Response{}
err = client.Call("websockets.PublishAsync", makeMessage(command, broker, []byte("hello, PHP2"), topics...), ret)
- if err != nil {
- panic(err)
- }
+ assert.NoError(t, err)
+ assert.True(t, ret.Ok)
}
-func publish2(command string, broker string, topics ...string) {
+func publish2(t *testing.T, command string, broker string, topics ...string) {
conn, err := net.Dial("tcp", "127.0.0.1:6001")
if err != nil {
panic(err)
@@ -852,9 +850,8 @@ func publish2(command string, broker string, topics ...string) {
ret := &websocketsv1.Response{}
err = client.Call("websockets.Publish", makeMessage(command, broker, []byte("hello, PHP2"), topics...), ret)
- if err != nil {
- panic(err)
- }
+ assert.NoError(t, err)
+ assert.True(t, ret.Ok)
}
func messageWS(command string, broker string, payload []byte, topics ...string) *websocketsv1.Message {
return &websocketsv1.Message{