mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-06 08:27:04 +08:00
Updated test suites to retry connection to tcp server. Use concurrency to setup cluster in Test_Cluster suite.
This commit is contained in:
@@ -16,18 +16,15 @@ package set_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/echovault/echovault/echovault"
|
||||
"github.com/echovault/echovault/internal"
|
||||
"github.com/echovault/echovault/internal/config"
|
||||
"github.com/echovault/echovault/internal/constants"
|
||||
"github.com/echovault/echovault/internal/modules/set"
|
||||
"github.com/tidwall/resp"
|
||||
"net"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -51,13 +48,9 @@ func Test_Set(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Done()
|
||||
mockServer.Start()
|
||||
}()
|
||||
wg.Wait()
|
||||
|
||||
t.Cleanup(func() {
|
||||
mockServer.ShutDown()
|
||||
@@ -65,7 +58,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSADD", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -213,7 +206,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSCARD", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -340,7 +333,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSDIFF", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -490,7 +483,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSDIFFSTORE", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -672,7 +665,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSINTER", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -822,7 +815,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSINTERCARD", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -977,7 +970,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSINTERSTORE", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1159,7 +1152,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSISMEMBER", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1281,7 +1274,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSMEMBERS", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1408,7 +1401,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSMISMEMBER", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1535,7 +1528,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSMOVE", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1731,7 +1724,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSPOP", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -1873,7 +1866,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSRANDMEMBER", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -2038,7 +2031,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSREM", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -2179,7 +2172,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSUNION", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
@@ -2322,7 +2315,7 @@ func Test_Set(t *testing.T) {
|
||||
|
||||
t.Run("Test_HandleSUNIONSTORE", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||
conn, err := internal.GetConnection("localhost", port)
|
||||
if err != nil {
|
||||
t.Error()
|
||||
return
|
||||
|
Reference in New Issue
Block a user