|
1 # |
|
2 # Copyright 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 many-bundles |
|
18 net::num_nodes 4 |
|
19 manifest::file apps/dtnrecv/dtnrecv dtnrecv |
|
20 |
|
21 set clayer tcp |
|
22 set count 5000 |
|
23 set length 10 |
|
24 set wait_time 15 |
|
25 set storage_type berkeleydb |
|
26 |
|
27 foreach {var val} $opt(opts) { |
|
28 if {$var == "-cl" || $var == "cl"} { |
|
29 set clayer $val |
|
30 } elseif {$var == "-count" || $var == "count"} { |
|
31 set count $val |
|
32 } elseif {$var == "-length" || $var == "length"} { |
|
33 set length $val |
|
34 } elseif {$var == "-wait_time" || $var == "wait_time"} { |
|
35 set wait_time $val |
|
36 } elseif {$var == "-storage_type" } { |
|
37 set storage_type $val |
|
38 } else { |
|
39 testlog error "ERROR: unrecognized test option '$var'" |
|
40 exit 1 |
|
41 } |
|
42 } |
|
43 |
|
44 testlog "Configuring $clayer interfaces / links" |
|
45 dtn::config -storage_type $storage_type |
|
46 dtn::config_interface $clayer |
|
47 #dtn::config_linear_topology OPPORTUNISTIC $clayer true |
|
48 dtn::config_linear_topology AlWAYSON $clayer true |
|
49 test::script { |
|
50 set starttime [clock seconds] |
|
51 |
|
52 testlog "Running dtnd 0" |
|
53 dtn::run_dtnd 0 |
|
54 dtn::wait_for_dtnd 0 |
|
55 |
|
56 set source dtn://host-0/test |
|
57 set dest dtn://host-3/test |
|
58 |
|
59 testlog "Sending $count bundles of length $length" |
|
60 for {set i 0} {$i < $count} {incr i} { |
|
61 set timestamp($i) [dtn::tell_dtnd 0 sendbundle $source $dest\ |
|
62 length=$length expiration=3600] |
|
63 } |
|
64 |
|
65 testlog "Checking that all the bundles are queued" |
|
66 dtn::wait_for_bundle_stats 0 "$count pending" |
|
67 |
|
68 testlog "Restarting dtnd 0" |
|
69 dtn::stop_dtnd 0 |
|
70 after 5000 |
|
71 dtn::run_dtnd 0 dtnd "" |
|
72 |
|
73 testlog "Checking that all bundles were re-read from the database" |
|
74 dtn::wait_for_dtnd 0 |
|
75 dtn::wait_for_bundle_stats 0 "$count pending" |
|
76 |
|
77 testlog "Starting dtnd 1" |
|
78 dtn::run_dtnd 1 |
|
79 dtn::wait_for_dtnd 1 |
|
80 |
|
81 testlog "Opening link to dtnd 1" |
|
82 dtn::tell_dtnd 0 link open $clayer-link:0-1 |
|
83 |
|
84 testlog "Waiting for all bundles to flow (up to $wait_time minutes)" |
|
85 set timeout [expr $wait_time * 60 * 1000] |
|
86 |
|
87 dtn::wait_for_bundle_stats 0 "0 pending" $timeout |
|
88 dtn::wait_for_bundle_stats 1 "$count pending" $timeout |
|
89 |
|
90 testlog "Checking that the link stayed open" |
|
91 dtn::check_link_stats 0 $clayer-link:0-1 "1 contacts" |
|
92 dtn::check_link_stats 1 $clayer-link:1-0 "1 contacts" |
|
93 |
|
94 testlog "Starting dtnd 2 and 3" |
|
95 dtn::run_dtnd 2 |
|
96 dtn::run_dtnd 3 |
|
97 dtn::wait_for_dtnd 2 |
|
98 dtn::wait_for_dtnd 3 |
|
99 |
|
100 testlog "Starting dtnrecv on node 3" |
|
101 set rcvpid [dtn::run_app 3 dtnrecv "-q -n $count $dest"] |
|
102 |
|
103 testlog "Opening links" |
|
104 dtn::tell_dtnd 2 link open $clayer-link:2-3 |
|
105 dtn::tell_dtnd 1 link open $clayer-link:1-2 |
|
106 |
|
107 testlog "Waiting for all bundles to be delivered" |
|
108 dtn::wait_for_bundle_stats 1 "0 pending" $timeout |
|
109 dtn::wait_for_bundle_stats 2 "0 pending" $timeout |
|
110 dtn::wait_for_bundle_stats 3 "$count delivered" $timeout |
|
111 |
|
112 testlog "Checking that all links stayed open" |
|
113 dtn::check_link_stats 0 $clayer-link:0-1 "1 contacts" |
|
114 dtn::check_link_stats 1 $clayer-link:1-0 "1 contacts" |
|
115 dtn::check_link_stats 1 $clayer-link:1-2 "1 contacts" |
|
116 dtn::check_link_stats 2 $clayer-link:2-1 "1 contacts" |
|
117 dtn::check_link_stats 2 $clayer-link:2-3 "1 contacts" |
|
118 dtn::check_link_stats 3 $clayer-link:3-2 "1 contacts" |
|
119 |
|
120 testlog "Waiting for receiver to complete" |
|
121 run::wait_for_pid_exit 3 $rcvpid |
|
122 |
|
123 testlog "Waiting for all daemon event queues to flush" |
|
124 dtn::wait_for_daemon_stat 0 0 pending_events |
|
125 dtn::wait_for_daemon_stat 1 0 pending_events |
|
126 dtn::wait_for_daemon_stat 2 0 pending_events |
|
127 dtn::wait_for_daemon_stat 3 0 pending_events |
|
128 |
|
129 testlog "Test success!" |
|
130 |
|
131 set elapsed [expr [clock seconds] - $starttime] |
|
132 testlog "TEST TIME: $elapsed seconds" |
|
133 |
|
134 } |
|
135 |
|
136 test::exit_script { |
|
137 testlog "Stopping all dtnds" |
|
138 dtn::stop_dtnd * |
|
139 } |