Skip to content

Commit

Permalink
Disabled multishard cmds and test for HTTP/WS
Browse files Browse the repository at this point in the history
  • Loading branch information
lucifercr07 committed Dec 7, 2024
1 parent 66a9f33 commit 612e7c3
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 1,442 deletions.
2 changes: 1 addition & 1 deletion integration_tests/commands/http/command_getkeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestCommandGetKeys(t *testing.T) {
commands: []HTTPCommand{
{Command: "COMMAND/GETKEYS", Body: map[string]interface{}{"key": "MSET", "keys": []interface{}{"key1 key2"}, "values": []interface{}{" val1 val2"}}},
},
expected: []interface{}{[]interface{}{"key1 key2"}},
expected: []interface{}{"ERR invalid command specified"},
},
{
name: "Expire command",
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/command_rename_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/copy_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/dbsize_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
1 change: 1 addition & 0 deletions integration_tests/commands/http/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ func TestJsonStrlen(t *testing.T) {
}

func TestJSONMGET(t *testing.T) {
t.Skip("Skipping this test until multishards cmds supported by http")
exec := NewHTTPCommandExecutor()
setupData := map[string]string{
"xx": `["hehhhe","hello"]`,
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/keys_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/mget_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/mset_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/object_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
228 changes: 114 additions & 114 deletions integration_tests/commands/http/set_data_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,120 +159,120 @@ func TestSetDataCmd(t *testing.T) {
assert_type: []string{"equal", "array", "equal", "array"},
expected: []interface{}{float64(3), []any{string("bar"), string("baz"), string("bax")}, float64(0), []any{string("bar"), string("baz"), string("bax")}},
},
{
name: "SADD & SDIFF",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "baz"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "bax"}},
{Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), float64(1), float64(1), []any{string("bar")}},
},
{
name: "SADD & SDIFF with non-existing subsequent key",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
},
{
name: "SADD & SDIFF with wrong key type",
commands: []HTTPCommand{
{Command: "SET", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal"},
expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
},
{
name: "SADD & SDIFF with subsequent key of wrong type",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SET", Body: map[string]interface{}{"key": "foo2", "value": "bar"}},
{Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "equal", "equal"},
expected: []interface{}{float64(1), float64(1), "OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
},
{
name: "SADD & SDIFF with non-existing first key",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SDIFF", Body: map[string]interface{}{"key1": "foo2", "key2": "foo"}},
},
assert_type: []string{"equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), []any{}},
},
{
name: "SADD & SDIFF with one key",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SDIFF", Body: map[string]interface{}{"key": "foo"}},
},
assert_type: []string{"equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
},
{
name: "SADD & SINTER",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "baz"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "bax"}},
{Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), float64(1), float64(1), []any{string("baz")}},
},
{
name: "SADD & SINTER with non-existing subsequent key",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), []any{}},
},
{
name: "SADD & SINTER with wrong key type",
commands: []HTTPCommand{
{Command: "SET", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal"},
expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
},
{
name: "SADD & SINTER with subsequent key of wrong type",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SET", Body: map[string]interface{}{"key": "foo2", "value": "bar"}},
{Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
},
assert_type: []string{"equal", "equal", "equal", "equal"},
expected: []interface{}{float64(1), float64(1), "OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
},
{
name: "SADD & SINTER with single key",
commands: []HTTPCommand{
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
{Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
{Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo"}}},
},
assert_type: []string{"equal", "equal", "array"},
expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
},
//{
// name: "SADD & SDIFF",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "baz"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "bax"}},
// {Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), float64(1), float64(1), []any{string("bar")}},
//},
//{
// name: "SADD & SDIFF with non-existing subsequent key",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
//},
//{
// name: "SADD & SDIFF with wrong key type",
// commands: []HTTPCommand{
// {Command: "SET", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal"},
// expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
//},
//{
// name: "SADD & SDIFF with subsequent key of wrong type",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SET", Body: map[string]interface{}{"key": "foo2", "value": "bar"}},
// {Command: "SDIFF", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "equal", "equal"},
// expected: []interface{}{float64(1), float64(1), "OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
//},
//{
// name: "SADD & SDIFF with non-existing first key",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SDIFF", Body: map[string]interface{}{"key1": "foo2", "key2": "foo"}},
// },
// assert_type: []string{"equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), []any{}},
//},
//{
// name: "SADD & SDIFF with one key",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SDIFF", Body: map[string]interface{}{"key": "foo"}},
// },
// assert_type: []string{"equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
//},
//{
// name: "SADD & SINTER",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "baz"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo2", "value": "bax"}},
// {Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), float64(1), float64(1), []any{string("baz")}},
//},
//{
// name: "SADD & SINTER with non-existing subsequent key",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), []any{}},
//},
//{
// name: "SADD & SINTER with wrong key type",
// commands: []HTTPCommand{
// {Command: "SET", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal"},
// expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
//},
//{
// name: "SADD & SINTER with subsequent key of wrong type",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SET", Body: map[string]interface{}{"key": "foo2", "value": "bar"}},
// {Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo", "foo2"}}},
// },
// assert_type: []string{"equal", "equal", "equal", "equal"},
// expected: []interface{}{float64(1), float64(1), "OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
//},
//{
// name: "SADD & SINTER with single key",
// commands: []HTTPCommand{
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "bar"}},
// {Command: "SADD", Body: map[string]interface{}{"key": "foo", "value": "baz"}},
// {Command: "SINTER", Body: map[string]interface{}{"values": []interface{}{"foo"}}},
// },
// assert_type: []string{"equal", "equal", "array"},
// expected: []interface{}{float64(1), float64(1), []any{string("bar"), string("baz")}},
//},
}

defer exec.FireCommand(HTTPCommand{
Expand Down
8 changes: 3 additions & 5 deletions integration_tests/commands/http/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/dicedb/dice/internal/server/httpws"
"log"
"net/http"
"strings"
"sync"
"time"

"github.com/dicedb/dice/internal/server/utils"

"github.com/dicedb/dice/config"
derrors "github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/querymanager"
"github.com/dicedb/dice/internal/server"
"github.com/dicedb/dice/internal/shard"
dstore "github.com/dicedb/dice/internal/store"
)
Expand Down Expand Up @@ -88,7 +86,7 @@ func (e *HTTPCommandExecutor) FireCommand(cmd HTTPCommand) (interface{}, error)
defer resp.Body.Close()

if cmd.Command != "Q.WATCH" {
var result utils.HTTPResponse
var result httpws.HTTPResponse
err = json.NewDecoder(resp.Body).Decode(&result)
if err != nil {
return nil, err
Expand Down Expand Up @@ -119,7 +117,7 @@ func RunHTTPServer(ctx context.Context, wg *sync.WaitGroup, opt TestServerOption
queryWatcherLocal := querymanager.NewQueryManager()
config.DiceConfig.HTTP.Port = opt.Port
// Initialize the HTTPServer
testServer := server.NewHTTPServer(shardManager, nil)
testServer := httpws.NewHTTPServer(shardManager, nil)
// Inform the user that the server is starting
fmt.Println("Starting the test server on port", config.DiceConfig.HTTP.Port)
shardManagerCtx, cancelShardManager := context.WithCancel(ctx)
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/commands/http/touch_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build ignore
// +build ignore

// Ignored as multishard commands not supported by HTTP
package http

import (
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/resp/command_getkeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var getKeysTestCases = []struct {
{"Get command", "get key", []interface{}{"key"}},
{"TTL command", "ttl key", []interface{}{"key"}},
{"Del command", "del 1 2 3 4 5 6", []interface{}{"1", "2", "3", "4", "5", "6"}},
{"MSET command", "MSET key1 val1 key2 val2", []interface{}{"key1", "key2"}},
//{"MSET command", "MSET key1 val1 key2 val2", []interface{}{"key1", "key2"}},
{"Expire command", "expire key time extra", []interface{}{"key"}},
{"Ping command", "ping", "ERR the command has no key arguments"},
{"Invalid Get command", "get", "ERR invalid number of arguments specified for command"},
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/commands/websocket/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/dicedb/dice/internal/server/httpws"
"log"
"log/slog"
"net/http"
Expand All @@ -14,7 +15,6 @@ import (
"github.com/dicedb/dice/config"
derrors "github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/querymanager"
"github.com/dicedb/dice/internal/server"
"github.com/dicedb/dice/internal/shard"
dstore "github.com/dicedb/dice/internal/store"
"github.com/gorilla/websocket"
Expand Down Expand Up @@ -117,7 +117,7 @@ func RunWebsocketServer(ctx context.Context, wg *sync.WaitGroup, opt TestServerO
shardManager := shard.NewShardManager(1, watchChan, nil, globalErrChannel)
queryWatcherLocal := querymanager.NewQueryManager()
config.DiceConfig.WebSocket.Port = opt.Port
testServer := server.NewWebSocketServer(shardManager, testPort1, nil)
testServer := httpws.NewWebSocketServer(shardManager, testPort1, nil)
shardManagerCtx, cancelShardManager := context.WithCancel(ctx)

// run shard manager
Expand Down
Loading

0 comments on commit 612e7c3

Please sign in to comment.