From dac7403e32ee8250ad3e57fbf55d54ddf6a0e2aa Mon Sep 17 00:00:00 2001
From: binary_ho
Date: Sun, 1 Sep 2024 03:11:23 +0900
Subject: [PATCH 01/13] Add temporary comment for measure ci time
---
server/backend/database/testcases/testcases.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index 2108f8c83..c7be1c48f 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -47,6 +47,7 @@ const (
)
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
+// TODO(binary-ho) : temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
From b7364ef0ed741e2279d4e8344ba69be82aa56a94 Mon Sep 17 00:00:00 2001
From: binary_ho
Date: Sun, 1 Sep 2024 03:33:59 +0900
Subject: [PATCH 02/13] Remove unnecessary 'Get tools dependencies' step from
bench, sharding-test jobs
---
.github/workflows/ci.yml | 6 ------
1 file changed, 6 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 049944a6b..a73cfc1be 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -109,9 +109,6 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
- - name: Get tools dependencies
- run: make tools
-
- name: Stack
run: docker compose -f build/docker/docker-compose.yml up --build -d
@@ -153,9 +150,6 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
- - name: Get tools dependencies
- run: make tools
-
- name: Check Docker Compose Version
run: docker compose --version
From c90561ad07dd7cd36fd8c3ef66e05453a184fc56 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Sun, 1 Sep 2024 14:56:07 +0900
Subject: [PATCH 03/13] Set integration test to run in parallel
---
server/backend/database/testcases/testcases.go | 2 +-
test/integration/admin_test.go | 2 ++
test/integration/array_test.go | 6 ++++++
test/integration/client_test.go | 5 +++++
test/integration/counter_test.go | 2 ++
test/integration/document_test.go | 4 ++++
test/integration/gc_test.go | 2 ++
test/integration/health_test.go | 6 ++++++
test/integration/history_test.go | 2 ++
test/integration/housekeeping_test.go | 2 ++
test/integration/object_test.go | 8 ++++++++
test/integration/presence_test.go | 2 ++
test/integration/primitive_test.go | 2 ++
test/integration/restapi_test.go | 4 ++++
test/integration/retention_test.go | 2 ++
test/integration/server_test.go | 1 +
test/integration/snapshot_test.go | 2 ++
test/integration/text_test.go | 2 ++
test/integration/tree_concurrency_test.go | 10 ++++++++++
test/integration/tree_test.go | 2 ++
test/integration/user_test.go | 2 ++
21 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index c7be1c48f..006914f59 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -47,7 +47,7 @@ const (
)
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
-// TODO(binary-ho) : temporary comment for measure CI test time
+// TODO(binary-ho): temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
diff --git a/test/integration/admin_test.go b/test/integration/admin_test.go
index 6d77773b8..be8903f75 100644
--- a/test/integration/admin_test.go
+++ b/test/integration/admin_test.go
@@ -36,6 +36,8 @@ import (
)
func TestAdmin(t *testing.T) {
+ t.Parallel()
+
ctx := context.Background()
adminCli, err := admin.Dial(defaultServer.RPCAddr(), admin.WithInsecure(true))
diff --git a/test/integration/array_test.go b/test/integration/array_test.go
index 5d41db06b..12f71b114 100644
--- a/test/integration/array_test.go
+++ b/test/integration/array_test.go
@@ -34,6 +34,8 @@ import (
)
func TestArray(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
@@ -328,6 +330,8 @@ func TestArray(t *testing.T) {
}
func TestArraySetTypeGuard(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -385,6 +389,8 @@ func TestArraySetTypeGuard(t *testing.T) {
}
func TestArraySet(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/client_test.go b/test/integration/client_test.go
index 3e9593d7e..6d1a9edc9 100644
--- a/test/integration/client_test.go
+++ b/test/integration/client_test.go
@@ -37,6 +37,7 @@ import (
func TestClient(t *testing.T) {
t.Run("dial and close test", func(t *testing.T) {
+ t.Parallel()
cli, err := client.Dial(defaultServer.RPCAddr())
assert.NoError(t, err)
@@ -47,6 +48,7 @@ func TestClient(t *testing.T) {
})
t.Run("activate/deactivate test", func(t *testing.T) {
+ t.Parallel()
cli, err := client.Dial(defaultServer.RPCAddr())
assert.NoError(t, err)
defer func() {
@@ -76,6 +78,7 @@ func TestClient(t *testing.T) {
})
t.Run("sync option with multiple clients test", func(t *testing.T) {
+ t.Parallel()
clients := activeClients(t, 3)
defer deactivateAndCloseClients(t, clients)
c1, c2, c3 := clients[0], clients[1], clients[2]
@@ -131,6 +134,7 @@ func TestClient(t *testing.T) {
})
t.Run("sync option with mixed mode test", func(t *testing.T) {
+ t.Parallel()
clients := activeClients(t, 1)
defer deactivateAndCloseClients(t, clients)
cli := clients[0]
@@ -176,6 +180,7 @@ func TestClient(t *testing.T) {
})
t.Run("deactivated client's stream test", func(t *testing.T) {
+ t.Parallel()
ctx := context.Background()
c1, err := client.Dial(defaultServer.RPCAddr())
diff --git a/test/integration/counter_test.go b/test/integration/counter_test.go
index 4971c88e5..7075c66c6 100644
--- a/test/integration/counter_test.go
+++ b/test/integration/counter_test.go
@@ -33,6 +33,8 @@ import (
)
func TestCounter(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/document_test.go b/test/integration/document_test.go
index 2451723d7..5986c11da 100644
--- a/test/integration/document_test.go
+++ b/test/integration/document_test.go
@@ -39,6 +39,8 @@ import (
)
func TestDocument(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 3)
c1, c2, c3 := clients[0], clients[1], clients[2]
defer deactivateAndCloseClients(t, clients)
@@ -689,6 +691,8 @@ func TestDocument(t *testing.T) {
}
func TestDocumentWithProjects(t *testing.T) {
+ t.Parallel()
+
ctx := context.Background()
adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr())
defer func() { adminCli.Close() }()
diff --git a/test/integration/gc_test.go b/test/integration/gc_test.go
index 0713abd4f..ca1801794 100644
--- a/test/integration/gc_test.go
+++ b/test/integration/gc_test.go
@@ -35,6 +35,8 @@ import (
)
func TestGarbageCollection(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/health_test.go b/test/integration/health_test.go
index 02e5fdffc..2de1704b5 100644
--- a/test/integration/health_test.go
+++ b/test/integration/health_test.go
@@ -40,6 +40,8 @@ var services = []string{
}
func TestRPCHealthCheck(t *testing.T) {
+ t.Parallel()
+
conn, err := grpc.Dial(
defaultServer.RPCAddr(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -79,6 +81,8 @@ func TestRPCHealthCheck(t *testing.T) {
}
func TestHTTPGETHealthCheck(t *testing.T) {
+ t.Parallel()
+
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Get("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
@@ -125,6 +129,8 @@ func TestHTTPGETHealthCheck(t *testing.T) {
}
func TestHTTPHEADHealthCheck(t *testing.T) {
+ t.Parallel()
+
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Head("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
diff --git a/test/integration/history_test.go b/test/integration/history_test.go
index 52c059518..9eede0bd7 100644
--- a/test/integration/history_test.go
+++ b/test/integration/history_test.go
@@ -31,6 +31,8 @@ import (
)
func TestHistory(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
cli := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/housekeeping_test.go b/test/integration/housekeeping_test.go
index add1a9a93..b7591945b 100644
--- a/test/integration/housekeeping_test.go
+++ b/test/integration/housekeeping_test.go
@@ -70,6 +70,8 @@ func setupBackend(t *testing.T) *backend.Backend {
}
func TestHousekeeping(t *testing.T) {
+ t.Parallel()
+
be := setupBackend(t)
defer func() {
assert.NoError(t, be.Shutdown())
diff --git a/test/integration/object_test.go b/test/integration/object_test.go
index 374953c76..1e383131e 100644
--- a/test/integration/object_test.go
+++ b/test/integration/object_test.go
@@ -34,6 +34,8 @@ import (
)
func TestObject(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
@@ -359,6 +361,8 @@ func TestObject(t *testing.T) {
}
func TestObjectTypeGuard(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -419,6 +423,8 @@ func TestObjectTypeGuard(t *testing.T) {
}
func TestObjectSetCycle(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -481,6 +487,8 @@ func TestObjectSetCycle(t *testing.T) {
}
func TestObjectSet(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/presence_test.go b/test/integration/presence_test.go
index 9f0a8e891..cef4778bf 100644
--- a/test/integration/presence_test.go
+++ b/test/integration/presence_test.go
@@ -38,6 +38,8 @@ import (
)
func TestPresence(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/primitive_test.go b/test/integration/primitive_test.go
index 747eb598a..08f58c224 100644
--- a/test/integration/primitive_test.go
+++ b/test/integration/primitive_test.go
@@ -32,6 +32,8 @@ import (
)
func TestPrimitive(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/restapi_test.go b/test/integration/restapi_test.go
index 18926c209..aa836d85e 100644
--- a/test/integration/restapi_test.go
+++ b/test/integration/restapi_test.go
@@ -44,6 +44,7 @@ type documentSummary struct {
func TestRESTAPI(t *testing.T) {
t.Run("document retrieval test", func(t *testing.T) {
+ t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -58,6 +59,7 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("bulk document retrieval test", func(t *testing.T) {
+ t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -72,6 +74,7 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("list documents test", func(t *testing.T) {
+ t.Parallel()
project, _ := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -86,6 +89,7 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("search documents test", func(t *testing.T) {
+ t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
diff --git a/test/integration/retention_test.go b/test/integration/retention_test.go
index a8662bc98..83a00c30c 100644
--- a/test/integration/retention_test.go
+++ b/test/integration/retention_test.go
@@ -40,6 +40,8 @@ import (
)
func TestRetention(t *testing.T) {
+ t.Parallel()
+
var b *background.Background
patch, err := monkey.PatchInstanceMethodByName(
reflect.TypeOf(b),
diff --git a/test/integration/server_test.go b/test/integration/server_test.go
index 30dc03d5e..23f331cb4 100644
--- a/test/integration/server_test.go
+++ b/test/integration/server_test.go
@@ -33,6 +33,7 @@ import (
func TestServer(t *testing.T) {
t.Run("closing WatchDocument stream on server shutdown test", func(t *testing.T) {
+ t.Parallel()
ctx := context.Background()
svr := helper.TestServer()
assert.NoError(t, svr.Start())
diff --git a/test/integration/snapshot_test.go b/test/integration/snapshot_test.go
index 25ea67589..f7503b8cb 100644
--- a/test/integration/snapshot_test.go
+++ b/test/integration/snapshot_test.go
@@ -36,6 +36,8 @@ import (
)
func TestSnapshot(t *testing.T) {
+ t.Parallel()
+
var b *background.Background
patch, err := monkey.PatchInstanceMethodByName(
reflect.TypeOf(b),
diff --git a/test/integration/text_test.go b/test/integration/text_test.go
index 890c4857f..ab66f620a 100644
--- a/test/integration/text_test.go
+++ b/test/integration/text_test.go
@@ -31,6 +31,8 @@ import (
)
func TestText(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/tree_concurrency_test.go b/test/integration/tree_concurrency_test.go
index b342bebcb..6416bad84 100644
--- a/test/integration/tree_concurrency_test.go
+++ b/test/integration/tree_concurrency_test.go
@@ -261,6 +261,8 @@ func TestTreeConcurrencyEditEdit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// a b c
d e f
g h i
+ t.Parallel()
+
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -330,6 +332,8 @@ func TestTreeConcurrencySplitSplit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//
a b c d
e f g h
i j k l
+ t.Parallel()
+
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -377,6 +381,8 @@ func TestTreeConcurrencySplitEdit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//
a b c d
e f g h
i j k l
+ t.Parallel()
+
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -440,6 +446,8 @@ func TestTreeConcurrencyStyleStyle(t *testing.T) {
// 3,6 : |----------|
// 6,9 : |----------|
+ t.Parallel()
+
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -480,6 +488,8 @@ func TestTreeConcurrencyEditStyle(t *testing.T) {
// 3,6 : |----------|
// 6,9 : |----------|
+ t.Parallel()
+
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go
index 54e1067c0..49024d557 100644
--- a/test/integration/tree_test.go
+++ b/test/integration/tree_test.go
@@ -34,6 +34,8 @@ import (
)
func TestTree(t *testing.T) {
+ t.Parallel()
+
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/user_test.go b/test/integration/user_test.go
index 304f6c168..7157bb49e 100644
--- a/test/integration/user_test.go
+++ b/test/integration/user_test.go
@@ -29,6 +29,8 @@ import (
)
func TestUser(t *testing.T) {
+ t.Parallel()
+
adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr())
defer func() { adminCli.Close() }()
From a9b6a2d5a7f7f206f0f7c01d6e30f3b52378c65d Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Sun, 1 Sep 2024 16:00:39 +0900
Subject: [PATCH 04/13] Set healthcheck test to run in non parallel
---
test/integration/health_test.go | 6 ------
1 file changed, 6 deletions(-)
diff --git a/test/integration/health_test.go b/test/integration/health_test.go
index 2de1704b5..02e5fdffc 100644
--- a/test/integration/health_test.go
+++ b/test/integration/health_test.go
@@ -40,8 +40,6 @@ var services = []string{
}
func TestRPCHealthCheck(t *testing.T) {
- t.Parallel()
-
conn, err := grpc.Dial(
defaultServer.RPCAddr(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -81,8 +79,6 @@ func TestRPCHealthCheck(t *testing.T) {
}
func TestHTTPGETHealthCheck(t *testing.T) {
- t.Parallel()
-
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Get("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
@@ -129,8 +125,6 @@ func TestHTTPGETHealthCheck(t *testing.T) {
}
func TestHTTPHEADHealthCheck(t *testing.T) {
- t.Parallel()
-
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Head("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
From 9cafb215ef52bd8abda793f89b976f4fbc4419c0 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Wed, 4 Sep 2024 23:21:21 +0900
Subject: [PATCH 05/13] Revert "Set Test Parallel to integration package test"
This reverts commit 52289f690f249932627a12272157002ac46dc3db.
---
test/integration/health_test.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/integration/health_test.go b/test/integration/health_test.go
index 02e5fdffc..2de1704b5 100644
--- a/test/integration/health_test.go
+++ b/test/integration/health_test.go
@@ -40,6 +40,8 @@ var services = []string{
}
func TestRPCHealthCheck(t *testing.T) {
+ t.Parallel()
+
conn, err := grpc.Dial(
defaultServer.RPCAddr(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -79,6 +81,8 @@ func TestRPCHealthCheck(t *testing.T) {
}
func TestHTTPGETHealthCheck(t *testing.T) {
+ t.Parallel()
+
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Get("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
@@ -125,6 +129,8 @@ func TestHTTPGETHealthCheck(t *testing.T) {
}
func TestHTTPHEADHealthCheck(t *testing.T) {
+ t.Parallel()
+
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Head("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
From 4a6f430fcc12d5f206d3c9bbeebe0517a8887b6f Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Wed, 4 Sep 2024 23:26:07 +0900
Subject: [PATCH 06/13] Revert "Set integration test to run in parallel"
This reverts commit 15b2748631015efb616237d9d4d65f8c2095164d.
---
server/backend/database/testcases/testcases.go | 2 +-
test/integration/admin_test.go | 2 --
test/integration/array_test.go | 6 ------
test/integration/client_test.go | 5 -----
test/integration/counter_test.go | 2 --
test/integration/document_test.go | 4 ----
test/integration/gc_test.go | 2 --
test/integration/health_test.go | 6 ------
test/integration/history_test.go | 2 --
test/integration/housekeeping_test.go | 2 --
test/integration/object_test.go | 8 --------
test/integration/presence_test.go | 2 --
test/integration/primitive_test.go | 2 --
test/integration/restapi_test.go | 4 ----
test/integration/retention_test.go | 2 --
test/integration/server_test.go | 1 -
test/integration/snapshot_test.go | 2 --
test/integration/text_test.go | 2 --
test/integration/tree_concurrency_test.go | 10 ----------
test/integration/tree_test.go | 2 --
test/integration/user_test.go | 2 --
21 files changed, 1 insertion(+), 69 deletions(-)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index 006914f59..c7be1c48f 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -47,7 +47,7 @@ const (
)
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
-// TODO(binary-ho): temporary comment for measure CI test time
+// TODO(binary-ho) : temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
diff --git a/test/integration/admin_test.go b/test/integration/admin_test.go
index be8903f75..6d77773b8 100644
--- a/test/integration/admin_test.go
+++ b/test/integration/admin_test.go
@@ -36,8 +36,6 @@ import (
)
func TestAdmin(t *testing.T) {
- t.Parallel()
-
ctx := context.Background()
adminCli, err := admin.Dial(defaultServer.RPCAddr(), admin.WithInsecure(true))
diff --git a/test/integration/array_test.go b/test/integration/array_test.go
index 12f71b114..5d41db06b 100644
--- a/test/integration/array_test.go
+++ b/test/integration/array_test.go
@@ -34,8 +34,6 @@ import (
)
func TestArray(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
@@ -330,8 +328,6 @@ func TestArray(t *testing.T) {
}
func TestArraySetTypeGuard(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -389,8 +385,6 @@ func TestArraySetTypeGuard(t *testing.T) {
}
func TestArraySet(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/client_test.go b/test/integration/client_test.go
index 6d1a9edc9..3e9593d7e 100644
--- a/test/integration/client_test.go
+++ b/test/integration/client_test.go
@@ -37,7 +37,6 @@ import (
func TestClient(t *testing.T) {
t.Run("dial and close test", func(t *testing.T) {
- t.Parallel()
cli, err := client.Dial(defaultServer.RPCAddr())
assert.NoError(t, err)
@@ -48,7 +47,6 @@ func TestClient(t *testing.T) {
})
t.Run("activate/deactivate test", func(t *testing.T) {
- t.Parallel()
cli, err := client.Dial(defaultServer.RPCAddr())
assert.NoError(t, err)
defer func() {
@@ -78,7 +76,6 @@ func TestClient(t *testing.T) {
})
t.Run("sync option with multiple clients test", func(t *testing.T) {
- t.Parallel()
clients := activeClients(t, 3)
defer deactivateAndCloseClients(t, clients)
c1, c2, c3 := clients[0], clients[1], clients[2]
@@ -134,7 +131,6 @@ func TestClient(t *testing.T) {
})
t.Run("sync option with mixed mode test", func(t *testing.T) {
- t.Parallel()
clients := activeClients(t, 1)
defer deactivateAndCloseClients(t, clients)
cli := clients[0]
@@ -180,7 +176,6 @@ func TestClient(t *testing.T) {
})
t.Run("deactivated client's stream test", func(t *testing.T) {
- t.Parallel()
ctx := context.Background()
c1, err := client.Dial(defaultServer.RPCAddr())
diff --git a/test/integration/counter_test.go b/test/integration/counter_test.go
index 7075c66c6..4971c88e5 100644
--- a/test/integration/counter_test.go
+++ b/test/integration/counter_test.go
@@ -33,8 +33,6 @@ import (
)
func TestCounter(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/document_test.go b/test/integration/document_test.go
index 5986c11da..2451723d7 100644
--- a/test/integration/document_test.go
+++ b/test/integration/document_test.go
@@ -39,8 +39,6 @@ import (
)
func TestDocument(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 3)
c1, c2, c3 := clients[0], clients[1], clients[2]
defer deactivateAndCloseClients(t, clients)
@@ -691,8 +689,6 @@ func TestDocument(t *testing.T) {
}
func TestDocumentWithProjects(t *testing.T) {
- t.Parallel()
-
ctx := context.Background()
adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr())
defer func() { adminCli.Close() }()
diff --git a/test/integration/gc_test.go b/test/integration/gc_test.go
index ca1801794..0713abd4f 100644
--- a/test/integration/gc_test.go
+++ b/test/integration/gc_test.go
@@ -35,8 +35,6 @@ import (
)
func TestGarbageCollection(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/health_test.go b/test/integration/health_test.go
index 2de1704b5..02e5fdffc 100644
--- a/test/integration/health_test.go
+++ b/test/integration/health_test.go
@@ -40,8 +40,6 @@ var services = []string{
}
func TestRPCHealthCheck(t *testing.T) {
- t.Parallel()
-
conn, err := grpc.Dial(
defaultServer.RPCAddr(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -81,8 +79,6 @@ func TestRPCHealthCheck(t *testing.T) {
}
func TestHTTPGETHealthCheck(t *testing.T) {
- t.Parallel()
-
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Get("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
@@ -129,8 +125,6 @@ func TestHTTPGETHealthCheck(t *testing.T) {
}
func TestHTTPHEADHealthCheck(t *testing.T) {
- t.Parallel()
-
// check default service
t.Run("Service: default", func(t *testing.T) {
resp, err := http.Head("http://" + defaultServer.RPCAddr() + httphealth.HealthV1ServiceName)
diff --git a/test/integration/history_test.go b/test/integration/history_test.go
index 9eede0bd7..52c059518 100644
--- a/test/integration/history_test.go
+++ b/test/integration/history_test.go
@@ -31,8 +31,6 @@ import (
)
func TestHistory(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
cli := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/housekeeping_test.go b/test/integration/housekeeping_test.go
index b7591945b..add1a9a93 100644
--- a/test/integration/housekeeping_test.go
+++ b/test/integration/housekeeping_test.go
@@ -70,8 +70,6 @@ func setupBackend(t *testing.T) *backend.Backend {
}
func TestHousekeeping(t *testing.T) {
- t.Parallel()
-
be := setupBackend(t)
defer func() {
assert.NoError(t, be.Shutdown())
diff --git a/test/integration/object_test.go b/test/integration/object_test.go
index 1e383131e..374953c76 100644
--- a/test/integration/object_test.go
+++ b/test/integration/object_test.go
@@ -34,8 +34,6 @@ import (
)
func TestObject(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
@@ -361,8 +359,6 @@ func TestObject(t *testing.T) {
}
func TestObjectTypeGuard(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -423,8 +419,6 @@ func TestObjectTypeGuard(t *testing.T) {
}
func TestObjectSetCycle(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
@@ -487,8 +481,6 @@ func TestObjectSetCycle(t *testing.T) {
}
func TestObjectSet(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 1)
c1 := clients[0]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/presence_test.go b/test/integration/presence_test.go
index cef4778bf..9f0a8e891 100644
--- a/test/integration/presence_test.go
+++ b/test/integration/presence_test.go
@@ -38,8 +38,6 @@ import (
)
func TestPresence(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/primitive_test.go b/test/integration/primitive_test.go
index 08f58c224..747eb598a 100644
--- a/test/integration/primitive_test.go
+++ b/test/integration/primitive_test.go
@@ -32,8 +32,6 @@ import (
)
func TestPrimitive(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/restapi_test.go b/test/integration/restapi_test.go
index aa836d85e..18926c209 100644
--- a/test/integration/restapi_test.go
+++ b/test/integration/restapi_test.go
@@ -44,7 +44,6 @@ type documentSummary struct {
func TestRESTAPI(t *testing.T) {
t.Run("document retrieval test", func(t *testing.T) {
- t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -59,7 +58,6 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("bulk document retrieval test", func(t *testing.T) {
- t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -74,7 +72,6 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("list documents test", func(t *testing.T) {
- t.Parallel()
project, _ := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
@@ -89,7 +86,6 @@ func TestRESTAPI(t *testing.T) {
})
t.Run("search documents test", func(t *testing.T) {
- t.Parallel()
project, docs := helper.CreateProjectAndDocuments(t, defaultServer, 3)
res := post(
t,
diff --git a/test/integration/retention_test.go b/test/integration/retention_test.go
index 83a00c30c..a8662bc98 100644
--- a/test/integration/retention_test.go
+++ b/test/integration/retention_test.go
@@ -40,8 +40,6 @@ import (
)
func TestRetention(t *testing.T) {
- t.Parallel()
-
var b *background.Background
patch, err := monkey.PatchInstanceMethodByName(
reflect.TypeOf(b),
diff --git a/test/integration/server_test.go b/test/integration/server_test.go
index 23f331cb4..30dc03d5e 100644
--- a/test/integration/server_test.go
+++ b/test/integration/server_test.go
@@ -33,7 +33,6 @@ import (
func TestServer(t *testing.T) {
t.Run("closing WatchDocument stream on server shutdown test", func(t *testing.T) {
- t.Parallel()
ctx := context.Background()
svr := helper.TestServer()
assert.NoError(t, svr.Start())
diff --git a/test/integration/snapshot_test.go b/test/integration/snapshot_test.go
index f7503b8cb..25ea67589 100644
--- a/test/integration/snapshot_test.go
+++ b/test/integration/snapshot_test.go
@@ -36,8 +36,6 @@ import (
)
func TestSnapshot(t *testing.T) {
- t.Parallel()
-
var b *background.Background
patch, err := monkey.PatchInstanceMethodByName(
reflect.TypeOf(b),
diff --git a/test/integration/text_test.go b/test/integration/text_test.go
index ab66f620a..890c4857f 100644
--- a/test/integration/text_test.go
+++ b/test/integration/text_test.go
@@ -31,8 +31,6 @@ import (
)
func TestText(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/tree_concurrency_test.go b/test/integration/tree_concurrency_test.go
index 6416bad84..b342bebcb 100644
--- a/test/integration/tree_concurrency_test.go
+++ b/test/integration/tree_concurrency_test.go
@@ -261,8 +261,6 @@ func TestTreeConcurrencyEditEdit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// a b c
d e f
g h i
- t.Parallel()
-
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -332,8 +330,6 @@ func TestTreeConcurrencySplitSplit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//
a b c d
e f g h
i j k l
- t.Parallel()
-
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -381,8 +377,6 @@ func TestTreeConcurrencySplitEdit(t *testing.T) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//
a b c d
e f g h
i j k l
- t.Parallel()
-
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -446,8 +440,6 @@ func TestTreeConcurrencyStyleStyle(t *testing.T) {
// 3,6 : |----------|
// 6,9 : |----------|
- t.Parallel()
-
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
@@ -488,8 +480,6 @@ func TestTreeConcurrencyEditStyle(t *testing.T) {
// 3,6 : |----------|
// 6,9 : |----------|
- t.Parallel()
-
initialState := json.TreeNode{
Type: "root",
Children: []json.TreeNode{
diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go
index 49024d557..54e1067c0 100644
--- a/test/integration/tree_test.go
+++ b/test/integration/tree_test.go
@@ -34,8 +34,6 @@ import (
)
func TestTree(t *testing.T) {
- t.Parallel()
-
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
diff --git a/test/integration/user_test.go b/test/integration/user_test.go
index 7157bb49e..304f6c168 100644
--- a/test/integration/user_test.go
+++ b/test/integration/user_test.go
@@ -29,8 +29,6 @@ import (
)
func TestUser(t *testing.T) {
- t.Parallel()
-
adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr())
defer func() { adminCli.Close() }()
From 5aa4998649bc4fb376360dcea0f15ccdf48ef1f3 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Thu, 5 Sep 2024 12:43:11 +0900
Subject: [PATCH 07/13] Rename sharding-test to complex-test and move
tree_concurrency_test to complex package
---
.github/workflows/ci.yml | 16 ++-
.../server_test.go => complex/main_test.go} | 126 +++++++-----------
.../mongo_client_test.go | 4 +-
test/complex/server_test.go | 105 +++++++++++++++
.../tree_concurrency_test.go | 4 +-
test/integration/main_test.go | 31 -----
6 files changed, 169 insertions(+), 117 deletions(-)
rename test/{sharding/server_test.go => complex/main_test.go} (58%)
rename test/{sharding => complex}/mongo_client_test.go (99%)
create mode 100644 test/complex/server_test.go
rename test/{integration => complex}/tree_concurrency_test.go (99%)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a73cfc1be..e438e5b88 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,7 +23,7 @@ jobs:
outputs:
build: ${{ steps.ci-target-check.outputs.build }}
bench: ${{ steps.ci-target-check.outputs.bench }}
- sharding-test: ${{ steps.ci-target-check.outputs.sharding-test }}
+ complex-test: ${{ steps.ci-target-check.outputs.complex-test }}
steps:
- name: Checkout code
@@ -42,8 +42,10 @@ jobs:
- 'admin/**'
- 'api/converter/**'
- sharding-test:
+ complex-test:
- 'server/backend/database/**'
+ - 'pkg/document/**'
+ - 'client/**'
build:
name: build
@@ -133,12 +135,12 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
- sharding-test:
- name: sharding-test
+ complex-test:
+ name: complex-test
runs-on: ubuntu-latest
needs: ci-target-check
- if: ${{ needs.ci-target-check.outputs.sharding-test == 'true' }}
+ if: ${{ needs.ci-target-check.outputs.complex-test == 'true' }}
steps:
@@ -171,5 +173,5 @@ jobs:
- name: Initialize the Mongos
run: docker compose -f build/docker/sharding/docker-compose.yml exec mongos1 mongosh test /scripts/init-mongos1.js
- - name: Run the tests with sharding tag
- run: go test -tags sharding -race -v ./test/sharding/...
+ - name: Run the tests with complex tag
+ run: go test -tags complex -race -v ./test/complex/...
diff --git a/test/sharding/server_test.go b/test/complex/main_test.go
similarity index 58%
rename from test/sharding/server_test.go
rename to test/complex/main_test.go
index cd42f0567..b78db3c19 100644
--- a/test/sharding/server_test.go
+++ b/test/complex/main_test.go
@@ -1,4 +1,4 @@
-//go:build sharding
+//go:build complex
/*
* Copyright 2023 The Yorkie Authors. All rights reserved.
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package sharding
+package complex
import (
"context"
@@ -27,20 +27,25 @@ import (
"testing"
"connectrpc.com/connect"
-
+ "github.com/stretchr/testify/assert"
"github.com/yorkie-team/yorkie/admin"
"github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect"
"github.com/yorkie-team/yorkie/client"
+ "github.com/yorkie-team/yorkie/pkg/document"
"github.com/yorkie-team/yorkie/server/backend"
"github.com/yorkie-team/yorkie/server/backend/database"
"github.com/yorkie-team/yorkie/server/backend/database/mongo"
"github.com/yorkie-team/yorkie/server/backend/housekeeping"
"github.com/yorkie-team/yorkie/server/profiling/prometheus"
"github.com/yorkie-team/yorkie/server/rpc"
- "github.com/yorkie-team/yorkie/server/rpc/testcases"
"github.com/yorkie-team/yorkie/test/helper"
)
+type clientAndDocPair struct {
+ cli *client.Client
+ doc *document.Document
+}
+
var (
shardedDBNameForServer = "test-yorkie-meta-server"
testRPCServer *rpc.Server
@@ -132,82 +137,53 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
-func TestSDKRPCServerBackendWithShardedDB(t *testing.T) {
- t.Run("activate/deactivate client test", func(t *testing.T) {
- testcases.RunActivateAndDeactivateClientTest(t, testClient)
- })
-
- t.Run("attach/detach document test", func(t *testing.T) {
- testcases.RunAttachAndDetachDocumentTest(t, testClient)
- })
-
- t.Run("attach/detach on removed document test", func(t *testing.T) {
- testcases.RunAttachAndDetachRemovedDocumentTest(t, testClient)
- })
-
- t.Run("push/pull changes test", func(t *testing.T) {
- testcases.RunPushPullChangeTest(t, testClient)
- })
-
- t.Run("push/pull on removed document test", func(t *testing.T) {
- testcases.RunPushPullChangeOnRemovedDocumentTest(t, testClient)
- })
+func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
+ assert.True(t, len(pairs) > 1)
+ ctx := context.Background()
+ // Save own changes and get previous changes.
+ for i, pair := range pairs {
+ fmt.Printf("before d%d: %s\n", i+1, pair.doc.Marshal())
+ err := pair.cli.Sync(ctx)
+ assert.NoError(t, err)
+ }
- t.Run("remove document test", func(t *testing.T) {
- testcases.RunRemoveDocumentTest(t, testClient)
- })
+ // Get last client changes.
+ // Last client get all precede changes in above loop.
+ for _, pair := range pairs[:len(pairs)-1] {
+ err := pair.cli.Sync(ctx)
+ assert.NoError(t, err)
+ }
- t.Run("remove document with invalid client state test", func(t *testing.T) {
- testcases.RunRemoveDocumentWithInvalidClientStateTest(t, testClient)
- })
+ // Assert start.
+ expected := pairs[0].doc.Marshal()
+ fmt.Printf("after d1: %s\n", expected)
+ for i, pair := range pairs[1:] {
+ v := pair.doc.Marshal()
+ fmt.Printf("after d%d: %s\n", i+2, v)
+ if expected != v {
+ return false
+ }
+ }
- t.Run("watch document test", func(t *testing.T) {
- testcases.RunWatchDocumentTest(t, testClient)
- })
+ return true
}
-func TestAdminRPCServerBackendWithShardedDB(t *testing.T) {
- t.Run("admin signup test", func(t *testing.T) {
- testcases.RunAdminSignUpTest(t, testAdminClient)
- })
-
- t.Run("admin login test", func(t *testing.T) {
- testcases.RunAdminLoginTest(t, testAdminClient)
- })
+// activeClients creates and activates the given number of clients.
+func activeClients(t *testing.T, n int) (clients []*client.Client) {
+ for i := 0; i < n; i++ {
+ c, err := client.Dial(testRPCAddr)
+ assert.NoError(t, err)
+ assert.NoError(t, c.Activate(context.Background()))
- t.Run("admin delete account test", func(t *testing.T) {
- testcases.RunAdminDeleteAccountTest(t, testAdminClient)
- })
-
- t.Run("admin change password test", func(t *testing.T) {
- testcases.RunAdminChangePasswordTest(t, testAdminClient)
- })
-
- t.Run("admin create project test", func(t *testing.T) {
- testcases.RunAdminCreateProjectTest(t, testAdminClient, testAdminAuthInterceptor)
- })
-
- t.Run("admin list projects test", func(t *testing.T) {
- testcases.RunAdminListProjectsTest(t, testAdminClient, testAdminAuthInterceptor)
- })
-
- t.Run("admin get project test", func(t *testing.T) {
- testcases.RunAdminGetProjectTest(t, testAdminClient, testAdminAuthInterceptor)
- })
-
- t.Run("admin update project test", func(t *testing.T) {
- testcases.RunAdminUpdateProjectTest(t, testAdminClient, testAdminAuthInterceptor)
- })
-
- t.Run("admin list documents test", func(t *testing.T) {
- testcases.RunAdminListDocumentsTest(t, testAdminClient, testAdminAuthInterceptor)
- })
-
- t.Run("admin get document test", func(t *testing.T) {
- testcases.RunAdminGetDocumentTest(t, testClient, testAdminClient, testAdminAuthInterceptor)
- })
+ clients = append(clients, c)
+ }
+ return
+}
- t.Run("admin list changes test", func(t *testing.T) {
- testcases.RunAdminListChangesTest(t, testClient, testAdminClient, testAdminAuthInterceptor)
- })
+// deactivateAndCloseClients deactivates and closes the given clients.
+func deactivateAndCloseClients(t *testing.T, clients []*client.Client) {
+ for _, c := range clients {
+ assert.NoError(t, c.Deactivate(context.Background()))
+ assert.NoError(t, c.Close())
+ }
}
diff --git a/test/sharding/mongo_client_test.go b/test/complex/mongo_client_test.go
similarity index 99%
rename from test/sharding/mongo_client_test.go
rename to test/complex/mongo_client_test.go
index 5cb2bffe6..2fd6691fb 100644
--- a/test/sharding/mongo_client_test.go
+++ b/test/complex/mongo_client_test.go
@@ -1,4 +1,4 @@
-//go:build sharding
+//go:build complex
/*
* Copyright 2023 The Yorkie Authors. All rights reserved.
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package sharding
+package complex
import (
"context"
diff --git a/test/complex/server_test.go b/test/complex/server_test.go
new file mode 100644
index 000000000..cacc41186
--- /dev/null
+++ b/test/complex/server_test.go
@@ -0,0 +1,105 @@
+//go:build complex
+
+/*
+ * Copyright 2023 The Yorkie Authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package complex
+
+import (
+ "testing"
+
+ "github.com/yorkie-team/yorkie/server/rpc/testcases"
+)
+
+func TestSDKRPCServerBackendWithShardedDB(t *testing.T) {
+ t.Run("activate/deactivate client test", func(t *testing.T) {
+ testcases.RunActivateAndDeactivateClientTest(t, testClient)
+ })
+
+ t.Run("attach/detach document test", func(t *testing.T) {
+ testcases.RunAttachAndDetachDocumentTest(t, testClient)
+ })
+
+ t.Run("attach/detach on removed document test", func(t *testing.T) {
+ testcases.RunAttachAndDetachRemovedDocumentTest(t, testClient)
+ })
+
+ t.Run("push/pull changes test", func(t *testing.T) {
+ testcases.RunPushPullChangeTest(t, testClient)
+ })
+
+ t.Run("push/pull on removed document test", func(t *testing.T) {
+ testcases.RunPushPullChangeOnRemovedDocumentTest(t, testClient)
+ })
+
+ t.Run("remove document test", func(t *testing.T) {
+ testcases.RunRemoveDocumentTest(t, testClient)
+ })
+
+ t.Run("remove document with invalid client state test", func(t *testing.T) {
+ testcases.RunRemoveDocumentWithInvalidClientStateTest(t, testClient)
+ })
+
+ t.Run("watch document test", func(t *testing.T) {
+ testcases.RunWatchDocumentTest(t, testClient)
+ })
+}
+
+func TestAdminRPCServerBackendWithShardedDB(t *testing.T) {
+ t.Run("admin signup test", func(t *testing.T) {
+ testcases.RunAdminSignUpTest(t, testAdminClient)
+ })
+
+ t.Run("admin login test", func(t *testing.T) {
+ testcases.RunAdminLoginTest(t, testAdminClient)
+ })
+
+ t.Run("admin delete account test", func(t *testing.T) {
+ testcases.RunAdminDeleteAccountTest(t, testAdminClient)
+ })
+
+ t.Run("admin change password test", func(t *testing.T) {
+ testcases.RunAdminChangePasswordTest(t, testAdminClient)
+ })
+
+ t.Run("admin create project test", func(t *testing.T) {
+ testcases.RunAdminCreateProjectTest(t, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin list projects test", func(t *testing.T) {
+ testcases.RunAdminListProjectsTest(t, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin get project test", func(t *testing.T) {
+ testcases.RunAdminGetProjectTest(t, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin update project test", func(t *testing.T) {
+ testcases.RunAdminUpdateProjectTest(t, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin list documents test", func(t *testing.T) {
+ testcases.RunAdminListDocumentsTest(t, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin get document test", func(t *testing.T) {
+ testcases.RunAdminGetDocumentTest(t, testClient, testAdminClient, testAdminAuthInterceptor)
+ })
+
+ t.Run("admin list changes test", func(t *testing.T) {
+ testcases.RunAdminListChangesTest(t, testClient, testAdminClient, testAdminAuthInterceptor)
+ })
+}
diff --git a/test/integration/tree_concurrency_test.go b/test/complex/tree_concurrency_test.go
similarity index 99%
rename from test/integration/tree_concurrency_test.go
rename to test/complex/tree_concurrency_test.go
index b342bebcb..0b5a48242 100644
--- a/test/integration/tree_concurrency_test.go
+++ b/test/complex/tree_concurrency_test.go
@@ -1,4 +1,4 @@
-//go:build integration
+//go:build complex
/*
* Copyright 2024 The Yorkie Authors. All rights reserved.
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package integration
+package complex
import (
"context"
diff --git a/test/integration/main_test.go b/test/integration/main_test.go
index e63be3137..867634420 100644
--- a/test/integration/main_test.go
+++ b/test/integration/main_test.go
@@ -88,37 +88,6 @@ func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
}
}
-func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
- assert.True(t, len(pairs) > 1)
- ctx := context.Background()
- // Save own changes and get previous changes.
- for i, pair := range pairs {
- fmt.Printf("before d%d: %s\n", i+1, pair.doc.Marshal())
- err := pair.cli.Sync(ctx)
- assert.NoError(t, err)
- }
-
- // Get last client changes.
- // Last client get all precede changes in above loop.
- for _, pair := range pairs[:len(pairs)-1] {
- err := pair.cli.Sync(ctx)
- assert.NoError(t, err)
- }
-
- // Assert start.
- expected := pairs[0].doc.Marshal()
- fmt.Printf("after d1: %s\n", expected)
- for i, pair := range pairs[1:] {
- v := pair.doc.Marshal()
- fmt.Printf("after d%d: %s\n", i+2, v)
- if expected != v {
- return false
- }
- }
-
- return true
-}
-
// activeClients creates and activates the given number of clients.
func activeClients(t *testing.T, n int) (clients []*client.Client) {
for i := 0; i < n; i++ {
From bc1d50d56e6aa44ecf8aa8d4ac3c2b255414f4e8 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Thu, 5 Sep 2024 12:49:29 +0900
Subject: [PATCH 08/13] Add temporary comment for ci test
---
server/backend/database/testcases/testcases.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index c7be1c48f..fdc3f9c21 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -48,6 +48,7 @@ const (
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
// TODO(binary-ho) : temporary comment for measure CI test time
+// TODO(binary-ho) : temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
From 1a7c968c116c1ade5c7ca222d519a9373c0e905d Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Sat, 7 Sep 2024 16:03:02 +0900
Subject: [PATCH 09/13] Add test function and type in integration/main_test
---
test/integration/main_test.go | 36 +++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/test/integration/main_test.go b/test/integration/main_test.go
index 867634420..40f17b6b6 100644
--- a/test/integration/main_test.go
+++ b/test/integration/main_test.go
@@ -34,6 +34,11 @@ import (
"github.com/yorkie-team/yorkie/test/helper"
)
+type testResult struct {
+ flag bool
+ resultDesc string
+}
+
type clientAndDocPair struct {
cli *client.Client
doc *document.Document
@@ -61,6 +66,37 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
+func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
+ assert.True(t, len(pairs) > 1)
+ ctx := context.Background()
+ // Save own changes and get previous changes.
+ for i, pair := range pairs {
+ fmt.Printf("before d%d: %s\n", i+1, pair.doc.Marshal())
+ err := pair.cli.Sync(ctx)
+ assert.NoError(t, err)
+ }
+
+ // Get last client changes.
+ // Last client get all precede changes in above loop.
+ for _, pair := range pairs[:len(pairs)-1] {
+ err := pair.cli.Sync(ctx)
+ assert.NoError(t, err)
+ }
+
+ // Assert start.
+ expected := pairs[0].doc.Marshal()
+ fmt.Printf("after d1: %s\n", expected)
+ for i, pair := range pairs[1:] {
+ v := pair.doc.Marshal()
+ fmt.Printf("after d%d: %s\n", i+2, v)
+ if expected != v {
+ return false
+ }
+ }
+
+ return true
+}
+
func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
assert.True(t, len(pairs) > 1)
ctx := context.Background()
From 22a5b7c865ae835a3aa87fba90b76724dd23b43c Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Sat, 7 Sep 2024 16:43:18 +0900
Subject: [PATCH 10/13] Trigger CI for measure time After remove cache
---
server/backend/database/testcases/testcases.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index fdc3f9c21..c7be1c48f 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -48,7 +48,6 @@ const (
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
// TODO(binary-ho) : temporary comment for measure CI test time
-// TODO(binary-ho) : temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
From aa9e6b4d0d9685c62d278194f897187e6c7bac11 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Sat, 7 Sep 2024 17:47:55 +0900
Subject: [PATCH 11/13] Remove all temporary comments for test
---
server/backend/database/testcases/testcases.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go
index c7be1c48f..2108f8c83 100644
--- a/server/backend/database/testcases/testcases.go
+++ b/server/backend/database/testcases/testcases.go
@@ -47,7 +47,6 @@ const (
)
// RunFindDocInfoTest runs the FindDocInfo test for the given db.
-// TODO(binary-ho) : temporary comment for measure CI test time
func RunFindDocInfoTest(
t *testing.T,
db database.Database,
From 163ca60d6de89bd115e2a68eea772f69bc8d9550 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Wed, 11 Sep 2024 22:01:39 +0900
Subject: [PATCH 12/13] Move `testResult` to `main_test.go`
---
test/complex/main_test.go | 5 +++++
test/complex/tree_concurrency_test.go | 5 -----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/complex/main_test.go b/test/complex/main_test.go
index b78db3c19..9ce84b62d 100644
--- a/test/complex/main_test.go
+++ b/test/complex/main_test.go
@@ -41,6 +41,11 @@ import (
"github.com/yorkie-team/yorkie/test/helper"
)
+type testResult struct {
+ flag bool
+ resultDesc string
+}
+
type clientAndDocPair struct {
cli *client.Client
doc *document.Document
diff --git a/test/complex/tree_concurrency_test.go b/test/complex/tree_concurrency_test.go
index 0b5a48242..b7e900f5d 100644
--- a/test/complex/tree_concurrency_test.go
+++ b/test/complex/tree_concurrency_test.go
@@ -52,11 +52,6 @@ func parseSimpleXML(s string) []string {
return res
}
-type testResult struct {
- flag bool
- resultDesc string
-}
-
type rangeSelector int
const (
From 6546db1da16bb7e181c2045ff686f73aed013e08 Mon Sep 17 00:00:00 2001
From: binary-ho
Date: Wed, 11 Sep 2024 22:04:44 +0900
Subject: [PATCH 13/13] Put the functions back in the correct place
---
test/integration/main_test.go | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/test/integration/main_test.go b/test/integration/main_test.go
index 40f17b6b6..d966cf9cf 100644
--- a/test/integration/main_test.go
+++ b/test/integration/main_test.go
@@ -66,7 +66,7 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
-func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
+func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
assert.True(t, len(pairs) > 1)
ctx := context.Background()
// Save own changes and get previous changes.
@@ -89,15 +89,11 @@ func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
for i, pair := range pairs[1:] {
v := pair.doc.Marshal()
fmt.Printf("after d%d: %s\n", i+2, v)
- if expected != v {
- return false
- }
+ assert.Equal(t, expected, v)
}
-
- return true
}
-func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
+func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
assert.True(t, len(pairs) > 1)
ctx := context.Background()
// Save own changes and get previous changes.
@@ -120,8 +116,12 @@ func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
for i, pair := range pairs[1:] {
v := pair.doc.Marshal()
fmt.Printf("after d%d: %s\n", i+2, v)
- assert.Equal(t, expected, v)
+ if expected != v {
+ return false
+ }
}
+
+ return true
}
// activeClients creates and activates the given number of clients.