Skip to content

Commit 825a710

Browse files
committed
OpenSVC test to copy config
1 parent b00a4f3 commit 825a710

File tree

527 files changed

+226
-751942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+226
-751942
lines changed

cluster/cluster.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ const (
251251

252252
// Init initial cluster definition
253253
func (cluster *Cluster) Init(conf config.Config, cfgGroup string, tlog *s18log.TermLog, log *s18log.HttpLog, termlength int, runUUID string, repmgrVersion string, repmgrHostname string, key []byte) error {
254+
254255
cluster.crcTable = crc64.MakeTable(crc64.ECMA) // http://golang.org/pkg/hash/crc64/#pkg-constants
255256
cluster.switchoverChan = make(chan bool)
256257
// should use buffered channels or it will block
@@ -349,7 +350,7 @@ func (cluster *Cluster) Init(conf config.Config, cfgGroup string, tlog *s18log.T
349350
//Loading configuration compliances
350351
cluster.Configurator.Init(cluster.Conf)
351352

352-
switch cluster.GetOrchestrator() {
353+
switch cluster.GetOrchestrator() {
353354
case config.ConstOrchestratorLocalhost:
354355
cluster.DropDBTagConfig("docker")
355356
cluster.DropDBTagConfig("threadpool")
@@ -361,7 +362,7 @@ func (cluster *Cluster) Init(conf config.Config, cfgGroup string, tlog *s18log.T
361362
func (cluster *Cluster) initOrchetratorNodes() {
362363

363364
//cluster.LogPrintf(LvlInfo, "Loading nodes from orchestrator %s", cluster.Conf.ProvOrchestrator)
364-
switch cluster.GetOrchestrator() {
365+
switch cluster.GetOrchestrator() {
365366
case config.ConstOrchestratorOpenSVC:
366367
cluster.Agents, _ = cluster.OpenSVCGetNodes()
367368
case config.ConstOrchestratorKubernetes:

cluster/cluster_get.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ func (cluster *Cluster) GetFailoverCtr() int {
163163
return cluster.FailoverCtr
164164
}
165165

166+
func (cluster *Cluster) GetIncludeDir() string {
167+
return cluster.Conf.Include
168+
}
169+
166170
func (cluster *Cluster) GetFailoverTs() int64 {
167171
return cluster.FailoverTs
168172
}

etc/opensvc/cluster-api/cluster-demo/stephane.toml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ opensvc-p12-certificate = "etc/opensvc/cluster-api/cluster-demo/signal18.p12"
44
opensvc-host = "10.8.0.15:1215"
55
opensvc-p12-secret = "36vf2cczf8rms8hh"
66

7-
include ="etc/opensvc/cluster-api/cluster-demo/stephane.d"
7+
#include ="etc/opensvc/cluster-api/cluster-demo/stephane.d"
88
# log-heartbeat = true
99

1010
log-file="/var/log/replication-manager/replication-manager.log"
@@ -32,3 +32,26 @@ prov-proxy-agents = "s18-fr-1,s18-fr-2"
3232
prov-proxy-service-type = "docker"
3333
prov-proxy-disk-type = "volume"
3434
prov-proxy-volume-data = "tank"
35+
36+
37+
38+
[test]
39+
title = "test"
40+
db-servers-hosts = "db1,db2"
41+
db-servers-prefered-master = "db1"
42+
db-servers-connect-timeout = 1
43+
#failover-mode = "automatic"
44+
#autorejoin-mysqldump = true
45+
#autorejoin-flashback = true
46+
#failover-falsepositive-heartbeat = false
47+
#force-slave-semisync = true
48+
#force-sync-binlog = true
49+
#force-sync-innodb = true
50+
#force-slave-failover-readonly-state = true
51+
#failover-falsepositive-ping-counter = 3
52+
#failover-limit = 999
53+
#failover-time-limit = 1
54+
prov-db-docker-img = "mariadb:10.5"
55+
prov-db-tags = "smallredolog,semisync,innodb,noquerycache,threadpool,logslow"
56+
haproxy=true
57+
haproxy-servers = "haproxy1"

regtest/regtest.go

Lines changed: 26 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package regtest
33
import (
44
"bufio"
55
"encoding/json"
6-
"fmt"
76
"io/ioutil"
87
"os"
98
"path/filepath"
10-
"sort"
119
"strings"
1210

1311
"github.com/signal18/replication-manager/cluster"
12+
"github.com/signal18/replication-manager/utils/misc"
1413
)
1514

1615
var tests = []string{
@@ -78,7 +77,7 @@ func (regtest *RegTest) SaveTestsFromResult(cl *cluster.Cluster, result map[stri
7877
return nil
7978
}
8079

81-
func (regtest *RegTest) CreateTestsFromShare(cl *cluster.Cluster) error {
80+
func (regtest *RegTest) CreateTestsFromShare(cl *cluster.Cluster) map[string]cluster.Test {
8281
Path := cl.GetShareDir() + "/tests/"
8382
var allTests = map[string]cluster.Test{}
8483
err := filepath.Walk(Path, func(path string, info os.FileInfo, err error) error {
@@ -98,7 +97,7 @@ func (regtest *RegTest) CreateTestsFromShare(cl *cluster.Cluster) error {
9897
var test cluster.Test
9998
scenario := scanner.Text()
10099
test.Name = scenario
101-
test.ConfigFile = path + "/replication-manager.toml"
100+
test.ConfigFile = filepath.Dir(path) + "/config.toml"
102101
allTests[path+"/"+scenario] = test
103102
tests = append(tests, scenario)
104103
}
@@ -108,20 +107,32 @@ func (regtest *RegTest) CreateTestsFromShare(cl *cluster.Cluster) error {
108107
return err
109108
}
110109

111-
fmt.Printf("dir: %s name: %s\n", strings.Join(tests, ","), path)
110+
// fmt.Printf("dir: %s name: %s\n", strings.Join(tests, ","), path)
112111
}
113112
}
114113

115114
return err
116115
})
117116
if err != nil {
118-
return err
117+
return allTests
119118
}
120119
saveJson, _ := json.MarshalIndent(allTests, "", "\t")
121120
errmarshall := ioutil.WriteFile(cl.Conf.WorkingDir+"/"+cl.Name+"/tests.json", saveJson, 0644)
122121
if errmarshall != nil {
123-
return errmarshall
122+
return allTests
123+
}
124+
return allTests
125+
}
126+
127+
func (regtest *RegTest) CopyConfig(cl *cluster.Cluster, test cluster.Test) error {
128+
srcFile := test.ConfigFile
129+
// The scenario run on the local cluster and does need a special config
130+
if srcFile == "" {
131+
return nil
124132
}
133+
dstFile := cl.GetIncludeDir() + "/" + filepath.Base(srcFile)
134+
cl.LogPrintf("INFO", "Copy from %s to %s", srcFile, dstFile)
135+
misc.CopyFile(srcFile, dstFile)
125136
return nil
126137
}
127138

@@ -139,199 +150,22 @@ func (regtest *RegTest) GetTestsFromScenarios(cl *cluster.Cluster, scenarios []s
139150
return allTests
140151
}
141152

142-
// RunAllTests can run
143-
// - Single scenario on the monitored cluster
144-
// - All scenarios on the monitored cluster
145-
// - All found scenarios under a given path in the test suite directory
146-
// play scenarios listed in files .todo with a config replication-manager.toml found in same directory
147-
//
148-
// Returns
149-
// - A map of cluster.Test executed
150-
// - Saved this map in the cluster datadir under tests.json file acumulate multiple run
151-
//
152-
// Workflow
153-
// - Build a map of cluster.Test based on parmater type
154-
// - Loop over the map
155-
//
156-
// Call the test that
157-
// - Copy the config in include directory when given
158-
// - Relaod the config
159-
// - Provision the cluster
160-
// - Play the scenario
161-
// - Unprovision the cluster
162-
163-
func (regtest *RegTest) RunAllTests(cl *cluster.Cluster, testExp string, path string) []cluster.Test {
153+
func (regtest *RegTest) GetTestsFromPath(cl *cluster.Cluster, tests map[string]cluster.Test, path string) map[string]cluster.Test {
164154
var allTests = map[string]cluster.Test{}
165-
pathdefault := cl.GetShareDir() + "/" + cl.GetOrchestrator() + "/config/masterslave/mariadb/without_traffic/10.5/x2/semisync"
166-
if path == "" {
167-
path = pathdefault
168-
}
169-
170-
if testExp == "SUITE" {
171-
regtest.CreateTestsFromShare(cl)
172-
} else if testExp == "ALL" {
173-
allTests = regtest.GetTestsFromScenarios(cl, regtest.GetTests())
174-
} else {
175-
allTests = regtest.GetTestsFromScenarios(cl, strings.Split(testExp, ","))
176-
}
177-
178-
for key, test := range allTests {
155+
for key, thisTest := range tests {
156+
var test cluster.Test
157+
cl.LogPrintf("TEST", "filter %s %s", key, path)
179158

180-
var res bool
181-
cl.LogPrintf("TEST : %s", test.Name)
159+
if strings.Contains(key, path) {
182160

183-
test.ConfigFile = cl.GetConf().ConfigFile
184-
if !cl.InitTestCluster(test.ConfigFile, &test) {
185-
test.Result = "ERR"
186-
} else {
187-
if test.Name == "testFailoverManual" {
188-
res = testFailoverSemisyncAutoRejoinSafeMSMXMS(cl, test.ConfigFile, &test)
189-
}
190-
if test.Name == "testFailoverSemisyncAutoRejoinSafeMSMXMS" {
191-
res = testFailoverSemisyncAutoRejoinSafeMSMXMS(cl, test.ConfigFile, &test)
192-
}
193-
if test.Name == "testFailoverSemisyncAutoRejoinSafeMSXMSM" {
194-
res = testFailoverSemisyncAutoRejoinSafeMSXMSM(cl, test.ConfigFile, &test)
195-
}
196-
if test.Name == "testFailoverSemisyncAutoRejoinSafeMSMXXXRMXMS" {
197-
res = testFailoverSemisyncAutoRejoinSafeMSMXXXRMXMS(cl, test.ConfigFile, &test)
198-
}
199-
if test.Name == "testFailoverSemisyncAutoRejoinSafeMSMXXXRXSMS" {
200-
res = testFailoverSemisyncAutoRejoinSafeMSMXXXRXSMS(cl, test.ConfigFile, &test)
201-
}
202-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSMXMS" {
203-
res = testFailoverSemisyncAutoRejoinUnsafeMSMXMS(cl, test.ConfigFile, &test)
204-
}
205-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSMXXXMXMS" {
206-
res = testFailoverSemisyncAutoRejoinUnsafeMSMXXXMXMS(cl, test.ConfigFile, &test)
207-
}
208-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSMXXXXMSM" {
209-
res = testFailoverSemisyncAutoRejoinUnsafeMSMXXXXMSM(cl, test.ConfigFile, &test)
210-
}
211-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSXMSM" {
212-
res = testFailoverSemisyncAutoRejoinUnsafeMSXMSM(cl, test.ConfigFile, &test)
213-
}
214-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSXMXXMXMS" {
215-
res = testFailoverSemisyncAutoRejoinUnsafeMSXMXXMXMS(cl, test.ConfigFile, &test)
216-
}
217-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSXMXXXMSM" {
218-
res = testFailoverSemisyncAutoRejoinUnsafeMSXMXXXMSM(cl, test.ConfigFile, &test)
219-
}
220-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSMXXXRMXMS" {
221-
res = testFailoverSemisyncAutoRejoinUnsafeMSMXXXRMXMS(cl, test.ConfigFile, &test)
222-
}
223-
if test.Name == "testFailoverSemisyncAutoRejoinUnsafeMSMXXXRXMSM" {
224-
res = testFailoverSemisyncAutoRejoinUnsafeMSMXXXRXMSM(cl, test.ConfigFile, &test)
225-
}
226-
if test.Name == "testFailoverAssyncAutoRejoinNoGtid" {
227-
res = testFailoverAssyncAutoRejoinNoGtid(cl, test.ConfigFile, &test)
228-
}
229-
if test.Name == "testFailoverAssyncAutoRejoinRelay" {
230-
res = testFailoverAssyncAutoRejoinRelay(cl, test.ConfigFile, &test)
231-
}
232-
if test.Name == "testFailoverSemisyncAutoRejoinMSSXMSXXMSXMSSM" {
233-
res = testFailoverSemisyncAutoRejoinMSSXMSXXMSXMSSM(cl, test.ConfigFile, &test)
234-
}
235-
if test.Name == "testFailoverSemisyncAutoRejoinMSSXMSXXMXSMSSM" {
236-
res = testFailoverSemisyncAutoRejoinMSSXMSXXMXSMSSM(cl, test.ConfigFile, &test)
237-
}
238-
if test.Name == "testFailoverSemisyncSlavekilledAutoRejoin" {
239-
res = testFailoverSemisyncSlavekilledAutoRejoin(cl, test.ConfigFile, &test)
240-
}
241-
if test.Name == "testFailoverSemisyncAutoRejoinFlashback" {
242-
res = testFailoverSemisyncAutoRejoinFlashback(cl, test.ConfigFile, &test)
243-
}
244-
if test.Name == "testFailoverAssyncAutoRejoinFlashback" {
245-
res = testFailoverAssyncAutoRejoinFlashback(cl, test.ConfigFile, &test)
246-
}
247-
if test.Name == "testFailoverAssyncAutoRejoinNowrites" {
248-
res = testFailoverAssyncAutoRejoinNowrites(cl, test.ConfigFile, &test)
249-
}
250-
if test.Name == "testFailoverAssyncAutoRejoinDump" {
251-
res = testFailoverAssyncAutoRejoinDump(cl, test.ConfigFile, &test)
252-
}
253-
if test.Name == "testSwitchoverAllSlavesDelayMultimasterNoRplChecksNoSemiSync" {
254-
res = testSwitchoverAllSlavesDelayMultimasterNoRplChecksNoSemiSync(cl, test.ConfigFile, &test)
255-
}
256-
if test.Name == "testSwitchoverLongTransactionNoRplCheckNoSemiSync" {
257-
res = testSwitchoverLongTransactionNoRplCheckNoSemiSync(cl, test.ConfigFile, &test)
258-
}
259-
if test.Name == "testSwitchoverLongTrxWithoutCommitNoRplCheckNoSemiSync" {
260-
res = testSwitchoverLongTrxWithoutCommitNoRplCheckNoSemiSync(cl, test.ConfigFile, &test)
261-
}
262-
if test.Name == "testSwitchoverLongQueryNoRplCheckNoSemiSync" {
263-
res = testSwitchoverLongQueryNoRplCheckNoSemiSync(cl, test.ConfigFile, &test)
264-
}
265-
if test.Name == "testSwitchoverNoReadOnlyNoRplCheck" {
266-
res = testSwitchoverNoReadOnlyNoRplCheck(cl, test.ConfigFile, &test)
267-
}
268-
if test.Name == "testSwitchoverReadOnlyNoRplCheck" {
269-
res = testSwitchoverReadOnlyNoRplCheck(cl, test.ConfigFile, &test)
270-
}
271-
if test.Name == "testSwitchover2TimesReplicationOkNoSemiSyncNoRplCheck" {
272-
res = testSwitchover2TimesReplicationOkNoSemiSyncNoRplCheck(cl, test.ConfigFile, &test)
273-
}
274-
if test.Name == "testSwitchover2TimesReplicationOkSemiSyncNoRplCheck" {
275-
res = testSwitchover2TimesReplicationOkSemiSyncNoRplCheck(cl, test.ConfigFile, &test)
276-
}
277-
if test.Name == "testSwitchoverBackPreferedMasterNoRplCheckSemiSync" {
278-
res = testSwitchoverBackPreferedMasterNoRplCheckSemiSync(cl, test.ConfigFile, &test)
279-
}
280-
if test.Name == "testSwitchoverAllSlavesStopRplCheckNoSemiSync" {
281-
res = testSwitchoverAllSlavesStopRplCheckNoSemiSync(cl, test.ConfigFile, &test)
282-
}
283-
if test.Name == "testSwitchoverAllSlavesStopNoSemiSyncNoRplCheck" {
284-
res = testSwitchoverAllSlavesStopNoSemiSyncNoRplCheck(cl, test.ConfigFile, &test)
285-
}
286-
if test.Name == "testSwitchoverAllSlavesDelayRplCheckNoSemiSync" {
287-
res = testSwitchoverAllSlavesDelayRplCheckNoSemiSync(cl, test.ConfigFile, &test)
288-
}
289-
if test.Name == "testSwitchoverAllSlavesDelayNoRplChecksNoSemiSync" {
290-
res = testSwitchoverAllSlavesDelayNoRplChecksNoSemiSync(cl, test.ConfigFile, &test)
291-
}
292-
if test.Name == "testSlaReplAllSlavesStopNoSemiSync" {
293-
res = testSlaReplAllSlavesStopNoSemiSync(cl, test.ConfigFile, &test)
294-
}
295-
if test.Name == "testSlaReplAllSlavesDelayNoSemiSync" {
296-
res = testSlaReplAllSlavesDelayNoSemiSync(cl, test.ConfigFile, &test)
297-
}
298-
if test.Name == "testFailoverNoRplChecksNoSemiSync" {
299-
res = testFailoverNoRplChecksNoSemiSync(cl, test.ConfigFile, &test)
300-
}
301-
if test.Name == "testFailoverAllSlavesDelayNoRplChecksNoSemiSync" {
302-
res = testFailoverAllSlavesDelayNoRplChecksNoSemiSync(cl, test.ConfigFile, &test)
303-
}
304-
if test.Name == "testFailoverAllSlavesDelayRplChecksNoSemiSync" {
305-
res = testFailoverAllSlavesDelayRplChecksNoSemiSync(cl, test.ConfigFile, &test)
306-
}
307-
if test.Name == "testFailoverNumberFailureLimitReach" {
308-
res = testFailoverNumberFailureLimitReach(cl, test.ConfigFile, &test)
309-
}
310-
if test.Name == "testFailoverTimeNotReach" {
311-
res = testFailoverTimeNotReach(cl, test.ConfigFile, &test)
312-
}
313-
test.Result = regtest.getTestResultLabel(res)
314-
cl.CloseTestCluster(test.ConfigFile, &test)
161+
test = thisTest
315162
allTests[key] = test
316163
}
317-
} //end loop on all tests
318-
319-
vals := make([]cluster.Test, 0, len(allTests))
320-
keys := make([]string, 0, len(allTests))
321-
for key, val := range allTests {
322-
keys = append(keys, key)
323-
vals = append(vals, val)
324-
}
325-
sort.Strings(keys)
326-
for _, v := range keys {
327-
cl.LogPrintf("TEST", "Result %s -> %s", strings.Trim(v+strings.Repeat(" ", 60-len(v)), "test"), allTests[v].Result)
328164
}
329-
cl.CleanAll = false
330-
regtest.SaveTestsFromResult(cl, allTests)
331-
return vals
165+
return allTests
332166
}
333167

334-
func (regtest *RegTest) getTestResultLabel(res bool) string {
168+
func (regtest *RegTest) GetTestResultLabel(res bool) string {
335169
if res == false {
336170
return "FAIL"
337171
} else {

regtest/test_failover_assync_autorejoin_flashback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/signal18/replication-manager/cluster"
1414
)
1515

16-
func testFailoverAssyncAutoRejoinFlashback(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
16+
func (regtest *RegTest) TestFailoverAssyncAutoRejoinFlashback(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
1717

1818
cluster.SetFailSync(false)
1919
cluster.SetInteractive(false)

regtest/test_failover_assync_autorejoin_mysqldump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/signal18/replication-manager/cluster"
1414
)
1515

16-
func testFailoverAssyncAutoRejoinDump(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
16+
func (regtest *RegTest) TestFailoverAssyncAutoRejoinDump(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
1717

1818
cluster.SetFailSync(false)
1919
cluster.SetInteractive(false)

regtest/test_failover_assync_autorejoin_nogtid.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/signal18/replication-manager/cluster"
1414
)
1515

16-
func testFailoverAssyncAutoRejoinNoGtid(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
16+
func (regtest *RegTest) TestFailoverAssyncAutoRejoinNoGtid(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
1717
cluster.SetForceSlaveNoGtid(true)
1818
cluster.SetFailSync(false)
1919
cluster.SetInteractive(false)

regtest/test_failover_assync_autorejoin_nowrite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/signal18/replication-manager/cluster"
1414
)
1515

16-
func testFailoverAssyncAutoRejoinNowrites(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
16+
func (regtest *RegTest) TestFailoverAssyncAutoRejoinNowrites(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
1717

1818
cluster.SetFailSync(false)
1919
cluster.SetInteractive(false)

regtest/test_failover_assync_autorejoin_relay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/signal18/replication-manager/cluster"
1414
)
1515

16-
func testFailoverAssyncAutoRejoinRelay(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
16+
func (regtest *RegTest) TestFailoverAssyncAutoRejoinRelay(cluster *cluster.Cluster, conf string, test *cluster.Test) bool {
1717
cluster.SetMultiTierSlave(true)
1818
cluster.SetFailSync(false)
1919
cluster.SetInteractive(false)

0 commit comments

Comments
 (0)