forked from signal18/replication-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_failover_assync_autorejoin_nowrite.go
62 lines (49 loc) · 1.57 KB
/
test_failover_assync_autorejoin_nowrite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// replication-manager - Replication Manager Monitoring and CLI for MariaDB and MySQL
// Copyright 2017 Signal 18 SARL
// Authors: Guillaume Lefranc <guillaume@signal18.io>
// Stephane Varoqui <svaroqui@gmail.com>
// This source code is licensed under the GNU General Public License, version 3.
package regtest
import (
"sync"
"time"
"github.com/signal18/replication-manager/cluster"
)
func testFailoverAssyncAutoRejoinNowrites(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
cluster.SetFailSync(false)
cluster.SetInteractive(false)
cluster.SetRplChecks(false)
cluster.SetRejoin(true)
cluster.SetRejoinFlashback(false)
cluster.SetRejoinDump(false)
cluster.DisableSemisync()
SaveMasterURL := cluster.GetMaster().URL
SaveMaster := cluster.GetMaster()
time.Sleep(4 * time.Second)
wg := new(sync.WaitGroup)
wg.Add(1)
go cluster.WaitFailover(wg)
cluster.StopDatabaseService(cluster.GetMaster())
wg.Wait()
/// give time to start the failover
if cluster.GetMaster().URL == SaveMasterURL {
cluster.LogPrintf("TEST", " Old master %s == Next master %s ", SaveMasterURL, cluster.GetMaster().URL)
return false
}
wg2 := new(sync.WaitGroup)
wg2.Add(1)
go cluster.WaitRejoin(wg2)
cluster.StartDatabaseService(SaveMaster)
wg2.Wait()
//Wait for replication recovery
time.Sleep(2 * time.Second)
if cluster.CheckTableConsistency("test.sbtest") != true {
cluster.LogPrintf(LvlErr, "Inconsitant slave")
return false
}
if cluster.CheckSlavesRunning() == false {
cluster.LogPrintf(LvlErr, "Replication issue")
return false
}
return true
}