forked from bakwc/PySyncObj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncobj_ut.py
executable file
·704 lines (528 loc) · 16.7 KB
/
syncobj_ut.py
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
import os
import time
import random
import threading
import cPickle
import sys
from functools import partial
import functools
import struct
from pysyncobj import SyncObj, SyncObjConf, replicated, FAIL_REASON, _COMMAND_TYPE
_bchr = functools.partial(struct.pack, 'B')
class TEST_TYPE:
DEFAULT = 0
COMPACTION_1 = 1
COMPACTION_2 = 2
RAND_1 = 3
class TestObj(SyncObj):
def __init__(self, selfNodeAddr, otherNodeAddrs,
testType = TEST_TYPE.DEFAULT,
compactionMinEntries = 0,
dumpFile = None,
password = None,
dynamicMembershipChange = False):
cfg = SyncObjConf(autoTick=False, appendEntriesUseBatch=False)
cfg.appendEntriesPeriod = 0.1
cfg.raftMinTimeout = 0.5
cfg.raftMaxTimeout = 1.0
cfg.dynamicMembershipChange = dynamicMembershipChange
if dumpFile is not None:
cfg.fullDumpFile = dumpFile
if password is not None:
cfg.password = password
if testType == TEST_TYPE.COMPACTION_1:
cfg.logCompactionMinEntries = compactionMinEntries
cfg.logCompactionMinTime = 0.1
cfg.appendEntriesUseBatch = True
if testType == TEST_TYPE.COMPACTION_2:
cfg.logCompactionMinEntries = 99999
cfg.logCompactionMinTime = 99999
cfg.fullDumpFile = dumpFile
if testType == TEST_TYPE.RAND_1:
cfg.autoTickPeriod = 0.05
cfg.appendEntriesPeriod = 0.02
cfg.raftMinTimeout = 0.1
cfg.raftMaxTimeout = 0.2
cfg.logCompactionMinTime = 9999999
cfg.logCompactionMinEntries = 9999999
super(TestObj, self).__init__(selfNodeAddr, otherNodeAddrs, cfg)
self.__counter = 0
self.__data = {}
@replicated
def addValue(self, value):
self.__counter += value
return self.__counter
@replicated
def addKeyValue(self, key, value):
self.__data[key] = value
def getCounter(self):
return self.__counter
def getValue(self, key):
return self.__data.get(key, None)
def dumpKeys(self):
print 'keys:', sorted(self.__data.keys())
def singleTickFunc(o, timeToTick, interval):
currTime = time.time()
finishTime = currTime + timeToTick
while time.time() < finishTime:
o._onTick(interval)
def doTicks(objects, timeToTick, interval = 0.05):
threads = []
for o in objects:
t = threading.Thread(target=singleTickFunc, args=(o, timeToTick, interval))
t.start()
threads.append(t)
for t in threads:
t.join()
_g_nextAddress = 6000 + 60 * (int(time.time()) % 600)
def getNextAddr():
global _g_nextAddress
_g_nextAddress += 1
return 'localhost:%d' % _g_nextAddress
def syncTwoObjects():
random.seed(42)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]])
o2 = TestObj(a[1], [a[0]])
objs = [o1, o2]
assert not o1._isReady()
assert not o2._isReady()
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1._isReady()
assert o2._isReady()
o1.addValue(150)
o2.addValue(200)
doTicks(objs, 1.5)
assert o1._isReady()
assert o2._isReady()
assert o1.getCounter() == 350
assert o2.getCounter() == 350
def syncThreeObjectsLeaderFail():
random.seed(12)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]])
o2 = TestObj(a[1], [a[2], a[0]])
o3 = TestObj(a[2], [a[0], a[1]])
objs = [o1, o2, o3]
assert not o1._isReady()
assert not o2._isReady()
assert not o3._isReady()
doTicks(objs, 4.5)
assert o1._isReady()
assert o2._isReady()
assert o3._isReady()
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1._getLeader() == o3._getLeader()
o1.addValue(150)
o2.addValue(200)
doTicks(objs, 1.5)
assert o3.getCounter() == 350
prevLeader = o1._getLeader()
newObjs = [o for o in objs if o._getSelfNodeAddr() != prevLeader]
assert len(newObjs) == 2
doTicks(newObjs, 4.5)
assert newObjs[0]._getLeader() != prevLeader
assert newObjs[0]._getLeader() in a
assert newObjs[0]._getLeader() == newObjs[1]._getLeader()
newObjs[1].addValue(50)
doTicks(newObjs, 1.5)
assert newObjs[0].getCounter() == 400
doTicks(objs, 4.5)
for o in objs:
assert o.getCounter() == 400
def manyActionsLogCompaction():
random.seed(42)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]], TEST_TYPE.COMPACTION_1, compactionMinEntries=100)
o2 = TestObj(a[1], [a[2], a[0]], TEST_TYPE.COMPACTION_1, compactionMinEntries=100)
o3 = TestObj(a[2], [a[0], a[1]], TEST_TYPE.COMPACTION_1, compactionMinEntries=100)
objs = [o1, o2, o3]
assert not o1._isReady()
assert not o2._isReady()
assert not o3._isReady()
doTicks(objs, 4.5)
assert o1._isReady()
assert o2._isReady()
assert o3._isReady()
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1._getLeader() == o3._getLeader()
for i in xrange(0, 500):
o1.addValue(1)
o2.addValue(1)
doTicks(objs, 1.5)
assert o1.getCounter() == 1000
assert o2.getCounter() == 1000
assert o3.getCounter() == 1000
assert o1._getRaftLogSize() <= 100
assert o2._getRaftLogSize() <= 100
assert o3._getRaftLogSize() <= 100
newObjs = [o1, o2]
doTicks(newObjs, 4.5)
for i in xrange(0, 500):
o1.addValue(1)
o2.addValue(1)
doTicks(newObjs, 4.0)
assert o1.getCounter() == 2000
assert o2.getCounter() == 2000
assert o3.getCounter() != 2000
doTicks(objs, 4.5)
assert o3.getCounter() == 2000
assert o1._getRaftLogSize() <= 100
assert o2._getRaftLogSize() <= 100
assert o3._getRaftLogSize() <= 100
def onAddValue(res, err, info):
assert res == 3
assert err == FAIL_REASON.SUCCESS
info['callback'] = True
def checkCallbacksSimple():
random.seed(42)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]])
o2 = TestObj(a[1], [a[2], a[0]])
o3 = TestObj(a[2], [a[0], a[1]])
objs = [o1, o2, o3]
assert not o1._isReady()
assert not o2._isReady()
assert not o3._isReady()
doTicks(objs, 4.5)
assert o1._isReady()
assert o2._isReady()
assert o3._isReady()
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1._getLeader() == o3._getLeader()
callbackInfo = {
'callback': False
}
o1.addValue(3, callback=partial(onAddValue, info=callbackInfo))
doTicks(objs, 1.5)
assert o2.getCounter() == 3
assert callbackInfo['callback'] == True
def removeFiles(files):
for f in (files):
try:
os.remove(f)
except:
pass
def checkDumpToFile():
removeFiles(['dump1.bin', 'dump2.bin'])
random.seed(42)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump1.bin')
o2 = TestObj(a[1], [a[0]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump2.bin')
objs = [o1, o2]
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
o1.addValue(150)
o2.addValue(200)
doTicks(objs, 1.5)
assert o1.getCounter() == 350
assert o2.getCounter() == 350
del o1
del o2
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump1.bin')
o2 = TestObj(a[1], [a[0]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump2.bin')
objs = [o1, o2]
doTicks(objs, 4.5)
assert o1._isReady()
assert o2._isReady()
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1.getCounter() == 350
assert o2.getCounter() == 350
removeFiles(['dump1.bin', 'dump2.bin'])
def getRandStr():
return '%0100000x' % random.randrange(16 ** 100000)
def checkBigStorage():
removeFiles(['dump1.bin', 'dump2.bin'])
random.seed(42)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]], TEST_TYPE.COMPACTION_2, dumpFile = 'dump1.bin')
o2 = TestObj(a[1], [a[0]], TEST_TYPE.COMPACTION_2, dumpFile = 'dump2.bin')
objs = [o1, o2]
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
# Store ~50Mb data.
testRandStr = getRandStr()
for i in xrange(0, 500):
o1.addKeyValue(i, getRandStr())
o1.addKeyValue('test', testRandStr)
# Wait for replication.
doTicks(objs, 40.0)
assert o1.getValue('test') == testRandStr
o1._forceLogCompaction()
o2._forceLogCompaction()
# Wait for disk dump
doTicks(objs, 5.0)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump1.bin')
o2 = TestObj(a[1], [a[0]], TEST_TYPE.COMPACTION_1, compactionMinEntries=1, dumpFile = 'dump2.bin')
objs = [o1, o2]
# Wait for disk load, election and replication
doTicks(objs, 5.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o1.getValue('test') == testRandStr
assert o2.getValue('test') == testRandStr
removeFiles(['dump1.bin', 'dump2.bin'])
def encryptionCorrectPassword():
random.seed(42)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]], password='asd')
o2 = TestObj(a[1], [a[0]], password='asd')
objs = [o1, o2]
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
o1.addValue(150)
o2.addValue(200)
doTicks(objs, 1.5)
assert o1.getCounter() == 350
assert o2.getCounter() == 350
def encryptionWrongPassword():
random.seed(12)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]], password='asd')
o2 = TestObj(a[1], [a[2], a[0]], password='asd')
o3 = TestObj(a[2], [a[0], a[1]], password='qwe')
objs = [o1, o2, o3]
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
assert o3._getLeader() is None
def _checkSameLeader(objs):
for obj1 in objs:
l1 = obj1._getLeader()
if l1 != obj1._getSelfNodeAddr():
continue
t1 = obj1._getTerm()
for obj2 in objs:
l2 = obj2._getLeader()
if l2 != obj2._getSelfNodeAddr():
continue
if obj2._getTerm() != t1:
continue
if l2 != l1:
obj1._printStatus()
obj2._printStatus()
return False
return True
def _checkSameLeader2(objs):
for obj1 in objs:
l1 = obj1._getLeader()
if l1 is None:
continue
t1 = obj1._getTerm()
for obj2 in objs:
l2 = obj2._getLeader()
if l2 is None:
continue
if obj2._getTerm() != t1:
continue
if l2 != l1:
obj1._printStatus()
obj2._printStatus()
return False
return True
def randomTest1():
random.seed(12)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]], TEST_TYPE.RAND_1)
o2 = TestObj(a[1], [a[2], a[0]], TEST_TYPE.RAND_1)
o3 = TestObj(a[2], [a[0], a[1]], TEST_TYPE.RAND_1)
objs = [o1, o2, o3]
st = time.time()
while time.time() - st < 120.0:
doTicks(objs, random.random() * 0.3, interval=0.05)
assert _checkSameLeader(objs)
assert _checkSameLeader2(objs)
for i in xrange(0, random.randint(0, 2)):
random.choice(objs).addValue(random.randint(0, 10))
newObjs = list(objs)
newObjs.pop(random.randint(0, len(newObjs) - 1))
doTicks(newObjs, random.random() * 0.3, interval=0.05)
assert _checkSameLeader(objs)
assert _checkSameLeader2(objs)
for i in xrange(0, random.randint(0, 2)):
random.choice(objs).addValue(random.randint(0, 10))
if not (o1.getCounter() == o2.getCounter() == o3.getCounter()):
print time.time(), 'counters:', o1.getCounter(), o2.getCounter(), o3.getCounter()
st = time.time()
while not (o1.getCounter() == o2.getCounter() == o3.getCounter()):
doTicks(objs, 2.0, interval=0.05)
if time.time() - st > 30:
break
if not (o1.getCounter() == o2.getCounter() == o3.getCounter()):
o1._printStatus()
o2._printStatus()
o3._printStatus()
print 'Logs same:', o1._SyncObj__raftLog == o2._SyncObj__raftLog == o3._SyncObj__raftLog
print time.time(), 'counters:', o1.getCounter(), o2.getCounter(), o3.getCounter()
raise AssertionError('Values not equal')
# Ensure that raftLog after serialization is the same as in serialized data
def logCompactionRegressionTest1():
random.seed(42)
a = [getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1]])
o2 = TestObj(a[1], [a[0]])
objs = [o1, o2]
doTicks(objs, 4.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader()
o1._forceLogCompaction()
doTicks(objs, 0.5)
assert o1._SyncObj__forceLogCompaction == False
logAfterCompaction = o1._SyncObj__raftLog
o1._SyncObj__loadDumpFile()
logAfterDeserialize = o1._SyncObj__raftLog
assert logAfterCompaction == logAfterDeserialize
def logCompactionRegressionTest2():
removeFiles(['dump1.bin', 'dump2.bin', 'dump3.bin'])
random.seed(12)
a = [getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]], dumpFile = 'dump1.bin')
o2 = TestObj(a[1], [a[2], a[0]], dumpFile = 'dump2.bin')
o3 = TestObj(a[2], [a[0], a[1]], dumpFile = 'dump3.bin')
objs = [o1, o2]
doTicks(objs, 3.5)
objs = [o1, o2, o3]
o1.addValue(2)
o1.addValue(3)
doTicks(objs, 0.5)
o3._forceLogCompaction()
doTicks(objs, 0.5)
assert o1._getLeader() in a
assert o1._getLeader() == o2._getLeader() == o3._getLeader()
o3._destroy()
del o3
objs = [o1, o2]
o1.addValue(2)
o1.addValue(3)
doTicks(objs, 0.5)
o1._forceLogCompaction()
o2._forceLogCompaction()
doTicks(objs, 0.5)
o3 = TestObj(a[2], [a[0], a[1]], dumpFile='dump3.bin')
objs = [o1, o2, o3]
doTicks(objs, 3.5)
assert o1._isReady()
assert o2._isReady()
assert o3._isReady()
removeFiles(['dump1.bin', 'dump2.bin', 'dump3.bin'])
def __checkParnerNodeExists(obj, nodeName, shouldExist = True):
nodesSet1 = set()
nodesSet2 = set(obj._SyncObj__otherNodesAddrs)
for node in obj._SyncObj__nodes:
nodesSet1.add(node.getAddress())
if nodesSet1 != nodesSet2:
print 'otherNodes:', nodesSet2
print 'nodes:', nodesSet1
assert nodesSet1 == nodesSet2
if shouldExist:
assert nodeName in nodesSet1
else:
assert nodeName not in nodesSet1
def doChangeClusterUT1():
removeFiles(['dump1.bin'])
baseAddr = getNextAddr()
oterAddr = getNextAddr()
o1 = TestObj(baseAddr, ['localhost:1235', oterAddr], dumpFile='dump1.bin', dynamicMembershipChange=True)
__checkParnerNodeExists(o1, 'localhost:1238', False)
__checkParnerNodeExists(o1, 'localhost:1239', False)
__checkParnerNodeExists(o1, 'localhost:1235', True)
noop = _bchr(_COMMAND_TYPE.NO_OP)
member = _bchr(_COMMAND_TYPE.MEMBERSHIP)
# Check regular configuration change - adding
o1._onMessageReceived('localhost:12345', {
'type': 'append_entries',
'term': 1,
'prevLogIdx': 1,
'prevLogTerm': 0,
'commit_index': 2,
'entries': [(noop, 2, 1), (noop, 3, 1), (member + cPickle.dumps(['add', 'localhost:1238']), 4, 1)]
})
__checkParnerNodeExists(o1, 'localhost:1238', True)
__checkParnerNodeExists(o1, 'localhost:1239', False)
# Check rollback adding
o1._onMessageReceived('localhost:1236', {
'type': 'append_entries',
'term': 2,
'prevLogIdx': 2,
'prevLogTerm': 1,
'commit_index': 3,
'entries': [(noop, 3, 2), (member + cPickle.dumps(['add', 'localhost:1239']), 4, 2)]
})
__checkParnerNodeExists(o1, 'localhost:1238', False)
__checkParnerNodeExists(o1, 'localhost:1239', True)
__checkParnerNodeExists(o1, oterAddr, True)
# Check regular configuration change - removing
o1._onMessageReceived('localhost:1236', {
'type': 'append_entries',
'term': 2,
'prevLogIdx': 4,
'prevLogTerm': 2,
'commit_index': 4,
'entries': [(member + cPickle.dumps(['rem', 'localhost:1235']), 5, 2)]
})
__checkParnerNodeExists(o1, 'localhost:1238', False)
__checkParnerNodeExists(o1, 'localhost:1239', True)
__checkParnerNodeExists(o1, 'localhost:1235', False)
# Check log compaction
o1._forceLogCompaction()
doTicks([o1], 0.5)
o1._destroy()
del o1
o2 = TestObj(oterAddr, [baseAddr, 'localhost:1236'], dumpFile='dump1.bin', dynamicMembershipChange=True)
doTicks([o2], 0.5)
__checkParnerNodeExists(o2, oterAddr, False)
__checkParnerNodeExists(o2, baseAddr, True)
__checkParnerNodeExists(o2, 'localhost:1238', False)
__checkParnerNodeExists(o2, 'localhost:1239', True)
__checkParnerNodeExists(o2, 'localhost:1235', False)
def doChangeClusterUT2():
a = [getNextAddr(), getNextAddr(), getNextAddr(), getNextAddr()]
o1 = TestObj(a[0], [a[1], a[2]], dynamicMembershipChange=True)
o2 = TestObj(a[1], [a[2], a[0]], dynamicMembershipChange=True)
o3 = TestObj(a[2], [a[0], a[1]], dynamicMembershipChange=True)
doTicks([o1, o2, o3], 3.5)
assert o1._isReady() == o2._isReady() == o3._isReady() == True
o3.addValue(50)
o2._addNodeToCluster(a[3])
doTicks([o1, o2, o3], 1.5)
__checkParnerNodeExists(o1, a[3], True)
__checkParnerNodeExists(o2, a[3], True)
__checkParnerNodeExists(o3, a[3], True)
o4 = TestObj(a[3], [a[0], a[1], a[2]], dynamicMembershipChange=True)
doTicks([o1, o2, o3, o4], 3.5)
o1.addValue(450)
doTicks([o1, o2, o3, o4], 1.5)
assert o4._isReady()
assert o4.getCounter() == 500
def runTests():
useCrypto = True
if len(sys.argv) > 1 and sys.argv[1] == 'nocrypto':
useCrypto = False
syncTwoObjects()
syncThreeObjectsLeaderFail()
manyActionsLogCompaction()
logCompactionRegressionTest1()
logCompactionRegressionTest2()
checkCallbacksSimple()
doChangeClusterUT1()
doChangeClusterUT2()
checkDumpToFile()
checkBigStorage()
randomTest1()
if useCrypto:
encryptionCorrectPassword()
encryptionWrongPassword()
print '[SUCCESS]'
if __name__ == '__main__':
runTests()