|
1 # |
|
2 # Copyright 2008 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 sequence-id |
|
18 net::num_nodes 3 |
|
19 |
|
20 manifest::file apps/dtntest/dtntest dtntest |
|
21 |
|
22 set testopt(cl) tcp |
|
23 run::parse_test_opts |
|
24 |
|
25 set cl $testopt(cl) |
|
26 |
|
27 dtn::config -storage_type filesysdb |
|
28 dtn::config_interface $cl |
|
29 |
|
30 dtn::config_linear_topology ALWAYSON $cl true |
|
31 |
|
32 test::script { |
|
33 testlog "running dtnd and dtntest" |
|
34 dtn::run_dtnd * |
|
35 dtn::run_dtntest * |
|
36 |
|
37 testlog "waiting for dtnds and dtntest to start up" |
|
38 dtn::wait_for_dtnd * |
|
39 dtn::wait_for_dtntest * |
|
40 |
|
41 set h0 [tell_dtntest 0 dtn_open] |
|
42 set h1 [tell_dtntest 1 dtn_open] |
|
43 set h2 [tell_dtntest 2 dtn_open] |
|
44 |
|
45 set eid0 dtn://host-0/test |
|
46 set eid1 dtn://host-1/test |
|
47 set eid2 dtn://host-2/test |
|
48 |
|
49 set seqid00 <($eid0\ 0)> |
|
50 set seqid01 <($eid0\ 1)> |
|
51 set seqid02 <($eid0\ 2)> |
|
52 set seqid03 <($eid0\ 3)> |
|
53 |
|
54 set seqid10 <($eid1\ 0)> |
|
55 set seqid11 <($eid1\ 1)> |
|
56 set seqid12 <($eid1\ 2)> |
|
57 |
|
58 testlog "creating registrations" |
|
59 tell_dtntest 0 dtn_register $h0 endpoint=$eid0 expiration=0 |
|
60 tell_dtntest 1 dtn_register $h1 endpoint=$eid1 expiration=0 |
|
61 tell_dtntest 2 dtn_register $h2 endpoint=$eid2 expiration=0 |
|
62 |
|
63 testlog "waiting for links to establish" |
|
64 dtn::wait_for_link_state 0 $cl-link:0-1 OPEN |
|
65 dtn::wait_for_link_state 1 $cl-link:1-0 OPEN |
|
66 dtn::wait_for_link_state 1 $cl-link:1-2 OPEN |
|
67 dtn::wait_for_link_state 2 $cl-link:2-1 OPEN |
|
68 |
|
69 testlog "sending a bundle with sequence id and no session group" |
|
70 set id [dtn::tell_dtntest 0 dtn_send $h0 source=$eid0 dest=$eid2 \ |
|
71 payload_data=this_is_a_test \ |
|
72 sequence_id=$seqid00] |
|
73 |
|
74 testlog "waiting for arrival" |
|
75 dtn::wait_for_bundle_stats 0 {0 pending 1 deleted} |
|
76 dtn::wait_for_bundle_stats 1 {0 pending 1 deleted} |
|
77 dtn::wait_for_bundle_stats 2 {1 pending 0 deleted} |
|
78 array set bundle_data [dtn::tell_dtntest 2 dtn_recv $h2 payload_mem=true timeout=0] |
|
79 dtn::wait_for_bundle_stats 2 {0 pending 1 delivered 1 deleted} |
|
80 |
|
81 testlog "checking that sequence id was conveyed properly" |
|
82 dtn::check string equal $bundle_data(sequence_id) $seqid00 |
|
83 dtn::check string equal $bundle_data(obsoletes_id) {} |
|
84 |
|
85 testlog "closing link from 1-2" |
|
86 dtn::tell_dtnd 1 link close $cl-link:1-2 |
|
87 dtn::wait_for_link_state 1 $cl-link:1-2 UNAVAILABLE |
|
88 dtn::wait_for_link_state 2 $cl-link:2-1 UNAVAILABLE |
|
89 |
|
90 testlog "sending another bundle, waiting for it to be queued at node 1" |
|
91 set id [dtn::tell_dtntest 0 dtn_send $h0 source=$eid0 dest=$eid2 \ |
|
92 payload_data=this_is_another_test \ |
|
93 sequence_id=$seqid01] |
|
94 |
|
95 dtn::wait_for_bundle_stats 0 {0 pending 2 deleted} |
|
96 dtn::wait_for_bundle_stats 1 {1 pending 1 deleted} |
|
97 dtn::wait_for_bundle_stats 2 {0 pending 1 deleted} |
|
98 |
|
99 testlog "sending a third bundle, checking that it obsoletes the other one" |
|
100 set id [dtn::tell_dtntest 0 dtn_send $h0 source=$eid0 dest=$eid2 \ |
|
101 payload_data=this_is_the_third_test \ |
|
102 sequence_id=$seqid02 \ |
|
103 obsoletes_id=$seqid01] |
|
104 |
|
105 dtn::wait_for_bundle_stats 0 {0 pending 3 deleted} |
|
106 dtn::wait_for_bundle_stats 1 {1 pending 2 deleted} |
|
107 dtn::wait_for_bundle_stats 2 {0 pending 1 deleted} |
|
108 |
|
109 testlog "sending a bundle that doesn't obsolete the other" |
|
110 set id [dtn::tell_dtntest 0 dtn_send $h0 source=$eid0 dest=$eid2 \ |
|
111 payload_data=this_is_the_fourth_test \ |
|
112 sequence_id=$seqid11 \ |
|
113 obsoletes_id=$seqid10] |
|
114 |
|
115 dtn::wait_for_bundle_stats 0 {0 pending 4 deleted} |
|
116 dtn::wait_for_bundle_stats 1 {2 pending 2 deleted} |
|
117 dtn::wait_for_bundle_stats 2 {0 pending 1 deleted} |
|
118 |
|
119 testlog "sending a bundle that's obsolete when it arrives" |
|
120 set id [dtn::tell_dtntest 0 dtn_send $h0 source=$eid0 dest=$eid2 \ |
|
121 payload_data=this_is_the_fifth_test \ |
|
122 sequence_id=$seqid10] |
|
123 |
|
124 dtn::wait_for_bundle_stats 0 {0 pending 5 deleted} |
|
125 dtn::wait_for_bundle_stats 1 {2 pending 3 deleted} |
|
126 dtn::wait_for_bundle_stats 2 {0 pending 1 deleted} |
|
127 |
|
128 testlog "opening the link again, waiting for both bundles to be delivered" |
|
129 dtn::tell_dtnd 1 link open $cl-link:1-2 |
|
130 |
|
131 array set bundle_data [dtn::tell_dtntest 2 dtn_recv $h2 payload_mem=true timeout=10000] |
|
132 dtn::check string equal $bundle_data(sequence_id) $seqid02 |
|
133 dtn::check string equal $bundle_data(obsoletes_id) $seqid01 |
|
134 |
|
135 array set bundle_data [dtn::tell_dtntest 2 dtn_recv $h2 payload_mem=true timeout=10000] |
|
136 dtn::check string equal $bundle_data(sequence_id) $seqid11 |
|
137 dtn::check string equal $bundle_data(obsoletes_id) $seqid10 |
|
138 |
|
139 dtn::wait_for_bundle_stats 0 {0 pending 5 deleted} |
|
140 dtn::wait_for_bundle_stats 1 {0 pending 5 deleted} |
|
141 dtn::wait_for_bundle_stats 2 {0 pending 3 delivered 3 deleted} |
|
142 } |
|
143 |
|
144 test::exit_script { |
|
145 testlog "stopping all dtnds and dtntest" |
|
146 dtn::stop_dtnd * |
|
147 dtn::stop_dtntest * |
|
148 } |