From 01d7ff581c64909f066e3ec268d4025e3fa99edc Mon Sep 17 00:00:00 2001 From: Fred Carle Date: Fri, 11 Oct 2024 12:55:26 -0400 Subject: [PATCH] fix test and add variant --- .../net/simple/replicator/with_update_test.go | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/tests/integration/net/simple/replicator/with_update_test.go b/tests/integration/net/simple/replicator/with_update_test.go index 57fe1fb0c7..f7486c484e 100644 --- a/tests/integration/net/simple/replicator/with_update_test.go +++ b/tests/integration/net/simple/replicator/with_update_test.go @@ -172,12 +172,12 @@ func TestP2POneToOneReplicator_ManyDocsUpdateWithTargetNodeTemporarilyOffline_Sh testUtils.UpdateDoc{ NodeID: immutable.Some(0), DocID: 0, - Doc: `{Age: 22}`, + Doc: `{"Age": 22}`, }, testUtils.UpdateDoc{ NodeID: immutable.Some(0), DocID: 1, - Doc: `{Age: 23}`, + Doc: `{"Age": 23}`, }, testUtils.Start{ NodeID: immutable.Some(1), @@ -195,7 +195,88 @@ func TestP2POneToOneReplicator_ManyDocsUpdateWithTargetNodeTemporarilyOffline_Sh "Age": int64(23), }, { - "Age": int64(21), + "Age": int64(22), + }, + }, + }, + }, + }, + } + + testUtils.ExecuteTestCase(t, test) +} + +func TestP2POneToOneReplicator_ManyDocsUpdateWithTargetNodeTemporarilyOfflineAfterCreate_ShouldSucceed(t *testing.T) { + test := testUtils.TestCase{ + SupportedDatabaseTypes: immutable.Some( + []testUtils.DatabaseType{ + // This test only supports file type databases since it requires the ability to + // stop and start a node without losing data. + testUtils.BadgerFileType, + }, + ), + Actions: []any{ + testUtils.RandomNetworkingConfig(), + testUtils.RandomNetworkingConfig(), + testUtils.SchemaUpdate{ + Schema: ` + type Users { + Name: String + Age: Int + } + `, + }, + testUtils.ConfigureReplicator{ + SourceNodeID: 0, + TargetNodeID: 1, + }, + testUtils.CreateDoc{ + // Create John on the first (source) node only, and allow the value to sync + NodeID: immutable.Some(0), + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.CreateDoc{ + // Create Fred on the first (source) node only, and allow the value to sync + NodeID: immutable.Some(0), + Doc: `{ + "Name": "Fred", + "Age": 22 + }`, + }, + testUtils.WaitForSync{}, + testUtils.Close{ + NodeID: immutable.Some(1), + }, + testUtils.UpdateDoc{ + NodeID: immutable.Some(0), + DocID: 0, + Doc: `{"Age": 22}`, + }, + testUtils.UpdateDoc{ + NodeID: immutable.Some(0), + DocID: 1, + Doc: `{"Age": 23}`, + }, + testUtils.Start{ + NodeID: immutable.Some(1), + }, + testUtils.WaitForSync{}, + testUtils.Request{ + Request: `query { + Users { + Age + } + }`, + Results: map[string]any{ + "Users": []map[string]any{ + { + "Age": int64(23), + }, + { + "Age": int64(22), }, }, },