|
1 # |
|
2 # Copyright 2005-2006 Intel Corporation |
|
3 # |
|
4 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 # you may not use this file except in compliance with the License. |
|
6 # You may obtain a copy of the License at |
|
7 # |
|
8 # http://www.apache.org/licenses/LICENSE-2.0 |
|
9 # |
|
10 # Unless required by applicable law or agreed to in writing, software |
|
11 # distributed under the License is distributed on an "AS IS" BASIS, |
|
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 # See the License for the specific language governing permissions and |
|
14 # limitations under the License. |
|
15 # |
|
16 |
|
17 test::name bidirectional |
|
18 net::num_nodes 3 |
|
19 |
|
20 set cl tcp |
|
21 set count 200 |
|
22 set storage_type filesysdb |
|
23 |
|
24 foreach {var val} $opt(opts) { |
|
25 if {$var == "-cl" || $var == "cl"} { |
|
26 set cl $val |
|
27 } elseif {$var == "-count" || $var == "count"} { |
|
28 set count $val |
|
29 } elseif {$var == "-storage_type" } { |
|
30 set storage_type $val |
|
31 } else { |
|
32 testlog error "ERROR: unrecognized test option '$var'" |
|
33 exit 1 |
|
34 } |
|
35 } |
|
36 |
|
37 dtn::config --no_null_link --storage_type $storage_type |
|
38 |
|
39 dtn::config_interface $cl |
|
40 dtn::config_app_manifest 1 |
|
41 dtn::config_linear_topology ALWAYSON $cl true |
|
42 |
|
43 conf::add dtnd * "param set early_deletion false" |
|
44 |
|
45 # XXX/demmer do this test with bigger bundles... |
|
46 |
|
47 test::script { |
|
48 set N [net::num_nodes] |
|
49 set last [expr $N - 1] |
|
50 |
|
51 set eid1 dtn://host-0/test |
|
52 set eid2 dtn://host-$last/test |
|
53 |
|
54 set sleep 100 |
|
55 |
|
56 # ---------------------------------------------------------------------- |
|
57 testlog " " |
|
58 testlog " Test phase 1: continuous connectivity" |
|
59 testlog " " |
|
60 |
|
61 testlog " Running dtnds" |
|
62 dtn::run_dtnd * |
|
63 |
|
64 testlog " Waiting for dtnds to start up" |
|
65 dtn::wait_for_dtnd * |
|
66 |
|
67 testlog " Running senders / receivers for $count bundles, sleep $sleep" |
|
68 set rcvpid1 [dtn::run_app 0 dtnrecv "-q -n $count $eid1"] |
|
69 set rcvpid2 [dtn::run_app $last dtnrecv "-q -n $count $eid2"] |
|
70 set sndpid1 [dtn::run_app 0 dtnsend "-s $eid1 -d $eid2 -t d -z $sleep -n $count"] |
|
71 set sndpid2 [dtn::run_app $last dtnsend "-s $eid2 -d $eid1 -t d -z $sleep -n $count"] |
|
72 |
|
73 testlog " Waiting for senders / receivers to complete (up to 5 mins)" |
|
74 run::wait_for_pid_exit 0 $sndpid1 [expr 5 * 60] |
|
75 run::wait_for_pid_exit $last $sndpid2 [expr 5 * 60] |
|
76 run::wait_for_pid_exit 0 $rcvpid1 [expr 5 * 60] |
|
77 run::wait_for_pid_exit $last $rcvpid2 [expr 5 * 60] |
|
78 |
|
79 testlog " Waiting for all events to be processed" |
|
80 dtn::wait_for_daemon_stats 0 {0 pending_events} |
|
81 dtn::wait_for_daemon_stats 1 {0 pending_events} |
|
82 dtn::wait_for_daemon_stats 2 {0 pending_events} |
|
83 |
|
84 foreach node [list 0 $last] { |
|
85 testlog " Checking bundle stats on node $node" |
|
86 dtn::check_bundle_stats $node \ |
|
87 $count "delivered" \ |
|
88 [expr $count * 2] "received" |
|
89 } |
|
90 |
|
91 for {set i 0} {$i < $N} {incr i} { |
|
92 testlog "Node $i: [dtn::tell_dtnd $i bundle stats]" |
|
93 } |
|
94 |
|
95 testlog " Checking link stats" |
|
96 dtn::check_link_stats 0 $cl-link:0-1 1 contacts $count bundles_transmitted |
|
97 dtn::check_link_stats 1 $cl-link:1-0 1 contacts |
|
98 |
|
99 testlog " Stopping dtnds" |
|
100 dtn::stop_dtnd * |
|
101 |
|
102 # ---------------------------------------------------------------------- |
|
103 testlog " " |
|
104 testlog " Test phase 2: interrupted links" |
|
105 testlog " " |
|
106 |
|
107 testlog " Running dtnds" |
|
108 dtn::run_dtnd * |
|
109 |
|
110 testlog " Waiting for dtnds to start up" |
|
111 dtn::wait_for_dtnd * |
|
112 |
|
113 testlog " Running senders / receivers for $count bundles, sleep $sleep" |
|
114 set rcvpid1 [dtn::run_app 0 dtnrecv "-q -n $count $eid1"] |
|
115 set rcvpid2 [dtn::run_app $last dtnrecv "-q -n $count $eid2"] |
|
116 set sndpid1 [dtn::run_app 0 dtnsend "-s $eid1 -d $eid2 -t d -z $sleep -n $count"] |
|
117 set sndpid2 [dtn::run_app $last dtnsend "-s $eid2 -d $eid1 -t d -z $sleep -n $count"] |
|
118 |
|
119 for {set i 0} {$i < 100} {incr i} { |
|
120 after [expr int(10000 * rand())] |
|
121 |
|
122 testlog " Closing links to/from node 1 ([test::elapsed] seconds elapsed)" |
|
123 tell_dtnd 0 link close $cl-link:0-1 |
|
124 tell_dtnd 1 link close $cl-link:1-2 |
|
125 |
|
126 dtn::dump_stats |
|
127 |
|
128 after [expr int(5000 * rand())] |
|
129 testlog " Opening links to/from node 1 ([test::elapsed] seconds elapsed)" |
|
130 tell_dtnd 0 link open $cl-link:0-1 |
|
131 tell_dtnd 1 link open $cl-link:1-2 |
|
132 |
|
133 # if it finishes early, break out of the loop |
|
134 if {[dtn::get_bundle_stats 0 delivered] == $count} { break } |
|
135 } |
|
136 |
|
137 testlog " Done will link closing loop, stats:" |
|
138 for {set i 0} {$i < $N} {incr i} { |
|
139 testlog "Node $i: [dtn::tell_dtnd $i bundle stats]" |
|
140 } |
|
141 |
|
142 testlog " Waiting for senders / receivers to complete (up to 5 mins)" |
|
143 run::wait_for_pid_exit 0 $sndpid1 [expr 5 * 60] |
|
144 run::wait_for_pid_exit $last $sndpid2 [expr 5 * 60] |
|
145 run::wait_for_pid_exit 0 $rcvpid1 [expr 5 * 60] |
|
146 run::wait_for_pid_exit $last $rcvpid2 [expr 5 * 60] |
|
147 |
|
148 foreach node [list 0 $last] { |
|
149 testlog " Checking bundle stats on node $node" |
|
150 dtn::check_bundle_stats $node \ |
|
151 [expr $count * 2] "pending" \ |
|
152 $count "transmitted" \ |
|
153 $count "delivered" |
|
154 } |
|
155 |
|
156 for {set i 0} {$i < $N} {incr i} { |
|
157 testlog "Node $i: [dtn::tell_dtnd $i bundle stats]" |
|
158 } |
|
159 |
|
160 testlog " Stopping dtnds" |
|
161 dtn::stop_dtnd * |
|
162 |
|
163 # ---------------------------------------------------------------------- |
|
164 |
|
165 testlog " " |
|
166 testlog " Test phase 3: killing node" |
|
167 testlog " " |
|
168 |
|
169 testlog " Running dtnds" |
|
170 for {set i 0} {$i < [net::num_nodes]} {incr i} { |
|
171 set pids($i) [dtn::run_dtnd $i] |
|
172 } |
|
173 |
|
174 testlog " Waiting for dtnds to start up" |
|
175 dtn::wait_for_dtnd * |
|
176 |
|
177 testlog " Running senders / receivers for $count bundles, sleep $sleep" |
|
178 set rcvpid1 [dtn::run_app 0 dtnrecv "-q $eid1"] |
|
179 set rcvpid2 [dtn::run_app $last dtnrecv "-q $eid2"] |
|
180 set sndpid1 [dtn::run_app 0 dtnsend "-s $eid1 -d $eid2 -t d -z $sleep -n $count"] |
|
181 set sndpid2 [dtn::run_app $last dtnsend "-s $eid2 -d $eid1 -t d -z $sleep -n $count"] |
|
182 |
|
183 for {set i 0} {$i < 20} {incr i} { |
|
184 |
|
185 if {[dtn::test_bundle_stats 0 [list $count "delivered"]] && \ |
|
186 [dtn::test_bundle_stats 1 [list $count "delivered"]]} { |
|
187 break; # all done |
|
188 } |
|
189 |
|
190 set sleep [expr int(5000 * rand())] |
|
191 testlog " Sleeping for $sleep msecs" |
|
192 after $sleep |
|
193 |
|
194 testlog " Killing node 1" |
|
195 run::kill_pid 1 $pids(1) KILL |
|
196 tell::wait_for_close $net::host(1) [dtn::get_port console 1] |
|
197 |
|
198 set sleep [expr int(5000 * rand())] |
|
199 testlog " Sleeping for $sleep msecs" |
|
200 after $sleep |
|
201 |
|
202 testlog " Starting node 1" |
|
203 set pids(1) [dtn::run_dtnd 1 dtnd ""] |
|
204 dtn::wait_for_dtnd 1 |
|
205 } |
|
206 |
|
207 testlog " Done with killing loop.. stats:" |
|
208 for {set i 0} {$i < $N} {incr i} { |
|
209 testlog "Node $i: [tell_dtnd $i bundle stats]" |
|
210 } |
|
211 |
|
212 testlog " Waiting for senders to complete" |
|
213 run::wait_for_pid_exit 0 $sndpid1 |
|
214 run::wait_for_pid_exit $last $sndpid2 |
|
215 |
|
216 testlog " Killing receivers" |
|
217 run::kill_pid 0 $rcvpid1 TERM |
|
218 run::kill_pid $last $rcvpid2 TERM |
|
219 |
|
220 # all we can really check for is that they all got transmitted, |
|
221 # since some might end up getting lost when the node gets killed, |
|
222 # but after the ack was sent |
|
223 foreach node [list 0 $last] { |
|
224 testlog " Checking bundle stats on node $node" |
|
225 dtn::check_bundle_stats $node $count "transmitted" |
|
226 } |
|
227 |
|
228 testlog " Test success!" |
|
229 } |
|
230 |
|
231 test::exit_script { |
|
232 testlog " Stopping all dtnds" |
|
233 dtn::stop_dtnd * |
|
234 |
|
235 } |