-
Notifications
You must be signed in to change notification settings - Fork 0
/
StressTest-v1-930517.sh
594 lines (449 loc) · 22.9 KB
/
StressTest-v1-930517.sh
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
#!/bin/bash
function seprator(){
for((i=0;i<80;i++))
do
echo -n "*"
done
echo ""
}
clear
# introduction
seprator
echo " Auto-test Stress"
echo " written by Mahya MKashani"
echo " Copyright 2014. Mahya Mkashani"
echo " E-Mail : mahya.mkashani@gmail.com"
seprator
echo "First, please check Stress tool is installed or not!(your user should be root.) "
seprator
sleep 5
#installing test
i=0;
while [ $i -eq 0 ]
do
if [ $(dpkg-query -W -f='${Status}' stress 2>/dev/null | grep -c "ok installed") -eq 1 ]
then
echo "Stress test is installed"
i=1
else
echo "Sorry! Stress test is'nt installed, please try again."
read -r -p "Would you Install stress ?(Y/N) " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
apt-get install stress
echo "StressTest tool is installed"
i=1
elif [[ $response =~ ^([nN][oO]|[nN])$ ]]
then
echo " you cant work with stress test because of non installization,the program is stopped"
i=1
exit
else
echo "you must type y/n or yes/no to continue process:"
fi
# end if for response question
fi
# end if for install stress package
done
if [ $(dpkg-query -W -f='${Status}' stress 2>/dev/null | grep -c "ok installed") -eq 0 ]
then
echo "sorry, Stress Test is not installed on your system. So test will be stopped!"
exit
fi
# end if for ensure about install Stress package
seprator
while true
do
# explanations of test
i=0;
echo " If this is your first time test that test your system with StressTest, please read description."
while [ $i -eq 0 ]
do
read -r -p "Would you like to know more about stress test ?(Y/N) " describe
if [[ $describe =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Stress Test has different options :"
echo "Stress Test has 4 branches: cpu test,memory test,io test,hard disk test : "
echo "1- cpu test : is spawn N workers spinning on sqrt() function,you should determine timeout after N seconds(or minute,hour,days or even years)"
echo "range of cpu test with this config : cpu' core i7 3.4Ghz' is 5000 processes, although systems are different each other "
echo "2- memory test : has options to ensure memory is healthy ,you should determine that how many processes you need and for each process how many size of memory you need? "
echo "memory :test of memory has 3 section,you could choose each one for testing "
echo "2-1 memory : first test memory is to ensure about healthy by mallocate and free byte of memory nonstop"
echo "2-2 Stride memory : second test is touching byte of memory when mallocate memory then free it."
echo "2-3 hang memory : third test is mallocate byte of memory and mallocated volume's is freed after N seconds "
echo "3- io test :is Spawn N workers that you chooose it, sppinnig on sync() function."
echo "4- hard disk test: for this test you should determine that how many process you need and for each process how many sizes of hard you need? "
echo "Notice : if you dont know about config of your system please check it and you should check your temprature of cores of cpu and how many sizes of cpu/memory volumes is remained , if you need check temprature of cpu please type 'sensor' and if you need check config of system type 'lshw' and 'cpuinfo' if you need check temrature of hard please type 'hddtemp' if you need how many cpu/memory's volumes is remained type 'htop' "
echo "Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size)"
i=1
elif [[ $describe =~ ^([nN][oO]|[nN])$ ]]
then
echo " you couldnt see description about the test"
i=1
else
echo "you should type y/n or yes/no please type this words!"
fi
done
seprator
# start test
i=0;
while [ $i -eq 0 ]
do
read -r -p "Would you like to start the test ?(Y/N) " starttest
if [[ $starttest =~ ^([yY][eE][sS]|[yY])$ ]]
then
clear
while true
do
clear
echo "please choose one of the tests "
echo "if test cpu write 'c' "
echo "if test memory write 'm' "
echo "if test io write 'i' "
echo "if test hard disk write 'h' "
echo "if exit from test 'e' "
read -p "please choose one of the tests?(c,m,i,h,e) " cmih
case $cmih in
#cpu test
[Cc] ) read -p "how many processes would you need ?" workers
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --cpu $workers --timeout $stoptimming --verbose >verbosingcpu
if [ $(grep -c "successful" verbosingcpu) -eq 1 ] && [ $(grep -c "FAIL" verbosingcpu) -eq 0 ]
then
stress --cpu $workers --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --cpu $workers --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingcpu "
if [ $(grep -c "FAIL" verbosingcpu) -ge 1 ]
then
echo "test of cpu is failed while debugging"
else
echo "test of cpu is failed while running"
fi
sleep 10
fi
else
stress --cpu $workers --timeout $stoptimming --verbose >verbosingcpu
if [ $(grep -c "successful" verbosingcpu) -eq 1 ] && [ $(grep -c "FAIL" verbosingcpu) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingcpu "
if [ $(grep -c "FAIL" verbosingcpu) -ge 1 ]
then
echo "test of cpu is failed while debugging"
else
echo "test of cpu is failed while running"
fi
sleep 10
fi
fi;;
# memory test
[Mm] )
while true
do
clear
echo "please choose one of the memory test "
echo "if memory test is about allocate and free volume without stop write 'v' "
echo "if memory test is about allocate volume by touching memory then free it, write 's' "
echo " if memory test is about allocate memory after N secondes then free it(hang memory after N seconds), write 'h'"
echo "if exit from memory test 'x' "
read -p "please choose one of the tests?(v,s,h,x) " vshx
case $vshx in
#test of memory nonstop mallocate and free memory
[Vv])
clear
read -p "how many processes would you need ?" workers
read -p "how much size would you need to allocate from memory ?(write digit number with sufix size(B,K,M,G),'example:10G'" sizemem
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --vm $workers --vm-bytes $sizemem --timeout $stoptimming --verbose >verbosingmem
if [ $(grep -c "successful" verbosingmem) -eq 1 ] && [ $(grep -c "FAIL" verbosingmem) -eq 0 ]
then
stress --vm $workers --vm-bytes $sizemem --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --vm $workers --vm-bytes $sizemem --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmem "
if [ $(grep -c "FAIL" verbosingmem) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
else
stress --vm $workers --vm-bytes $sizemem --timeout $stoptimming --verbose >verbosingmem
if [ $(grep -c "successful" verbosingmem) -eq 1 ] && [ $(grep -c "FAIL" verbosingmem) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmem "
if [ $(grep -c "FAIL" verbosingmem) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
fi;;
#test memory by touching bytes of memory allocate it then free
[Ss])
clear
read -p "how many processes would you need ?" workers
read -p "how much size would you need to allocate from memory for stride memory test ?(write digit number with sufix size(B,K,M,G),'example:10G'" sizemem
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --vm $workers --vm-stride $sizemem --timeout $stoptimming --verbose >verbosingmemstride
if [ $(grep -c "successful" verbosingmemstride) -eq 1 ] && [ $(grep -c "FAIL" verbosingmemstride) -eq 0 ]
then
stress --vm $workers --vm-stride $sizemem --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --vm $workers --vm-stride $sizemem --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmemstride "
if [ $(grep -c "FAIL" verbosingmemstride) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
else
stress --vm $workers --vm-stride $sizemem --timeout $stoptimming --verbose >verbosingmemstride
if [ $(grep -c "successful" verbosingmemstride) -eq 1 ] && [ $(grep -c "FAIL" verbosingmemstride) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmemstride "
if [ $(grep -c "FAIL" verbosingmemstride) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
fi;;
# test of memory by allocated bytes of memory hang memory this sistuation after N secondes is freed allocated memory
[Hh])
clear
read -p "how many processes would you need ?" workers
read -p "how much size would you need to allocate from memory ?(write digit number with sufix size(B,K,M,G),'example:10G'" sizemem
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "how much time do you like to hang memory for allocatting and cant free it(your time should be a digit number (10)?" stoptimehang
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --vm $workers --vm-bytes $sizemem --vm-hang $stoptimehang --timeout $stoptimming --verbose >verbosingmemhang
if [ $(grep -c "successful" verbosingmemhang) -eq 1 ] && [ $(grep -c "FAIL" verbosingmemhang) -eq 0 ]
then
stress --vm $workers --vm-bytes $sizemem --vm-hang $stoptimehang --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --vm $workers --vm-bytes $sizemem --vm-hang $stoptimehang --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmemhang "
if [ $(grep -c "FAIL" verbosingmemhang) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
else
stress --vm $workers --vm-bytes $sizemem --vm-hang $stoptimehang --timeout $stoptimming --verbose >verbosingmemhang
if [ $(grep -c "successful" verbosingmemhang) -eq 1 ] && [ $(grep -c "FAIL" verbosingmemhang) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingmemhang "
if [ $(grep -c "FAIL" verbosingmemhang) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
fi;;
# break from test of memory
[Xx]) break;;
*) echo "you should type v,s,h or x character"
sleep 5 ;;
esac
done;;
# io test
[Ii] )
read -p "how many processes would you need ?" workers
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --io $workers --timeout $stoptimming --verbose >verbosingio
if [ $(grep -c "successful" verbosingio) -eq 1 ] && [ $(grep -c "FAIL" verbosingio) -eq 0 ]
then
stress --io $workers --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --io $workers --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingio "
if [ $(grep -c "FAIL" verbosingio) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
else
stress --io $workers --timeout $stoptimming --verbose >verbosingio
if [ $(grep -c "successful" verbosingio) -eq 1 ] && [ $(grep -c "FAIL" verbosingio) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosingio "
if [ $(grep -c "FAIL" verbosingio) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
fi;;
#hard disk test
[Hh] )
read -p "how many processes would you need ?" workers
read -p "how much size would you need to allocate from hard disk ?(write digit number with sufix size(B,K,M,G),'example:10G'" sizehdd
read -p "how much time do you like to stop the test(your time should be a digit number with suffix time (10s)?" stoptimming
read -p "would you like to explain more about the test?(Y/N)" description
if [[ $description =~ ^([yY][eE][sS]|[yY])$ ]]
then
stress --hdd $workers --hdd-bytes $sizehdd --timeout $stoptimming --verbose >verbosinghard
if [ $(grep -c "successful" verbosinghard) -eq 1 ] && [ $(grep -c "FAIL" verbosinghard) -eq 0 ]
then
stress --hdd $workers --hdd-bytes $sizehdd --timeout $stoptimming --verbose
seprator
echo "****************(test passed)*****************"
sleep 10
else
stress --hdd $workers --hdd-bytes $sizehdd --timeout $stoptimming --verbose
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosinghard "
if [ $(grep -c "FAIL" verbosinghard) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
else
stress --hdd $workers --hdd-bytes $sizehdd --timeout $stoptimming --verbose >verbosinghard
if [ $(grep -c "successful" verbosinghard) -eq 1 ] && [ $(grep -c "FAIL" verbosinghard) -eq 0 ]
then
seprator
echo "****************(test passed)*****************"
sleep 10
else
seprator
echo "****************(test failed)****************"
echo "you can see log from this test in file of verbosinghard "
if [ $(grep -c "FAIL" verbosinghard) -ge 1 ]
then
echo "test of memory is failed while debugging"
else
echo "test of memory is failed while running"
fi
sleep 10
fi
fi;;
[Ee] ) break;;
*) echo "you should type c,m,i,h or e character"
sleep 5 ;;
esac
done
i=1;
elif [[ $starttest =~ ^([nN][oO]|[nN])$ ]]
then
echo "you should stop the test!"
sleep 2
i=1;
else
echo "you should type yes/no or y/n! "
fi
done
#end
clear
b=0;
while [ $b -eq 0 ]
do
read -r -p "Would you like to stop the test ?(Y/N) " stoptest
if [[ $stoptest =~ ^([yY][eE][sS]|[yY])$ ]]
then
clear
b=1;
exit
elif [[ $stoptest =~ ^([nN][oO]|[nN])$ ]]
then
seprator
b=1;
else
echo "you should type y/n or yes or no type."
seprator
fi
done
done