From 00abb10eadb8a333103b214d21b237cb5eec4359 Mon Sep 17 00:00:00 2001 From: Ishan Goyal <63078216+Ishan27g@users.noreply.github.com> Date: Tue, 15 Mar 2022 13:16:16 +1100 Subject: [PATCH 1/2] multi-zone with followers --- .envFiles/2.follower.A.env | 8 +++++--- .envFiles/2.follower.B.env | 8 +++++--- .envFiles/3.follower.A.env | 8 ++++++++ .envFiles/3.follower.B.env | 8 ++++++++ load_test.go | 14 +++++++++----- main_test.go | 4 +++- utils_test.go | 8 ++++---- 7 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 .envFiles/3.follower.A.env create mode 100644 .envFiles/3.follower.B.env diff --git a/.envFiles/2.follower.A.env b/.envFiles/2.follower.A.env index 9c579f0..e529ff5 100644 --- a/.envFiles/2.follower.A.env +++ b/.envFiles/2.follower.A.env @@ -1,6 +1,8 @@ REGISTRY:"http://localhost:9999" ZoneId:2 -HTTP_PORT:"3107" -GRPC_PORT:"3127" -UDP_PORT:"3147" \ No newline at end of file +HTTP_PORT:"3207" +GRPC_PORT:"3227" +UDP_PORT:"3247" + +TempName="Zone-2:Follower-A" diff --git a/.envFiles/2.follower.B.env b/.envFiles/2.follower.B.env index f07c828..43110d1 100644 --- a/.envFiles/2.follower.B.env +++ b/.envFiles/2.follower.B.env @@ -1,6 +1,8 @@ REGISTRY:"http://localhost:9999" ZoneId:2 -HTTP_PORT:"3108" -GRPC_PORT:"3128" -UDP_PORT:"3148" \ No newline at end of file +HTTP_PORT:"3208" +GRPC_PORT:"3228" +UDP_PORT:"3248" + +TempName="Zone-2:Follower-B" \ No newline at end of file diff --git a/.envFiles/3.follower.A.env b/.envFiles/3.follower.A.env new file mode 100644 index 0000000..71c1d9f --- /dev/null +++ b/.envFiles/3.follower.A.env @@ -0,0 +1,8 @@ +REGISTRY:"http://localhost:9999" + +ZoneId:3 +HTTP_PORT:"3307" +GRPC_PORT:"3327" +UDP_PORT:"3347" + +TempName="Zone-3:Follower-A" diff --git a/.envFiles/3.follower.B.env b/.envFiles/3.follower.B.env new file mode 100644 index 0000000..c52357e --- /dev/null +++ b/.envFiles/3.follower.B.env @@ -0,0 +1,8 @@ +REGISTRY:"http://localhost:9999" + +ZoneId:3 +HTTP_PORT:"3308" +GRPC_PORT:"3328" +UDP_PORT:"3348" + +TempName="Zone-3:Follower-B" diff --git a/load_test.go b/load_test.go index 942fff2..26c191e 100644 --- a/load_test.go +++ b/load_test.go @@ -13,7 +13,7 @@ import ( const bulkMessages = 100 -func Test_Gossip_Load_Single_Round(t *testing.T) { +func Test_Gossip_Load_Single_Zone(t *testing.T) { ctx, can := context.WithCancel(context.Background()) defer func() { can() @@ -26,7 +26,7 @@ func Test_Gossip_Load_Single_Round(t *testing.T) { return time.Millisecond * 100 }) } -func Test_Gossip_Load_Multiple_Rounds(t *testing.T) { +func Test_Gossip_Load_Multiple_Zones(t *testing.T) { ctx, can := context.WithCancel(context.Background()) defer func() { can() @@ -35,7 +35,11 @@ func Test_Gossip_Load_Multiple_Rounds(t *testing.T) { <-time.After(2 * time.Second) }() - runTest(t, ctx, zone1, bulkMessages, atAny, func() time.Duration { - return 1 * time.Second - }) + // runTest(t, ctx, zone1, bulkMessages, atAny, func() time.Duration { + // return 1 * time.Second + // }) + + runTestZones(t, ctx, singleRoundNumMessages, atAny, func() time.Duration { + return 500 * time.Millisecond + }, []string{zone2, zone3}...) } diff --git a/main_test.go b/main_test.go index c116869..02f1495 100644 --- a/main_test.go +++ b/main_test.go @@ -72,7 +72,9 @@ func Test_Multiple_Zones(t *testing.T) { <-time.After(2 * time.Second) }() - runTestZones(t, ctx, 2, atLeaderOnly, twoSeconds, []string{zone2, zone3}...) + runTestZones(t, ctx, singleRoundNumMessages, atAny, func() time.Duration { + return 500 * time.Millisecond + }, []string{zone2, zone3}...) } // go test --v ./... -run Test_Round_AtLeader diff --git a/utils_test.go b/utils_test.go index 9972e82..fc407cc 100644 --- a/utils_test.go +++ b/utils_test.go @@ -42,12 +42,12 @@ var envFiles = envMap{ envFile + "1.follower.E.env", }, envFile + "2.leader.env": []string{ - // envFile + "2.follower.A.env", - // envFile + "2.follower.B.env", + envFile + "2.follower.A.env", + envFile + "2.follower.B.env", }, envFile + "3.leader.env": []string{ - //envFile + "3.follower.A.env", - //envFile + "3.follower.B.env", + envFile + "3.follower.A.env", + envFile + "3.follower.B.env", }, } From 3bceb93d0b7e681d086282f5aee6bdcfcd8f4ceb Mon Sep 17 00:00:00 2001 From: Ishan Goyal <63078216+Ishan27g@users.noreply.github.com> Date: Tue, 15 Mar 2022 13:27:51 +1100 Subject: [PATCH 2/2] uuuu --- main_test.go | 2 +- utils_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main_test.go b/main_test.go index 02f1495..34f2d84 100644 --- a/main_test.go +++ b/main_test.go @@ -72,7 +72,7 @@ func Test_Multiple_Zones(t *testing.T) { <-time.After(2 * time.Second) }() - runTestZones(t, ctx, singleRoundNumMessages, atAny, func() time.Duration { + runTestZones(t, ctx, singleRoundNumMessages, atLeaderOnly, func() time.Duration { return 500 * time.Millisecond }, []string{zone2, zone3}...) } diff --git a/utils_test.go b/utils_test.go index fc407cc..731bfa6 100644 --- a/utils_test.go +++ b/utils_test.go @@ -42,12 +42,12 @@ var envFiles = envMap{ envFile + "1.follower.E.env", }, envFile + "2.leader.env": []string{ - envFile + "2.follower.A.env", - envFile + "2.follower.B.env", + // envFile + "2.follower.A.env", + // envFile + "2.follower.B.env", }, envFile + "3.leader.env": []string{ - envFile + "3.follower.A.env", - envFile + "3.follower.B.env", + // envFile + "3.follower.A.env", + // envFile + "3.follower.B.env", }, }