Skip to content

Commit

Permalink
remove test at the moment (is too slow)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-kripakov-m10 committed Dec 21, 2023
1 parent 8fa19bb commit b902307
Showing 1 changed file with 0 additions and 92 deletions.
92 changes: 0 additions & 92 deletions dkron/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,95 +636,3 @@ func Test_selectNodes(t *testing.T) {
})
}
}

func Test_clusterWillRecoverAfterIpChange(t *testing.T) {
a1, rfn1 := buildAndRunAgent("test8", []string{}, 3)
defer rfn1()
a2, rfn2 := buildAndRunAgent("test9", []string{a1.bindRPCAddr()[:len(a1.bindRPCAddr())-4] + "8946"}, 3)
defer rfn2()
a3, rfn3 := buildAndRunAgent("test10", []string{a1.bindRPCAddr()[:len(a1.bindRPCAddr())-4] + "8946", a2.bindRPCAddr()[:len(a2.bindRPCAddr())-4] + "8946"}, 3)
defer rfn3()
time.Sleep(2 * time.Second)
assert.True(t, a1.IsLeader() || a2.IsLeader() || a3.IsLeader())
servers := a1.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))
servers = a2.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))
servers = a3.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))

_ = a1.Stop()

time.Sleep(30 * time.Second)

assert.True(t, !a1.IsLeader() && (a2.IsLeader() || a3.IsLeader()))

//servers = a2.raft.GetConfiguration().Configuration().Servers
//assert.Equal(t, 2, len(servers))
//servers = a3.raft.GetConfiguration().Configuration().Servers
//assert.Equal(t, 2, len(servers))

_ = a2.Stop()

time.Sleep(20 * time.Second)

assert.True(t, !a1.IsLeader() && !a2.IsLeader() && !a3.IsLeader())

//servers = a3.raft.GetConfiguration().Configuration().Servers
//assert.Equal(t, 1, len(servers))

a1, rfn1 = buildAndRunAgent("test8", []string{a3.bindRPCAddr()[:len(a3.bindRPCAddr())-4] + "8946"}, 3)
defer rfn1()
a2, rfn2 = buildAndRunAgent("test9", []string{a3.bindRPCAddr()[:len(a3.bindRPCAddr())-4] + "8946"}, 3)
defer rfn2()

time.Sleep(10 * time.Second)

assert.True(t, a1.IsLeader() || a2.IsLeader() || a3.IsLeader())
servers = a1.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))
servers = a2.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))
servers = a3.raft.GetConfiguration().Configuration().Servers
assert.Equal(t, 3, len(servers))
}

func buildAndRunAgent(
nodeName string,
startJoin []string,
bootstrapExpect int,
) (*Agent, func()) {

dir, err := os.MkdirTemp("", fmt.Sprintf("test-%s", nodeName))
if err != nil {
panic(err.Error())
}
defer os.RemoveAll(dir)
ip, returnFn := testutil.TakeIP()
defer returnFn()
addr := ip.String()

// Start another agent
c := DefaultConfig()
c.BindAddr = addr
c.StartJoin = startJoin
c.NodeName = nodeName
c.Server = true
c.LogLevel = logLevel
c.BootstrapExpect = bootstrapExpect
c.DevMode = true
c.DataDir = dir
c.RaftMultiplier = 1

a2 := NewAgent(c)
err = a2.Start()
if err != nil {
panic(err.Error())
}

return a2, func() {
_ = a2.Stop()
returnFn()
_ = os.RemoveAll(dir)
}
}

0 comments on commit b902307

Please sign in to comment.