-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_test.go
749 lines (647 loc) · 20.1 KB
/
test_test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
package kvraft
import "../porcupine"
import "../models"
import "testing"
import "strconv"
import "time"
import "math/rand"
import "log"
import "strings"
import "sync"
import "sync/atomic"
import "fmt"
import "io/ioutil"
// The tester generously allows solutions to complete elections in one second
// (much more than the paper's range of timeouts).
const electionTimeout = 1 * time.Second
const linearizabilityCheckTimeout = 1 * time.Second
// get/put/putappend that keep counts
func Get(cfg *config, ck *Clerk, key string) string {
v := ck.Get(key)
cfg.op()
return v
}
func Put(cfg *config, ck *Clerk, key string, value string) {
ck.Put(key, value)
cfg.op()
}
func Append(cfg *config, ck *Clerk, key string, value string) {
ck.Append(key, value)
cfg.op()
}
func check(cfg *config, t *testing.T, ck *Clerk, key string, value string) {
v := Get(cfg, ck, key)
if v != value {
t.Fatalf("Get(%v): expected:\n%v\nreceived:\n%v", key, value, v)
}
}
// a client runs the function f and then signals it is done
func run_client(t *testing.T, cfg *config, me int, ca chan bool, fn func(me int, ck *Clerk, t *testing.T)) {
ok := false
defer func() { ca <- ok }()
ck := cfg.makeClient(cfg.All())
fn(me, ck, t)
ok = true
cfg.deleteClient(ck)
}
// spawn ncli clients and wait until they are all done
func spawn_clients_and_wait(t *testing.T, cfg *config, ncli int, fn func(me int, ck *Clerk, t *testing.T)) {
ca := make([]chan bool, ncli)
for cli := 0; cli < ncli; cli++ {
ca[cli] = make(chan bool)
go run_client(t, cfg, cli, ca[cli], fn)
}
// log.Printf("spawn_clients_and_wait: waiting for clients")
for cli := 0; cli < ncli; cli++ {
ok := <-ca[cli]
// log.Printf("spawn_clients_and_wait: client %d is done\n", cli)
if ok == false {
t.Fatalf("failure")
}
}
}
// predict effect of Append(k, val) if old value is prev.
func NextValue(prev string, val string) string {
return prev + val
}
// check that for a specific client all known appends are present in a value,
// and in order
func checkClntAppends(t *testing.T, clnt int, v string, count int) {
lastoff := -1
for j := 0; j < count; j++ {
wanted := "x " + strconv.Itoa(clnt) + " " + strconv.Itoa(j) + " y"
off := strings.Index(v, wanted)
if off < 0 {
t.Fatalf("%v missing element %v in Append result %v", clnt, wanted, v)
}
off1 := strings.LastIndex(v, wanted)
if off1 != off {
t.Fatalf("duplicate element %v in Append result", wanted)
}
if off <= lastoff {
t.Fatalf("wrong order for element %v in Append result", wanted)
}
lastoff = off
}
}
// check that all known appends are present in a value,
// and are in order for each concurrent client.
func checkConcurrentAppends(t *testing.T, v string, counts []int) {
nclients := len(counts)
for i := 0; i < nclients; i++ {
lastoff := -1
for j := 0; j < counts[i]; j++ {
wanted := "x " + strconv.Itoa(i) + " " + strconv.Itoa(j) + " y"
off := strings.Index(v, wanted)
if off < 0 {
t.Fatalf("%v missing element %v in Append result %v", i, wanted, v)
}
off1 := strings.LastIndex(v, wanted)
if off1 != off {
t.Fatalf("duplicate element %v in Append result", wanted)
}
if off <= lastoff {
t.Fatalf("wrong order for element %v in Append result", wanted)
}
lastoff = off
}
}
}
// repartition the servers periodically
func partitioner(t *testing.T, cfg *config, ch chan bool, done *int32) {
defer func() { ch <- true }()
for atomic.LoadInt32(done) == 0 {
a := make([]int, cfg.n)
for i := 0; i < cfg.n; i++ {
a[i] = (rand.Int() % 2)
}
pa := make([][]int, 2)
for i := 0; i < 2; i++ {
pa[i] = make([]int, 0)
for j := 0; j < cfg.n; j++ {
if a[j] == i {
pa[i] = append(pa[i], j)
}
}
}
cfg.partition(pa[0], pa[1])
time.Sleep(electionTimeout + time.Duration(rand.Int63()%200)*time.Millisecond)
}
}
// Basic test is as follows: one or more clients submitting Append/Get
// operations to set of servers for some period of time. After the period is
// over, test checks that all appended values are present and in order for a
// particular key. If unreliable is set, RPCs may fail. If crash is set, the
// servers crash after the period is over and restart. If partitions is set,
// the test repartitions the network concurrently with the clients and servers. If
// maxraftstate is a positive number, the size of the state for Raft (i.e., log
// size) shouldn't exceed 8*maxraftstate. If maxraftstate is negative,
// snapshots shouldn't be used.
func GenericTest(t *testing.T, part string, nclients int, unreliable bool, crash bool, partitions bool, maxraftstate int) {
title := "Test: "
if unreliable {
// the network drops RPC requests and replies.
title = title + "unreliable net, "
}
if crash {
// peers re-start, and thus persistence must work.
title = title + "restarts, "
}
if partitions {
// the network may partition
title = title + "partitions, "
}
if maxraftstate != -1 {
title = title + "snapshots, "
}
if nclients > 1 {
title = title + "many clients"
} else {
title = title + "one client"
}
title = title + " (" + part + ")" // 3A or 3B
const nservers = 5
cfg := make_config(t, nservers, unreliable, maxraftstate)
defer cfg.cleanup()
cfg.begin(title)
ck := cfg.makeClient(cfg.All())
done_partitioner := int32(0)
done_clients := int32(0)
ch_partitioner := make(chan bool)
clnts := make([]chan int, nclients)
for i := 0; i < nclients; i++ {
clnts[i] = make(chan int)
}
for i := 0; i < 3; i++ {
// log.Printf("Iteration %v\n", i)
atomic.StoreInt32(&done_clients, 0)
atomic.StoreInt32(&done_partitioner, 0)
go spawn_clients_and_wait(t, cfg, nclients, func(cli int, myck *Clerk, t *testing.T) {
j := 0
defer func() {
clnts[cli] <- j
}()
last := ""
key := strconv.Itoa(cli)
Put(cfg, myck, key, last)
for atomic.LoadInt32(&done_clients) == 0 {
if (rand.Int() % 1000) < 500 {
nv := "x " + strconv.Itoa(cli) + " " + strconv.Itoa(j) + " y"
// log.Printf("%d: client new append %v\n", cli, nv)
Append(cfg, myck, key, nv)
last = NextValue(last, nv)
j++
} else {
// log.Printf("%d: client new get %v\n", cli, key)
v := Get(cfg, myck, key)
if v != last {
log.Fatalf("get wrong value, key %v, wanted:\n%v\n, got\n%v\n", key, last, v)
}
}
}
})
if partitions {
// Allow the clients to perform some operations without interruption
time.Sleep(1 * time.Second)
go partitioner(t, cfg, ch_partitioner, &done_partitioner)
}
time.Sleep(5 * time.Second)
atomic.StoreInt32(&done_clients, 1) // tell clients to quit
atomic.StoreInt32(&done_partitioner, 1) // tell partitioner to quit
if partitions {
// log.Printf("wait for partitioner\n")
<-ch_partitioner
// reconnect network and submit a request. A client may
// have submitted a request in a minority. That request
// won't return until that server discovers a new term
// has started.
cfg.ConnectAll()
// wait for a while so that we have a new term
time.Sleep(electionTimeout)
}
if crash {
Pf("")
Pf("")
Pf("")
Pf("")
Pf("")
log.Printf("shutdown servers\n")
Pf("")
Pf("")
Pf("")
for i := 0; i < nservers; i++ {
cfg.ShutdownServer(i)
}
// Wait for a while for servers to shutdown, since
// shutdown isn't a real crash and isn't instantaneous
time.Sleep(electionTimeout)
// log.Printf("restart servers\n")
// crash and re-start all
for i := 0; i < nservers; i++ {
cfg.StartServer(i)
}
cfg.ConnectAll()
}
// log.Printf("wait for clients\n")
for i := 0; i < nclients; i++ {
// log.Printf("read from clients %d\n", i)
j := <-clnts[i]
// if j < 10 {
// log.Printf("Warning: client %d managed to perform only %d put operations in 1 sec?\n", i, j)
// }
key := strconv.Itoa(i)
// log.Printf("Check %v for client %d\n", j, i)
v := Get(cfg, ck, key)
checkClntAppends(t, i, v, j)
}
if maxraftstate > 0 {
// Check maximum after the servers have processed all client
// requests and had time to checkpoint.
sz := cfg.LogSize()
if sz > 8*maxraftstate {
t.Fatalf("logs were not trimmed (%v > 8*%v)", sz, maxraftstate)
}
}
if maxraftstate < 0 {
// Check that snapshots are not used
ssz := cfg.SnapshotSize()
if ssz > 0 {
t.Fatalf("snapshot too large (%v), should not be used when maxraftstate = %d", ssz, maxraftstate)
}
}
}
cfg.end()
}
// similar to GenericTest, but with clients doing random operations (and using a
// linearizability checker)
func GenericTestLinearizability(t *testing.T, part string, nclients int, nservers int, unreliable bool, crash bool, partitions bool, maxraftstate int) {
title := "Test: "
if unreliable {
// the network drops RPC requests and replies.
title = title + "unreliable net, "
}
if crash {
// peers re-start, and thus persistence must work.
title = title + "restarts, "
}
if partitions {
// the network may partition
title = title + "partitions, "
}
if maxraftstate != -1 {
title = title + "snapshots, "
}
if nclients > 1 {
title = title + "many clients"
} else {
title = title + "one client"
}
title = title + ", linearizability checks (" + part + ")" // 3A or 3B
cfg := make_config(t, nservers, unreliable, maxraftstate)
defer cfg.cleanup()
cfg.begin(title)
begin := time.Now()
var operations []porcupine.Operation
var opMu sync.Mutex
done_partitioner := int32(0)
done_clients := int32(0)
ch_partitioner := make(chan bool)
clnts := make([]chan int, nclients)
for i := 0; i < nclients; i++ {
clnts[i] = make(chan int)
}
for i := 0; i < 3; i++ {
// log.Printf("Iteration %v\n", i)
atomic.StoreInt32(&done_clients, 0)
atomic.StoreInt32(&done_partitioner, 0)
go spawn_clients_and_wait(t, cfg, nclients, func(cli int, myck *Clerk, t *testing.T) {
j := 0
defer func() {
clnts[cli] <- j
}()
for atomic.LoadInt32(&done_clients) == 0 {
key := strconv.Itoa(rand.Int() % nclients)
nv := "x " + strconv.Itoa(cli) + " " + strconv.Itoa(j) + " y"
var inp models.KvInput
var out models.KvOutput
start := int64(time.Since(begin))
if (rand.Int() % 1000) < 500 {
Append(cfg, myck, key, nv)
inp = models.KvInput{Op: 2, Key: key, Value: nv}
j++
} else if (rand.Int() % 1000) < 100 {
Put(cfg, myck, key, nv)
inp = models.KvInput{Op: 1, Key: key, Value: nv}
j++
} else {
v := Get(cfg, myck, key)
inp = models.KvInput{Op: 0, Key: key}
out = models.KvOutput{Value: v}
}
end := int64(time.Since(begin))
op := porcupine.Operation{Input: inp, Call: start, Output: out, Return: end, ClientId: cli}
opMu.Lock()
operations = append(operations, op)
opMu.Unlock()
}
})
if partitions {
// Allow the clients to perform some operations without interruption
time.Sleep(1 * time.Second)
go partitioner(t, cfg, ch_partitioner, &done_partitioner)
}
time.Sleep(5 * time.Second)
atomic.StoreInt32(&done_clients, 1) // tell clients to quit
atomic.StoreInt32(&done_partitioner, 1) // tell partitioner to quit
if partitions {
// log.Printf("wait for partitioner\n")
<-ch_partitioner
// reconnect network and submit a request. A client may
// have submitted a request in a minority. That request
// won't return until that server discovers a new term
// has started.
cfg.ConnectAll()
// wait for a while so that we have a new term
time.Sleep(electionTimeout)
}
if crash {
// log.Printf("shutdown servers\n")
for i := 0; i < nservers; i++ {
cfg.ShutdownServer(i)
}
// Wait for a while for servers to shutdown, since
// shutdown isn't a real crash and isn't instantaneous
time.Sleep(electionTimeout)
// log.Printf("restart servers\n")
// crash and re-start all
for i := 0; i < nservers; i++ {
cfg.StartServer(i)
}
cfg.ConnectAll()
}
// wait for clients.
for i := 0; i < nclients; i++ {
<-clnts[i]
}
if maxraftstate > 0 {
// Check maximum after the servers have processed all client
// requests and had time to checkpoint.
sz := cfg.LogSize()
if sz > 8*maxraftstate {
t.Fatalf("logs were not trimmed (%v > 8*%v)", sz, maxraftstate)
}
}
}
cfg.end()
res, info := porcupine.CheckOperationsVerbose(models.KvModel, operations, linearizabilityCheckTimeout)
if res == porcupine.Illegal {
file, err := ioutil.TempFile("", "*.html")
if err != nil {
fmt.Printf("info: failed to create temp file for visualization")
} else {
err = porcupine.Visualize(models.KvModel, info, file)
if err != nil {
fmt.Printf("info: failed to write history visualization to %s\n", file.Name())
} else {
fmt.Printf("info: wrote history visualization to %s\n", file.Name())
}
}
t.Fatal("history is not linearizable")
t.Fatal("history is not linearizable")
} else if res == porcupine.Unknown {
fmt.Println("info: linearizability check timed out, assuming history is ok")
}
}
func TestBasic3A(t *testing.T) {
// Test: one client (3A) ...
GenericTest(t, "3A", 1, false, false, false, -1)
}
func TestConcurrent3A(t *testing.T) {
// Test: many clients (3A) ...
GenericTest(t, "3A", 5, false, false, false, -1)
}
func TestUnreliable3A(t *testing.T) {
// Test: unreliable net, many clients (3A) ...
GenericTest(t, "3A", 5, true, false, false, -1)
}
func TestUnreliableOneKey3A(t *testing.T) {
const nservers = 3
cfg := make_config(t, nservers, true, -1)
defer cfg.cleanup()
ck := cfg.makeClient(cfg.All())
cfg.begin("Test: concurrent append to same key, unreliable (3A)")
Put(cfg, ck, "k", "")
const nclient = 5
const upto = 10
spawn_clients_and_wait(t, cfg, nclient, func(me int, myck *Clerk, t *testing.T) {
n := 0
for n < upto {
Append(cfg, myck, "k", "x "+strconv.Itoa(me)+" "+strconv.Itoa(n)+" y")
n++
}
})
var counts []int
for i := 0; i < nclient; i++ {
counts = append(counts, upto)
}
vx := Get(cfg, ck, "k")
checkConcurrentAppends(t, vx, counts)
cfg.end()
}
// Submit a request in the minority partition and check that the requests
// doesn't go through until the partition heals. The leader in the original
// network ends up in the minority partition.
func TestOnePartition3A(t *testing.T) {
const nservers = 5
cfg := make_config(t, nservers, false, -1)
defer cfg.cleanup()
ck := cfg.makeClient(cfg.All())
Put(cfg, ck, "1", "13")
cfg.begin("Test: progress in majority (3A)")
p1, p2 := cfg.make_partition()
cfg.partition(p1, p2)
ckp1 := cfg.makeClient(p1) // connect ckp1 to p1
ckp2a := cfg.makeClient(p2) // connect ckp2a to p2
ckp2b := cfg.makeClient(p2) // connect ckp2b to p2
Put(cfg, ckp1, "1", "14")
check(cfg, t, ckp1, "1", "14")
cfg.end()
done0 := make(chan bool)
done1 := make(chan bool)
cfg.begin("Test: no progress in minority (3A)")
go func() {
Put(cfg, ckp2a, "1", "15")
done0 <- true
}()
go func() {
Get(cfg, ckp2b, "1") // different clerk in p2
done1 <- true
}()
select {
case <-done0:
t.Fatalf("Put in minority completed")
case <-done1:
t.Fatalf("Get in minority completed")
case <-time.After(time.Second):
}
check(cfg, t, ckp1, "1", "14")
Put(cfg, ckp1, "1", "16")
check(cfg, t, ckp1, "1", "16")
cfg.end()
cfg.begin("Test: completion after heal (3A)")
cfg.ConnectAll()
cfg.ConnectClient(ckp2a, cfg.All())
cfg.ConnectClient(ckp2b, cfg.All())
time.Sleep(electionTimeout)
select {
case <-done0:
case <-time.After(30 * 100 * time.Millisecond):
t.Fatalf("Put did not complete")
}
select {
case <-done1:
case <-time.After(30 * 100 * time.Millisecond):
t.Fatalf("Get did not complete")
default:
}
check(cfg, t, ck, "1", "15")
cfg.end()
}
func TestManyPartitionsOneClient3A(t *testing.T) {
// Test: partitions, one client (3A) ...
GenericTest(t, "3A", 1, false, false, true, -1)
}
func TestManyPartitionsManyClients3A(t *testing.T) {
// Test: partitions, many clients (3A) ...
GenericTest(t, "3A", 5, false, false, true, -1)
}
func TestPersistOneClient3A(t *testing.T) {
// Test: restarts, one client (3A) ...
GenericTest(t, "3A", 1, false, true, false, -1)
}
func TestPersistConcurrent3A(t *testing.T) {
// Test: restarts, many clients (3A) ...
GenericTest(t, "3A", 5, false, true, false, -1)
}
func TestPersistConcurrentUnreliable3A(t *testing.T) {
// Test: unreliable net, restarts, many clients (3A) ...
GenericTest(t, "3A", 5, true, true, false, -1)
}
func TestPersistPartition3A(t *testing.T) {
// Test: restarts, partitions, many clients (3A) ...
GenericTest(t, "3A", 5, false, true, true, -1)
}
func TestPersistPartitionUnreliable3A(t *testing.T) {
// Test: unreliable net, restarts, partitions, many clients (3A) ...
GenericTest(t, "3A", 5, true, true, true, -1)
}
func TestPersistPartitionUnreliableLinearizable3A(t *testing.T) {
// Test: unreliable net, restarts, partitions, linearizability checks (3A) ...
GenericTestLinearizability(t, "3A", 15, 7, true, true, true, -1)
}
//
// if one server falls behind, then rejoins, does it
// recover by using the InstallSnapshot RPC?
// also checks that majority discards committed log entries
// even if minority doesn't respond.
//
func TestSnapshotRPC3B(t *testing.T) {
const nservers = 3
maxraftstate := 1000
cfg := make_config(t, nservers, false, maxraftstate)
defer cfg.cleanup()
ck := cfg.makeClient(cfg.All())
cfg.begin("Test: InstallSnapshot RPC (3B)")
Put(cfg, ck, "a", "A")
check(cfg, t, ck, "a", "A")
// a bunch of puts into the majority partition.
cfg.partition([]int{0, 1}, []int{2})
{
ck1 := cfg.makeClient([]int{0, 1})
for i := 0; i < 50; i++ {
Put(cfg, ck1, strconv.Itoa(i), strconv.Itoa(i))
}
time.Sleep(electionTimeout)
Put(cfg, ck1, "b", "B")
}
// check that the majority partition has thrown away
// most of its log entries.
sz := cfg.LogSize()
if sz > 8*maxraftstate {
t.Fatalf("logs were not trimmed (%v > 8*%v)", sz, maxraftstate)
}
// now make group that requires participation of
// lagging server, so that it has to catch up.
cfg.partition([]int{0, 2}, []int{1})
{
Pf("FAILING")
ck1 := cfg.makeClient([]int{0, 2})
Put(cfg, ck1, "c", "C")
Put(cfg, ck1, "d", "D")
check(cfg, t, ck1, "a", "A")
check(cfg, t, ck1, "b", "B")
check(cfg, t, ck1, "1", "1")
check(cfg, t, ck1, "49", "49")
}
// now everybody
cfg.partition([]int{0, 1, 2}, []int{})
Put(cfg, ck, "e", "E")
check(cfg, t, ck, "c", "C")
check(cfg, t, ck, "e", "E")
check(cfg, t, ck, "1", "1")
cfg.end()
}
// are the snapshots not too huge? 500 bytes is a generous bound for the
// operations we're doing here.
func TestSnapshotSize3B(t *testing.T) {
const nservers = 3
maxraftstate := 1000
maxsnapshotstate := 500
cfg := make_config(t, nservers, false, maxraftstate)
defer cfg.cleanup()
ck := cfg.makeClient(cfg.All())
cfg.begin("Test: snapshot size is reasonable (3B)")
for i := 0; i < 200; i++ {
Put(cfg, ck, "x", "0")
check(cfg, t, ck, "x", "0")
Put(cfg, ck, "x", "1")
check(cfg, t, ck, "x", "1")
Pf("CASE: %v",i)
}
Pf("CHECKED ")
// check that servers have thrown away most of their log entries
sz := cfg.LogSize()
if sz > 8*maxraftstate {
t.Fatalf("logs were not trimmed (%v > 8*%v)", sz, maxraftstate)
}
// check that the snapshots are not unreasonably large
ssz := cfg.SnapshotSize()
if ssz > maxsnapshotstate {
t.Fatalf("snapshot too large (%v > %v)", ssz, maxsnapshotstate)
}
cfg.end()
}
func TestSnapshotRecover3B(t *testing.T) {
// Test: restarts, snapshots, one client (3B) ...
GenericTest(t, "3B", 1, false, true, false, 1000)
}
func TestSnapshotRecoverManyClients3B(t *testing.T) {
// Test: restarts, snapshots, many clients (3B) ...
GenericTest(t, "3B", 20, false, true, false, 1000)
}
func TestSnapshotUnreliable3B(t *testing.T) {
// Test: unreliable net, snapshots, many clients (3B) ...
GenericTest(t, "3B", 5, true, false, false, 1000)
}
func TestSnapshotUnreliableRecover3B(t *testing.T) {
// Test: unreliable net, restarts, snapshots, many clients (3B) ...
GenericTest(t, "3B", 5, true, true, false, 1000)
}
func TestSnapshotUnreliableRecoverConcurrentPartition3B(t *testing.T) {
// Test: unreliable net, restarts, partitions, snapshots, many clients (3B) ...
GenericTest(t, "3B", 5, true, true, true, 1000)
}
func TestSnapshotUnreliableRecoverConcurrentPartitionLinearizable3B(t *testing.T) {
// Test: unreliable net, restarts, partitions, snapshots, linearizability checks (3B) ...
GenericTestLinearizability(t, "3B", 15, 7, true, true, true, 1000)
}