summaryrefslogtreecommitdiffstats
path: root/sanity/top_profile/top_profile.sh
blob: 439c2bf66dc94d523d2d072ada4a8db28c24b8ce (plain)
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
824
825
826
827
828
829
830
831
832
833
834
#!/bin/bash

#The script assumes that 'glusterd' is running in all the machines which would become part of the cluster.
#If 'glusterd'is not running, please stop the script run glusterd and then re-execute the script.Script doen not check if 'glusterd'is running or not. 
#The script should be executed from the machine which would be part of the cluster.
#This script takes care of creating volumes and staring them. It aslo takes care of doing operations on them. 

if [ $# -ne 2 ];then
	echo "Usage: $0 <host1> <host2>"
	exit 111;
fi

assert_success ()
{
	if [ $1 -eq 0 ];then
		echo "PASS"
	else
		echo "FAIL"
	fi
}

assert_failure ()
{
	if [ $1 -ne 0 ];then
		echo "PASS"
	else
		echo "FAIL"
	fi
}

host1=$1;
host2=$2;

echo "KEY: peer probing and volume creation Tests";

gluster peer probe $host1;
echo "probing $host1: $(assert_success $?)";

gluster peer probe $host2;
echo "probing $host2: $(assert_success $?)";

gluster volume create hosdu $host1:/tmp/brick1 $host2:/tmp/brick2
echo "Creating volume: $(assert_success $?)";

gluster volume start hosdu 
echo "Starting volume: $(assert_success $?)";

echo "KEY: basic profile tests (profile start|stop|info)";

gluster volume profile hosdu start
echo "start profiling: $(assert_success $?)";
sleep 5; #This sleep is for all the bricks to come online(up).

gluster volume profile hosdu info
echo "profile info: $(assert_success $?)";

gluster volume profile hosdu stop
echo "stop profiling: $(assert_success $?)";

gluster volume profile hosdu stop
echo "stop profiling agian: $(assert_failure $?)";

gluster volume profile hosdu start
echo "start profiling: $(assert_success $?)";

gluster volume profile hosdu start
echo "start profile again: $(assert_failure $?)";

gluster volume profile hosdu stop
echo "stop profile: $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_failure $?)";

gluster volume stop hosdu --mode=script
echo "stopping volume: $(assert_success $?)";

gluster volume profile hosdu start
echo "profile stop after volume stop: $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info after volume stop: $(assert_failure $?)";

gluster volume start hosdu
echo "re-starting volume: $(assert_success $?)";

gluster volume profile hosdu start
echo "re-starting profile: $(assert_failure $?)";

gluster volume stop hosdu --mode=script
echo "stopping volume again: $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_failure $?)";

gluster volume start hosdu
sleep 5; #This time is for all the bricks to come online(up).

gluster volume profile hosdu stop
echo "stopping profile: $(assert_success $?)";

echo "KEY: profile tests after volume set instead of profile start";

gluster volume set hosdu count-fop-hits on
echo "set 'count-fop-hits': $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_failure $?)";

gluster volume set hosdu latency-measurement on
echo "set 'latency-measurement': $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_success $?)";

gluster volume reset hosdu
echo "reset volume option: $(assert_success $?)";

gluster volume set hosdu latency-measurement on
echo "set 'latency-measurenent': $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_failure $?)";

gluster volume set hosdu count-fop-hits on
echo "set count-fop-hits': $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info: $(assert_success $?)";

gluster volume profile hosdu stop 
echo "profile stop: $(assert_success $?)";

gluster volume profile hosdu info
echo "profile info after profile stop: $(assert_failure $?)";

gluster volume profile hosdu start
echo "profile start: $(assert_success $?)";


gluster volume profile hosdu info | grep "nan"
echo "'grep'ing for 'nan' in profile info: $(assert_failure $?)";

echo "KEY: tests after writing data on the mount point";

mount -t glusterfs $host1:hosdu /mnt/

for i in {1..20}
do
	dd if=/dev/zero of=/mnt/$i bs=128K count=10 2>/dev/null 1>/dev/null
	dd if=/mnt/$i of=/dev/null bs=128K count=10 2>/dev/null 1>/dev/null  
done

umount /mnt/

gluster volume profile hosdu info | grep "brick1"
echo "'grep'ing for brick1 in profile info: $(assert_success $?)";

gluster volume profile hosdu info | grep "brick2"
echo "'grep'ing for bruck2 in profile info: $(assert_success $?)";


temp=`gluster volume profile hosdu info | grep "Interval 5 Stats:" | wc -l`
if [ $temp -eq 2 ];then
	echo "'grep'ing for Interval 5 stats: $(assert_success 0)";
else
	echo "'grep'ing for Interval 5 stats: $(assert_success 1)";
fi

echo "KEY: profile tests after add-brick and rebalance";

gluster volume add-brick hosdu $host1:/tmp/brick3/
echo "adding brick3 to volume: $(assert_success $?)";

sleep 5; #This sleep time is for brick3 to come up.

gluster volume profile hosdu info | grep "brick3"
echo "grep for brick3 in profile info after add-brick: $(assert_success $?)";

gluster volume rebalance hosdu start | grep "starting rebalance on volume hosdu has been successful"
echo "rebalance after add-brick: $(assert_success $?)";

temp=0;
while [ $temp -eq 0 ]
do
	temp=`gluster volume rebalance hosdu status | grep "rebalance completed" | wc -l`
done

gluster volume profile hosdu info | grep "Interval 1 Stats"
echo "grep for Interval 1 stats in profile info: $(assert_success $?)";

gluster volume info | grep "count-fop-hits" 
echo "grep for count-fop-hits in volume info: $(assert_success $?)";

gluster volume info | grep "latency-measurement" 
echo "grep for latency-measurement in volume info: $(assert_success $?)";

gluster volume profile hosdu stop
echo "stop profiling: $(assert_success $?)";

gluster volume info | grep "count-fop-hits" 
echo "grep for count-fop-hits after profile stop: $(assert_failure $?)";

gluster volume info | grep "latency-measurement" 
echo "grep for latency-measurement after profile stop: $(assert_failure $?)";

echo "KEY: profile tests after remove-brick";

gluster volume remove-brick hosdu $host1:/tmp/brick1/ --mode=script
echo "remove-brick brick1: $(assert_success $?)";

gluster volume profile hosdu start
echo "start profiling: $(assert_success $?)";
sleep 5; 

gluster volume profile hosdu info | grep "brick1"
echo "grep for brick1 in profile info: $(assert_failure $?)";

gluster volume profile hosdu info | grep "brick2"
echo "grep for brick2: $(assert_success $?)";

gluster volume profile hosdu info | grep "brick3"
echo "grep for brick3: $(assert_success $?)";

echo "KEY: profile tests after replace-brick";

gluster volume replace-brick hosdu $host1:/tmp/brick3/ $host2:/tmp/brick4/ start
echo "replace-brick start from brick3 to brick4: $(assert_success $?)";

temp=0;
count=0;
while [ $temp -eq 0 ]&&[ $count -ne 10 ]
do
	temp=`gluster volume replace-brick hosdu $host1:/tmp/brick3/ $host2:/tmp/brick4/ status | grep "Migration complete" | wc -l`;
	sleep 3;
	let count++;
done

if [ $temp -eq 0 ];then
	echo "KEY: Replace-brick failed"
else
	echo "KEY: Replace-brick Migration Completed"
fi

gluster volume profile hosdu info | grep "brick4"
assert_failure $?;

gluster volume replace-brick hosdu $host1:/tmp/brick3/ $host2:/tmp/brick4/ commit
assert_success $?;
sleep 4;

gluster volume profile hosdu info | grep "brick4"
assert_success $?;

gluster volume stop  hosdu --mode=script
assert_success $?;

gluster volume profile hosdu info
assert_failure $?;

gluster volume start hosdu
assert_success $?;
sleep 4;

gluster volume profile hosdu info
assert_success $?;

gluster volume stop hosdu --mode=script 
assert_success $?;

#gluster volume delete hosdu --mode=script 
#assert_success $?;

echo "KEY: profile tests complete"

#######################################################################################################################################
#							TOP OPERATIONS
#######################################################################################################################################

echo "KEY: volume top tests"

gluster volume start hosdu
assert_success $?;

mount -t glusterfs $host1:hosdu /mnt/

rm -rf /mnt/* #host2:brick2 and host2:brick4 are there in the volume from here on
for i in {1..100}
do
	dd if=/dev/zero of=/mnt/$i bs=128K count=100 2>/dev/null 1>/dev/null
	dd if=/mnt/$i of=/dev/null bs=128K count=100 2>/dev/null 1>/dev/null
done

echo "KEY: tests for top open";

gluster volume top hosdu open
assert_success $?;

gluster volume top hosdu open list-cnt 100
assert_success $?;


gluster volume top hosdu open brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu open brick $host2:/tmp/brick4/ list-cnt 50
assert_success $?;

gluster volume top hosdu open list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu open list-cnt 0 
assert_success $?;

gluster volume top hosdu open list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu open list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

echo "KEY: tests for top read";

gluster volume top hosdu read
assert_success $?;

gluster volume top hosdu read list-cnt 100
assert_success $?;


gluster volume top hosdu read brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu read brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu read list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu read list-cnt 0 
assert_success $?;

gluster volume top hosdu read list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu read list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

echo "KEY: tests for top write";

gluster volume top hosdu write
assert_success $?;

gluster volume top hosdu write list-cnt 100
assert_success $?;


gluster volume top hosdu write brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu write brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu write list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu write list-cnt 0 
assert_success $?;

gluster volume top hosdu write list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu write list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

echo "KEY: tests for top opendir";

gluster volume top hosdu opendir
assert_success $?;

gluster volume top hosdu opendir list-cnt 100
assert_success $?;

gluster volume top hosdu opendir brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu opendir brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu opendir list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu opendir list-cnt 0 
assert_success $?;

gluster volume top hosdu opendir list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu opendir list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

echo "KEY: test for top readdir";

gluster volume top hosdu readdir
assert_success $?;

gluster volume top hosdu readdir list-cnt 100
assert_success $?;

gluster volume top hosdu readdir brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu readdir brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu readdir list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu readdir list-cnt 0 
assert_success $?;

gluster volume top hosdu readdir list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu readdir list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

echo "KEY:tests for top write-perf"

gluster volume top hosdu write-perf
assert_success $?;

gluster volume top hosdu write-perf list-cnt 100
assert_success $?;


gluster volume top hosdu write-perf brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu write-perf brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu write-perf list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu write-perf list-cnt 0 
assert_success $?;

gluster volume top hosdu write-perf list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu write-perf list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

gluster volume top hosdu write-perf bs 1024 count 100 list-cnt 10 
assert_success $?;

gluster volume top hosdu write-perf bs 1024 count 100 list-cnt 10  | grep "Throughput"
assert_success $?;

gluster volume top hosdu write-perf bs ff count 100 | grep "block size should be an integer"
assert_success $?;

gluster volume top hosdu write-perf bs 1024 count ff | grep "count should be an integer"
assert_success $?;

gluster volume top hosdu write-perf bs 0 count 100 | grep "block size should be an integer greater than zero"
assert_success $?;

gluster volume top hosdu write-perf count 0 bs 1024 | grep "count should be an integer greater than zero" 
assert_success $?;

gluster volume top hosdu write-perf bs 278947357438574675467857689456945896758967586746789678957689459675 count 100 brick $host2:/tmp/brick4/ | grep "block size is an invalid number"
assert_success $?;

gluster volume top hosdu write-perf bs 1024 count 1000000000000000000000000000000000000000000000000000000000000000000000 brick $host2:/tmp/brick2/ | grep "count is an invalid number"
assert_success $?;

gluster volume top hosdu write-perf list-cnt 1 bs 2048 brick $host2:/tmp/brick2/ count 100
assert_success $?;

gluster volume top hosdu write-porf list-cnt 4575475 | grep "list-cnt should be between 0 and 100"
assert_failure $?;
 
gluster volume top hosdu write-porf list-cnt 4575475 | grep -i "Usage:"
assert_success $?;

echo "KEY: tests for top read-perf";

gluster volume top hosdu read-perf
assert_success $?;

gluster volume top hosdu read-perf list-cnt 100
assert_success $?;


gluster volume top hosdu read-perf brick $host2:/tmp/brick2/ list-cnt 10
assert_success $?;

gluster volume top hosdu read-perf brick $host2:/tmp/brick4/ list-cnt 40 
assert_success $?;

gluster volume top hosdu read-perf list-cnt 222 | grep "list-cnt should be between 0 to 100"
assert_success $?;

gluster volume top hosdu read-perf list-cnt 0 
assert_success $?;

gluster volume top hosdu read-perf list-cnt 10 brick $host2:/tmp/brick3/
assert_failure $?;

gluster volume top hosdu read-perf list-cnt brick $host2:/tmp/brick2/ 100 | grep -i "Usage:"
assert_success $?;

gluster volume top hosdu read-perf bs 1024 count 100 list-cnt 10 
assert_success $?;

gluster volume top hosdu read-perf bs 1024 count 100 list-cnt 10  | grep "Throughput"
assert_success $?;

gluster volume top hosdu read-perf bs ff count 100 | grep "block size should be an integer"
assert_success $?;

gluster volume top hosdu read-perf bs 1024 count ff | grep "count should be an integer"
assert_success $?;

gluster volume top hosdu read-perf bs 0 count 100 | grep "block size should be an integer greater than zero"
assert_success $?;

gluster volume top hosdu read-perf count 0 bs 1024 | grep "count should be an integer greater than zero" 
assert_success $?;

gluster volume top hosdu read-perf bs 278947357438574675467857689456945896758967586746789678957689459675 count 100 brick $host2:/tmp/brick4/ | grep "block size is an invalid number"
assert_success $?;

gluster volume top hosdu read-perf bs 1024 count 1000000000000000000000000000000000000000000000000000000000000000000000 brick $host2:/tmp/brick2/ | grep "count is an invalid number"
assert_success $?;

gluster volume top hosdu read-perf list-cnt 1 bs 2048 brick $host2:/tmp/brick2/ count 100
assert_success $?;

gluster volume top hosdu read-porf list-cnt 4575475 | grep "list-cnt should be between 0 and 100"
assert_failure $?;
 
gluster volume top hosdu read-porf list-cnt 4575475 | grep -i "Usage:"
assert_success $?;




########################### Run tests after adding brick and removing brick etc #################3

echo "KEY: Tests for volume top after add-brick";

gluster volume add-brick hosdu $host1:/tmp/brick5/ #Now the total number of bricks are brick2 and brick4 is Host2 and brick5 in host1 
assert_success $?;

gluster volume rebalance hosdu start | grep "starting rebalance on volume hosdu has been successful"
assert_success $?;

temp=0;
while [ $temp -eq 0 ]
do
	temp=`gluster volume rebalance hosdu status | grep "rebalance completed" | wc -l`
done

gluster volume top hosdu open brick $host1:/tmp/brick5/
assert_success $?;

gluster volume top hosdu read brick $host1:/tmp/brick5/
assert_success $?;

gluster volume top hosdu write brick $host1:/tmp/brick5/
assert_success $?;

gluster volume top hosdu write-perf brick $host1:/tmp/brick5/ bs 1024 count 100
assert_success $?;

gluster volume top hosdu read-perf brick $host1:/tmp/brick5/ bs 2048 count 10
assert_success $?;

gluster volume top hosdu opendir brick $host1:/tmp/brick5/
assert_success $?;

gluster volume top hosdu readdir brick $host1:/tmp/brick5/
assert_success $?;

echo "KEY: volume top tests after remove-brick";

gluster volume remove-brick hosdu $host2:/tmp/brick2/ --mode=script #keyword: $host1:brick5 $host2:brick4 are bricks from here on
assert_success $?;

gluster volume top hosdu open brick $host2:/tmp/brick2/
assert_failure $?;

gluster volume top hosdu read brick $host2:/tmp/brick2/
assert_failure $?;

gluster volume top hosdu write brick $host2:/tmp/brick2/
assert_failure $?;

gluster volume top hosdu write-perf brick $host2:/tmp/brick2/ bs 1024 count 100
assert_failure $?;

gluster volume top hosdu read-perf brick $host2:/tmp/brick2/ bs 2048 count 10
assert_failure $?;

gluster volume top hosdu opendir brick $host2:/tmp/brick2/ list-cnt 100
assert_failure $?;

gluster volume top hosdu readdir brick $host2:/tmp/brick2/ list-cnt 10
assert_failure $?;

echo "KEY: volume top tests after replace-brick, before commit";

gluster volume replace-brick hosdu $host2:/tmp/brick4/ $host1:/tmp/brick6/ start
echo "replace-brick from brick4 to brick6: $(assert_success $?)";

temp=0;
count=0;
while [ $temp -eq 0 ]&&[ $count -ne 10 ]
do
	temp=`gluster volume replace-brick hosdu $host2:/tmp/brick4/ $host1:/tmp/brick6/ status | grep "Migration complete" | wc -l`;
	sleep 3;
	let count++;
done

if [ $temp -eq 0 ];then
	echo "KEY: Replace-brick operation failed";
else
	echo "KEY: Replace-brick Migration Complete";
fi

gluster volume top hosdu open brick $host1:/tmp/brick6/
assert_failure $?;

gluster volume top hosdu open brick $host2:/tmp/brick4/
assert_success $?;

gluster volume top hosdu read brick $host1:/tmp/brick6/
assert_failure $?;

gluster volume top hosdu read brick $host2:/tmp/brick4/
assert_success $?;

gluster volume top hosdu write brick $host1:/tmp/brick6/
assert_failure $?;

gluster volume top hosdu write brick $host2:/tmp/brick4/
assert_success $?;

gluster volume top hosdu write-perf brick $host1:/tmp/brick6/ bs 1024 count 100
assert_failure $?;

gluster volume top hosdu write-perf brick $host2:/tmp/brick4/ bs 1024 count 100
assert_success $?;

gluster volume top hosdu read-perf brick $host1:/tmp/brick6/ bs 2048 count 10
assert_failure $?;

gluster volume top hosdu read-perf brick $host2:/tmp/brick4/ bs 2048 count 10
assert_success $?;

gluster volume top hosdu opendir brick $host1:/tmp/brick6/ list-cnt 100
assert_failure $?;

gluster volume top hosdu opendir brick $host2:/tmp/brick4/ list-cnt 100
assert_success $?;

gluster volume top hosdu readdir brick $host1:/tmp/brick6/ list-cnt 10
assert_failure $?;

gluster volume top hosdu readdir brick $host2:/tmp/brick4/ list-cnt 10
assert_success $?;

echo "KEY: volume top tests after replace-brick, after commit";

gluster volume replace-brick hosdu $host2:/tmp/brick4/ $host1:/tmp/brick6/ commit # keyword: $host1:brick6 and $host1:/brick5
assert_success $?;
sleep 4;

gluster volume top hosdu open brick $host1:/tmp/brick6/
assert_success $?;

gluster volume top hosdu open brick $host2:/tmp/brick4/
assert_failure $?;

gluster volume top hosdu read brick $host1:/tmp/brick6/
assert_success $?;

gluster volume top hosdu read brick $host2:/tmp/brick4/
assert_failure $?;

gluster volume top hosdu write brick $host1:/tmp/brick6/
assert_success $?;

gluster volume top hosdu write brick $host2:/tmp/brick4/
assert_failure $?;

gluster volume top hosdu write-perf brick $host1:/tmp/brick6/ bs 1024 count 100
assert_success $?;

gluster volume top hosdu write-perf brick $host2:/tmp/brick4/ bs 1024 count 100
assert_failure $?;

gluster volume top hosdu read-perf brick $host1:/tmp/brick6/ bs 2048 count 10
assert_success $?;

gluster volume top hosdu read-perf brick $host2:/tmp/brick4/ bs 2048 count 10
assert_failure $?;

gluster volume top hosdu opendir brick $host1:/tmp/brick6/ list-cnt 100
assert_success $?;

gluster volume top hosdu opendir brick $host2:/tmp/brick4/ list-cnt 100
assert_failure $?;

gluster volume top hosdu readdir brick $host1:/tmp/brick6/ list-cnt 10
assert_success $?;

gluster volume top hosdu readdir brick $host2:/tmp/brick4/ list-cnt 10
assert_failure $?;

rm -rf /mnt/*

cpwd=`pwd`;

cd /mnt/

for i in {1..101}
do
mkdir dir$i;
cd dir$i;
done

cd $cpwd;

echo "KEY: tests for validating the list count numbers in the volume top";

temp=`gluster volume top hosdu opendir list-cnt 100 | wc -l`
if [ $temp -eq 5 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top hosdu readdir list-cnt 100 | wc -l`
if [ $temp -eq 5 ];then
	assert_success 0;
else
	assert_success 1;
fi

rm -rf /mnt/*;
umount /mnt/;
gluster volume stop hosdu --mode=script
gluster volume delete hosdu --mode=script

gluster volume create another $host1:/tmp/Brick
gluster volume start another 

mount -t glusterfs $host1:another /mnt/

for i in {1..100}
do
	dd if=/dev/zero of=/mnt/$i bs=128K count=100 2>/dev/null 1>/dev/null
	dd if=/mnt/$i of=/dev/null bs=128K count=100 2>/dev/null 1>/dev/null
done

temp=`gluster volume top another open list-cnt 100 | wc -l`
if [ $temp -eq 105 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another read list-cnt 100 | wc -l`
if [ $temp -eq 104 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another write list-cnt 100 | wc -l`
if [ $temp -eq 104 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another write-perf list-cnt 100 | wc -l`
if [ $temp -eq 104 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another write-perf bs 1024 count 100 list-cnt 100 | wc -l`
if [ $temp -eq 105 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another read-perf list-cnt 100 | wc -l`
if [ $temp -eq 104 ];then
	assert_success 0;
else
	assert_success 1;
fi

temp=`gluster volume top another read-perf bs 1024 count 100 list-cnt 100 | wc -l`
if [ $temp -eq 105 ];then
	assert_success 0;
else
	assert_success 1;
fi

echo "KEY: volume top tests complete"

#cleaing up the mess
rm -rf /mnt/*
umount /mnt/
gluster volume stop another --mode=script
gluster volume delete another --mode=script

#Ugly Temporary hack. Remove ut as soon as possible
rm -rf /tmp/brick*
rm -rf /tmp/Brick

echo "Sanity for Top/Profile completed. Exiting the script..."

exit 0;

################################# The End #################################################