-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_2_correctness.txt
executable file
·96 lines (76 loc) · 2.02 KB
/
test_2_correctness.txt
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
#!/bin/bash
#
# This is a test for 5 processes. 2 crash at start and one is paused for a long time.
#
############################################
#time to wait for correct processes to broadcast all messages (in seconds)
#(should be adapted to the number of messages to send)
time_to_finish=2
init_time=2
#configure lossy network simulation
sudo tc qdisc change dev lo root netem delay 50ms 200ms loss 10% 25% reorder 25% 50%
rm membership
echo "5
1 127.0.0.1 50500
2 127.0.0.1 50501
3 127.0.0.1 50502
4 127.0.0.1 50503
5 127.0.0.1 50504" >> membership
#start 5 processes, each broadcasting 5 messages
for i in `seq 1 5`
do
./da_proc $i membership 10 &
da_proc_id[$i]=$!
done
#leave some time for process initialization
sleep $init_time
#do some nasty stuff like process crashes and delays
kill -TERM "${da_proc_id[1]}" # crash 1
da_proc_id[1]=""
kill -TERM "${da_proc_id[2]}" # crash 2
da_proc_id[2]=""
kill -STOP "${da_proc_id[3]}" # pause 3
#start broadcasting
for i in `seq 1 5`
do
if [ -n "${da_proc_id[$i]}" ]; then
kill -USR2 "${da_proc_id[$i]}"
fi
done
#sleep and wake up
sleep 10
kill -CONT "${da_proc_id[3]}" # resume 3
#leave some time for the correct processes to broadcast all messages
sleep $time_to_finish
#stop all processes
for i in `seq 1 5`
do
if [ -n "${da_proc_id[$i]}" ]; then
kill -TERM "${da_proc_id[$i]}"
fi
done
#wait until all processes stop
for i in `seq 1 5`
do
wait "${da_proc_id[$i]}"
done
#check logs for correctness
echo -e "\nTESTING PROCESS OUTPUT.\n"
#for i in `seq 1 5`; do
#filename = "da_proc_${i}.txt"
# echo "Checking file da_proc_${i}.txt."
# python check_fifo.py da_proc_${i}.txt
# python check_no_duplication_incorrect_proc.py da_proc_${i}.txt
# if [ $? -ne 0 ]; then
# echo "Error in file da_proc_${i}.txt."
# echo -e "\nTEST FAILED.\n"
# #exit 1
# fi
# shift
#done
#echo -e "\nTEST SUCCEDED.\n"
echo "Correctness test done."
echo "The test contained 5 processes;"
echo "1 and 2 crashed, and 3 paused at start,"
echo "3 later resumed;"
echo "broadcasting 5 messages each."