|
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 multiple-registrations |
|
18 net::num_nodes 2 |
|
19 |
|
20 manifest::file apps/dtntest/dtntest dtntest |
|
21 manifest::file Rules.make test-payload.dat |
|
22 |
|
23 dtn::config |
|
24 dtn::config_interface tcp |
|
25 dtn::config_linear_topology ALWAYSON tcp true |
|
26 |
|
27 test::script { |
|
28 testlog "Running dtnd and dtntest" |
|
29 dtn::run_dtnd * |
|
30 dtn::run_dtntest * |
|
31 |
|
32 testlog "Waiting for dtnd and dtntest to start up" |
|
33 dtn::wait_for_dtnd * |
|
34 dtn::wait_for_dtntest * |
|
35 |
|
36 testlog "Creating a handle on each node" |
|
37 set h0 [dtn::tell_dtntest 0 dtn_open] |
|
38 set h1 [dtn::tell_dtntest 1 dtn_open] |
|
39 |
|
40 testlog "Creating two passive registrations on node 0" |
|
41 set reg1 [dtn::tell_dtntest 0 dtn_register $h0 \ |
|
42 endpoint=dtn://host-0/test1 expiration=3600 init_passive=true \ |
|
43 failure_action=defer] |
|
44 set reg2 [dtn::tell_dtntest 0 dtn_register $h0 \ |
|
45 endpoint=dtn://host-0/test2 expiration=3600 init_passive=true \ |
|
46 failure_action=defer] |
|
47 |
|
48 testlog "Binding to the two registrations" |
|
49 dtn::tell_dtntest 0 dtn_bind $h0 $reg1 |
|
50 dtn::tell_dtntest 0 dtn_bind $h0 $reg2 |
|
51 |
|
52 testlog "Sending a bundle to each registration" |
|
53 dtn::tell_dtntest 1 dtn_send $h1 \ |
|
54 source=dtn://host-1/test \ |
|
55 dest=dtn://host-0/test1 \ |
|
56 payload_data="test" |
|
57 |
|
58 dtn::tell_dtntest 1 dtn_send $h1 \ |
|
59 source=dtn://host-1/test \ |
|
60 dest=dtn://host-0/test2 \ |
|
61 payload_data="test" |
|
62 |
|
63 testlog "Waiting for the bundles to arrive" |
|
64 dtn::wait_for_bundle_stats 0 "2 received" |
|
65 |
|
66 testlog "Receiving both bundles" |
|
67 set b1_spec [dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=5000] |
|
68 set b2_spec [dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=5000] |
|
69 |
|
70 testlog "Trying to receive something else, checking that it times out" |
|
71 catch "dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=2000" recv_err |
|
72 dtn::check_equal $recv_err "error: error in dtn_recv: operation timed out" |
|
73 |
|
74 testlog "Unbinding from one of the registrations" |
|
75 dtn::tell_dtntest 0 dtn_unbind $h0 $reg1 |
|
76 |
|
77 testlog "Sending another bundle to both registrations" |
|
78 dtn::tell_dtntest 1 dtn_send $h1 \ |
|
79 source=dtn://host-1/test \ |
|
80 dest=dtn://host-0/test1 \ |
|
81 payload_data="test" |
|
82 |
|
83 dtn::tell_dtntest 1 dtn_send $h1 \ |
|
84 source=dtn://host-1/test \ |
|
85 dest=dtn://host-0/test2 \ |
|
86 payload_data="test" |
|
87 |
|
88 testlog "Waiting for the bundles to arrive" |
|
89 dtn::wait_for_bundle_stats 0 "4 received" |
|
90 |
|
91 testlog "Receiving a bundle" |
|
92 set spec [dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=5000] |
|
93 |
|
94 testlog "Checking that the right one was delivered" |
|
95 foreach {var val} $spec {set bundle_data($var) $val} |
|
96 dtn::check_equal $bundle_data(dest) dtn://host-0/test2 |
|
97 |
|
98 testlog "Checking that dtn_recv correctly times out" |
|
99 catch "dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=2000" recv_err |
|
100 |
|
101 testlog "Re-binding to the right registration" |
|
102 dtn::tell_dtntest 0 dtn_bind $h0 $reg1 |
|
103 |
|
104 testlog "Checking that the bundle is now received properly" |
|
105 set spec [dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=5000] |
|
106 foreach {var val} $spec {set bundle_data($var) $val} |
|
107 dtn::check_equal $bundle_data(dest) dtn://host-0/test1 |
|
108 |
|
109 testlog "Checking that many registrations works too" |
|
110 for {set i 2} {$i < 100} {incr i} { |
|
111 dtn::tell_dtntest 0 \ |
|
112 dtn_register $h0 endpoint=dtn://host-0/test$i expiration=3600 |
|
113 } |
|
114 |
|
115 for {set i 0} {$i < 100} {incr i} { |
|
116 dtn::tell_dtntest 1 dtn_send $h1 \ |
|
117 source=dtn://host-1/test \ |
|
118 dest=dtn://host-0/test$i \ |
|
119 payload_data="test" |
|
120 } |
|
121 |
|
122 for {set i 0} {$i < 100} {incr i} { |
|
123 dtn::tell_dtntest 0 dtn_recv $h0 payload_mem=true timeout=30000 |
|
124 } |
|
125 |
|
126 testlog "Checking final bundle stats" |
|
127 dtn::wait_for_bundle_stats 0 "104 delivered" |
|
128 } |
|
129 |
|
130 test::exit_script { |
|
131 testlog "Stopping dtnd and dtntest" |
|
132 dtn::tell_dtntest 0 dtn_close $h0 |
|
133 dtn::tell_dtntest 1 dtn_close $h1 |
|
134 dtn::stop_dtntest * |
|
135 dtn::stop_dtnd * |
|
136 } |