-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathslave_test.go
823 lines (716 loc) · 18.7 KB
/
slave_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
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
package tarantool
import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const luaMakeSnapshot = "require('box').snapshot()"
var (
tnt16User = "username"
tnt16Pass = "password"
tnt16UUID = "7c025e42-2394-11e7-aacf-0242ac110002"
)
func schemeNewReplicator(user, pass string) string {
tmpl := `
box.once('{user}:role_replication', function()
box.schema.user.create('{user}', {password = '{pass}', if_not_exists = true})
box.schema.user.grant('{user}','execute','role','replication', {if_not_exists = true})
end)
`
tmpl = strings.Replace(tmpl, "{user}", user, -1)
tmpl = strings.Replace(tmpl, "{pass}", pass, -1)
return tmpl
}
func schemeGrantRoleFunc(role, fn string) string {
scheme := `
box.once('{role}:exec_{fn}', function()
box.schema.role.grant('{role}', 'execute', 'function', '{fn}', {if_not_exists = true})
end)
`
scheme = strings.Replace(scheme, "{role}", role, -1)
scheme = strings.Replace(scheme, "{fn}", fn, -1)
return scheme
}
func schemeSpaceTester() string {
return `
box.once('space:tester', function()
local s = box.schema.space.create('tester')
local i = s:create_index('primary', {})
s:insert{1, 'Initial tuple #1'}
end)
box.once('guest:write_tester', function()
box.schema.user.grant('guest','write', 'space', 'tester', {if_not_exists = true})
end)
`
}
func newTntBox() (*Box, error) {
config := schemeNewReplicator(tnt16User, tnt16Pass)
config += schemeSpaceTester()
return NewBox(config, &BoxOptions{})
}
func TestTntBoxStart(t *testing.T) {
if testing.Short() {
t.Skip("Start this test if Slave Connect will be failed")
}
// setup TestBox
box, err := newTntBox()
require.NoError(t, err)
defer box.Close()
require.NotEmpty(t, box.Listen)
}
func TestTntBoxGuestWrite(t *testing.T) {
if testing.Short() {
t.Skip("Start this test if Slave Complex will be failed")
}
require := require.New(t)
// setup TestBox
box, err := newTntBox()
require.NoError(err)
defer box.Close()
require.NotEmpty(box.Listen)
// connect as quest
tnt, err := Connect(box.Listen, &Options{})
require.NoError(err)
defer tnt.Close()
tuple := []interface{}{int64(2), "Client inserted #2"}
res, err := tnt.Execute(&Insert{
Space: "tester",
Tuple: tuple,
})
require.NoError(err)
// check result
require.Len(res, 1)
require.Equal(tuple, res[0])
}
func TestSlaveConnect(t *testing.T) {
require := require.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
// setup
opts := Options{User: tnt16User, Password: tnt16Pass}
s, err := NewSlave(box.Listen, opts)
require.NoError(err)
// check
err = s.connect(box.Listen, opts)
require.NoError(err)
s.c.stop()
}
func TestSlaveJoinWithSnapSync(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
var expected struct {
UUID string
ReplicaSetLen int
}
// setup
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID})
defer s.Close()
if s.Version() < version1_7_0 {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 1} // one element and one reserved zero index element
} else {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 2} // one element and one reserved zero index element
}
it, err := s.JoinWithSnap()
require.NoError(err)
resultChan := make(chan bool, 1)
go func(it PacketIterator, rch chan bool) {
var p *Packet
var err error
for {
p, err = it.Next()
if err == io.EOF {
break
}
if err != nil || p == nil {
rch <- false
return
}
}
// after io.EOF p should be nil
rch <- p == nil
}(it, resultChan)
// check
timeout := time.After(10 * time.Second)
select {
case success := <-resultChan:
require.True(success, "There is nil packet or error has been happened")
case <-timeout:
t.Fatal("Timeout: there is no necessary snaplogs.")
}
assert.NotZero(s.ReplicaSet.UUID)
assert.Len(s.ReplicaSet.Instances, expected.ReplicaSetLen)
}
func TestSlaveHasNextOnJoin(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
var expected struct {
UUID string
ReplicaSetLen int
}
// setup
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID})
defer s.Close()
if s.Version() < version1_7_0 {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 1} // one element and one reserved zero index element
} else {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 2} // one element and one reserved zero index element
}
_, err = s.JoinWithSnap()
require.NoError(err)
resultChan := make(chan bool, 1)
go func(s *Slave, rch chan bool) {
for s.HasNext() {
if s.Err() != nil || s.Packet() == nil {
rch <- false
return
}
}
// after io.EOF p should be nil
rch <- s.Err() == nil && s.Packet() == nil
}(s, resultChan)
// check
timeout := time.After(10 * time.Second)
select {
case success := <-resultChan:
require.True(success, "There is nil packet or error has been happened")
case <-timeout:
t.Fatal("Timeout: there is no necessary snaplogs.")
}
assert.NotZero(s.ReplicaSet.UUID)
assert.Len(s.ReplicaSet.Instances, expected.ReplicaSetLen)
}
func TestSlaveIsEmptyChan(t *testing.T) {
s := &Slave{}
ch := make(chan *Packet)
assert.True(t, s.isEmptyChan(), "case empty params")
assert.False(t, s.isEmptyChan(ch), "case one param")
tt := []struct {
in []chan *Packet
expected bool
}{
{nil, true},
{[]chan *Packet{}, true},
{[]chan *Packet{nil}, true},
{[]chan *Packet{nil, ch}, true},
{[]chan *Packet{ch}, false},
{[]chan *Packet{ch, nil}, false},
{[]chan *Packet{ch, ch}, false},
}
for tc, item := range tt {
actual := s.isEmptyChan(item.in...)
assert.EqualValues(t, item.expected, actual, "case %v", tc+1)
}
}
func TestSlaveJoinWithSnapAsync(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
var expected struct {
UUID string
ReplicaSetLen int
}
// setup
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID})
defer s.Close()
if s.Version() < version1_7_0 {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 1} // one element and one reserved zero index element
} else {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 2} // one element and one reserved zero index element
}
respc := make(chan *Packet, 1)
var it PacketIterator
go func() {
it, err = s.JoinWithSnap(respc)
}()
// drain channel and fatal on timeout
timeout := time.After(10 * time.Second)
loop:
for {
select {
case p, open := <-respc:
if !open {
break loop
}
require.NotNil(p, "There is nil packet has been received.")
case <-timeout:
t.Fatal("Timeout: there is no necessary xlog.")
}
}
// check
assert.Nil(it)
assert.NoError(err)
assert.NotZero(s.ReplicaSet.UUID)
assert.Len(s.ReplicaSet.Instances, expected.ReplicaSetLen)
}
func TestSlaveJoin(t *testing.T) {
require := require.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
var expected struct {
UUID string
ReplicaSetLen int
}
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID})
if s.Version() < version1_7_0 {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 1} // one element and one reserved zero index element
} else {
expected = struct {
UUID string
ReplicaSetLen int
}{tnt16UUID, 1 + 2} // one element and one reserved zero index element
}
err = s.Join()
require.NoError(err)
err = s.Close()
require.NoError(err)
// check
require.NotZero(s.ReplicaSet.UUID)
require.Len(s.ReplicaSet.Instances, expected.ReplicaSetLen)
}
func TestSlaveDoubleClose(t *testing.T) {
require := require.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
})
err = s.Join()
require.NoError(err)
// check
err = s.Close()
require.NoError(err)
require.NotPanics(assert.PanicTestFunc(func() {
err = s.Close()
}))
require.NoError(err)
}
func TestSlaveSubscribeSync(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
// setup TestBox
box, err := newTntBox()
require.NoError(err)
defer box.Close()
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
})
// register in replica set
err = s.Join()
require.NoError(err)
assert.Len(s.UUID, UUIDStrLength)
assert.Len(s.ReplicaSet.UUID, UUIDStrLength)
err = s.Close()
require.NoError(err)
// new instance for the purity of the test
ns, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: s.UUID,
ReplicaSetUUID: s.ReplicaSet.UUID,
})
defer ns.Close()
it, err := ns.Subscribe(0)
require.NoError(err)
resultChan := make(chan bool, 1)
go func(it PacketIterator, rch chan bool) {
var p *Packet
var err error
for err != io.EOF {
p, err = it.Next()
if err == nil && p != nil {
if isUUIDinReplicaSet(p, s.UUID) {
rch <- true
return
}
continue
}
// if we are here something is going wrong
break
}
rch <- false
}(it, resultChan)
// check
timeout := time.After(10 * time.Second)
select {
case success := <-resultChan:
assert.True(success, "there is no packet with insert UUID in cluster space")
case <-timeout:
t.Fatal("timeout")
}
}
func TestSlaveHasNextOnSubscribe(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
// setup TestBox
box, err := newTntBox()
require.NoError(err)
defer box.Close()
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
})
// register in replica set
err = s.Join()
require.NoError(err)
err = s.Close()
require.NoError(err)
// new instance for the purity of the test
ns, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: s.UUID,
ReplicaSetUUID: s.ReplicaSet.UUID,
})
defer ns.Close()
_, err = ns.Subscribe(0)
require.NoError(err)
resultChan := make(chan bool, 1)
go func(ns *Slave, rch chan bool) {
for ns.HasNext() {
if isUUIDinReplicaSet(ns.Packet(), ns.UUID) {
rch <- true
return
}
}
rch <- false
}(ns, resultChan)
// check
timeout := time.After(10 * time.Second)
select {
case success := <-resultChan:
assert.True(success, "there is no packet with insert UUID in cluster space")
case <-timeout:
t.Fatal("timeout")
}
}
func isUUIDinReplicaSet(p *Packet, uuid string) bool {
if p == nil || len(uuid) == 0 {
return false
}
switch p.Cmd {
case InsertCommand:
q := p.Request.(*Insert)
switch q.Space {
case SpaceCluster:
if uuid == q.Tuple[1].(string) {
return true
}
}
}
return false
}
func TestSlaveVClock(t *testing.T) {
require := require.New(t)
// setup
guest := "guest"
config := schemeNewReplicator(tnt16User, tnt16Pass)
config += schemeSpaceTester()
// for making snapshot
config += schemeGrantUserEval(guest)
box, err := NewBox(config, &BoxOptions{})
require.NoError(err)
defer box.Close()
tnt, err := Connect(box.Listen, &Options{})
require.NoError(err)
defer tnt.Close()
makesnapshot := &Eval{Expression: luaMakeSnapshot}
res, err := tnt.Execute(makesnapshot)
require.NoError(err)
require.Len(res, 0, "response to make snapshot request contains error")
// check 1
s, err := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID,
})
require.NoError(err)
defer s.Close()
_, err = s.JoinWithSnap()
require.NoError(err)
var (
count int
finalDataCount int
)
// Tarantools above 1.7.0 send final data after sending data from snapshot
hasFinalDataStage := s.Version() > version1_7_0
for s.HasNext() {
// add new items to tnt concurrently while snap is downloading
field := fmt.Sprintf("Inserted tuple #%v", count+finalDataCount+2)
_, err = tnt.Execute(&Insert{
Space: "tester",
Tuple: []interface{}{uint(count) + uint(finalDataCount) + 2, field},
})
require.NoError(err)
if hasFinalDataStage && s.Packet().Cmd == InsertCommand {
request := s.Packet().Request.(*Insert)
space := request.Space.(uint)
// Space ids for user spaces begin from 512
if space > SpaceSystemMax {
finalDataCount++
continue
}
}
count++
}
require.NoError(s.Err())
joinLSN := s.VClock.LSN()
t.Logf("Join: %#v", s.VClock)
it, err := s.Subscribe(s.VClock[1:]...)
require.NoError(err)
subscribeLSN := s.VClock.LSN()
t.Logf("Subscribe: %#v", s.VClock)
assert.EqualValues(t, count, subscribeLSN-joinLSN-1)
// check 2
for ; count >= 0; count-- {
_, err = it.Next()
require.NoError(err)
}
assert.EqualValues(t, subscribeLSN, s.VClock.LSN())
}
func TestSlaveAttach(t *testing.T) {
require := require.New(t)
// setup TestBox
box, err := newTntBox()
require.NoError(err)
defer box.Close()
// setup
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
UUID: tnt16UUID})
// check
it, err := s.Attach()
require.NoError(err)
assert.NotNil(t, it)
// shutdown
err = s.Close()
require.NoError(err)
}
func TestSlaveAttachAsync(t *testing.T) {
require := require.New(t)
// setup TestBox
box, err := newTntBox()
require.NoError(err)
defer box.Close()
// setup Slave
s, _ := NewSlave(box.Listen, Options{
User: tnt16User,
Password: tnt16Pass,
})
respc := make(chan *Packet, 1)
_, err = s.Attach(respc)
require.NoError(err)
defer s.Close()
out := make(chan *Insert, 32)
go func(in <-chan *Packet, out chan *Insert) {
for packet := range in {
switch q := packet.Request.(type) {
case *Insert:
out <- q
}
}
}(respc, out)
// add new data to TestBox
tnt, err := Connect(box.Listen, &Options{})
require.NoError(err)
defer tnt.Close()
expected := []interface{}{int64(2), "Client inserted #2"}
res, err := tnt.Execute(&Insert{
Space: "tester",
Tuple: expected,
})
require.NoError(err)
require.Len(res, 1)
require.Equal(expected, res[0])
// check
timeout := time.After(10 * time.Second)
for {
select {
case qi := <-out:
if qi.Space.(uint) > SpaceSystemMax {
if num, err := numberToUint64(qi.Tuple[0]); err == nil && num > 1 {
require.EqualValues(expected, qi.Tuple)
return
}
}
case <-timeout:
t.Fatal("Timeout: there is no necessary Insert")
}
}
}
func TestSlaveParseOptionsRSParams(t *testing.T) {
require := require.New(t)
box, err := newTntBox()
require.NoError(err)
defer box.Close()
uri := fmt.Sprintf("%v:%v@%v", tnt16User, tnt16Pass, box.Listen)
tt := []struct {
opts Options
isParseErr bool
inReplica bool
}{
// good cases
{Options{UUID: "uuid1"}, false, false},
{Options{UUID: "uuid1", ReplicaSetUUID: "uuid2"}, false, true},
}
for tc, item := range tt {
s, err := NewSlave(uri, item.opts)
if item.isParseErr {
require.Error(err, fmt.Sprintf("case %v", tc+1))
// prepare handmade for second check
s = &Slave{UUID: item.opts.UUID}
s.ReplicaSet.UUID = item.opts.ReplicaSetUUID
} else {
require.NoError(err, "case %v", tc+1)
}
require.Equal(item.inReplica, s.IsInReplicaSet(), "case %v", tc+1)
}
}
func TestSlaveLastSnapVClock(t *testing.T) {
require := require.New(t)
// setup
user, role, luaDir := "guest", "replication", "lua"
luaInit, err := os.ReadFile(filepath.Join("testdata", "init.lua"))
require.NoError(err)
config := string(luaInit)
config += schemeNewReplicator(tnt16User, tnt16Pass)
config += schemeGrantRoleFunc(role, procLUALastSnapVClock)
// for making snapshot
config += schemeGrantUserEval(user)
box, err := NewBox(config, &BoxOptions{WorkDir: luaDir})
require.NoError(err)
defer box.Close()
// add replica to replica set
s, err := NewSlave(box.Listen, Options{User: tnt16User, Password: tnt16Pass})
require.NoError(err)
defer s.Close()
if s.Version() > version1_7_0 {
t.Skip("LastSnapVClock is depricated for tarantools above 1.7.0")
}
err = s.Join()
require.NoError(err)
// check init snapshot
expected := NewVectorClock(0)
vc, err := s.LastSnapVClock()
require.NoError(err)
defer s.Close()
assert.Equal(t, expected, vc, "init snapshot")
// make snapshot
tnt, err := Connect(box.Listen, &Options{})
require.NoError(err)
defer tnt.Close()
makesnapshot := &Eval{Expression: luaMakeSnapshot}
res, err := tnt.Execute(makesnapshot)
require.NoError(err)
require.Len(res, 0, "response to make snapshot request contains error")
// check newly generated snapshot
vc, err = s.LastSnapVClock()
require.NoError(err)
require.NotEqual(expected, vc)
require.True(vc.Has(2))
require.Zero(vc[2], "replica clock should be zero")
}
func TestVectorClock(t *testing.T) {
assert := assert.New(t)
expected := make([]uint64, VClockMax)
expectedLSN := uint64(0)
for i := range expected {
lsn := uint64(i * 10)
expected[i] = lsn
expectedLSN += lsn
}
vc := NewVectorClock()
// zebra filling is special test
for i := 0; i < VClockMax; i = i + 2 {
assert.True(vc.Follow(uint32(i), uint64(10*i)), "id=%v", i)
}
for i := 1; i < VClockMax; i = i + 2 {
assert.True(vc.Follow(uint32(i), uint64(10*i)), "id=%v", i)
}
// updating existing lsns
for i := VClockMax - 1; i >= 0; i-- {
assert.True(vc.Follow(uint32(i), uint64(10*i)), "id=%v", i)
}
assert.EqualValues(expected, vc)
assert.False(vc.Follow(VClockMax, 0), "VClockMax")
assert.False(vc.Follow(VClockMax+1, 0), "VClockMax+1")
assert.EqualValues(expected, vc)
assert.Equal(expectedLSN, vc.LSN(), "LSN")
}
func TestReplicaSet(t *testing.T) {
assert := assert.New(t)
expected := make([]string, ReplicaSetMaxSize)
uuidgen := func(i int) string { return fmt.Sprintf("%v%012v", tnt16UUID[:UUIDStrLength-12], i) }
for i := range expected {
expected[i] = uuidgen(i * 10)
}
rs := NewReplicaSet()
// zebra filling is special test
for i := 0; i < ReplicaSetMaxSize; i = i + 2 {
assert.True(rs.SetInstance(uint32(i), uuidgen(10*i)), "id=%v", i)
}
for i := 1; i < ReplicaSetMaxSize; i = i + 2 {
assert.True(rs.SetInstance(uint32(i), uuidgen(10*i)), "id=%v", i)
}
// updating existing lsns
for i := ReplicaSetMaxSize - 1; i >= 0; i-- {
assert.True(rs.SetInstance(uint32(i), uuidgen(10*i)), "id=%v", i)
}
assert.EqualValues(expected, rs.Instances)
assert.False(rs.SetInstance(ReplicaSetMaxSize, tnt16UUID), "ReplicaSetMax")
assert.False(rs.SetInstance(ReplicaSetMaxSize+1, tnt16UUID), "ReplicaSetMax+1")
assert.False(rs.SetInstance(0, ""), "Empty UUID")
assert.EqualValues(expected, rs.Instances)
}