Skip to content

Commit

Permalink
merge with latest, delete cmd_meta
Browse files Browse the repository at this point in the history
  • Loading branch information
iamskp11 committed Dec 10, 2024
2 parents 758035d + dfe05d5 commit 045c698
Show file tree
Hide file tree
Showing 27 changed files with 380 additions and 1,587 deletions.
15 changes: 8 additions & 7 deletions integration_tests/commands/http/command_getkeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ func TestCommandGetKeys(t *testing.T) {
},
expected: []interface{}{[]interface{}{"1 2 3 4 5 6 7"}},
},
{
name: "MSET command",
commands: []HTTPCommand{
{Command: "COMMAND/GETKEYS", Body: map[string]interface{}{"key": "MSET", "keys": []interface{}{"key1 key2"}, "values": []interface{}{" val1 val2"}}},
},
expected: []interface{}{[]interface{}{"key1 key2"}},
},
// Skipping these tests until multishards cmds supported by http
//{
// name: "MSET command",
// commands: []HTTPCommand{
// {Command: "COMMAND/GETKEYS", Body: map[string]interface{}{"key": "MSET", "keys": []interface{}{"key1 key2"}, "values": []interface{}{" val1 val2"}}},
// },
// expected: []interface{}{"ERR invalid command specified"},
//},
{
name: "Expire command",
commands: []HTTPCommand{
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 @@ -883,6 +883,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
229 changes: 115 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,121 @@ 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")}},
},
// Skipping these tests until multishards cmds supported by http
//{
// 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
7 changes: 3 additions & 4 deletions integration_tests/commands/http/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import (
"sync"
"time"

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

"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 +87,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 +118,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
3 changes: 2 additions & 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,8 @@ 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"}},
// TODO: Fix this for multi shard support
//{"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
5 changes: 3 additions & 2 deletions integration_tests/commands/websocket/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"sync"
"time"

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

"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 +118,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 045c698

Please sign in to comment.