test/session-membership.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     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 session-membership
       
    18 net::num_nodes 5
       
    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 --router_type dtlsr --no_null_link --storage_type filesysdb
       
    28 dtn::config_interface $cl
       
    29 
       
    30 dtn::config_topology_common false
       
    31 
       
    32 #
       
    33 # Set up initial topology:
       
    34 #
       
    35 #        0
       
    36 #        |
       
    37 #        1
       
    38 #       / \
       
    39 #      2   3
       
    40 #     /
       
    41 #    4
       
    42 
       
    43 dtn::config_link 0 1 ALWAYSON $cl ""
       
    44 dtn::config_link 1 0 ALWAYSON $cl ""
       
    45 dtn::config_link 1 2 ALWAYSON $cl ""
       
    46 dtn::config_link 2 1 ALWAYSON $cl ""
       
    47 dtn::config_link 1 3 ALWAYSON $cl ""
       
    48 dtn::config_link 3 1 ALWAYSON $cl ""
       
    49 dtn::config_link 2 4 ALWAYSON $cl ""
       
    50 dtn::config_link 4 2 ALWAYSON $cl ""
       
    51 dtn::config_link 3 4 OPPORTUNISTIC $cl ""
       
    52 dtn::config_link 4 3 OPPORTUNISTIC $cl ""
       
    53 
       
    54 conf::add dtnd * "route set subscription_timeout 30"
       
    55 
       
    56 test::script {
       
    57     testlog "running dtnd and dtntest"
       
    58     dtn::run_dtnd *
       
    59     dtn::run_dtntest *
       
    60 
       
    61     testlog "waiting for dtnds and dtntest to start up"
       
    62     dtn::wait_for_dtnd *
       
    63     dtn::wait_for_dtntest *
       
    64 
       
    65     set h0 [tell_dtntest 0 dtn_open]
       
    66     set h1 [tell_dtntest 1 dtn_open]
       
    67     set h2 [tell_dtntest 2 dtn_open]
       
    68     set h3 [tell_dtntest 3 dtn_open]
       
    69     set h4 [tell_dtntest 4 dtn_open]
       
    70 
       
    71     set eid0    dtn://host-0/test
       
    72     set eid1    dtn://host-1/test
       
    73     set eid2    dtn://host-2/test
       
    74     set eid3    dtn://host-3/test
       
    75     set eid4    dtn://host-4/test
       
    76 
       
    77     set seqid01 <($eid0\ 1)>
       
    78     set seqid02 <($eid0\ 2)>
       
    79     set seqid03 <($eid0\ 3)>
       
    80 
       
    81     set seqid11 <($eid1\ 1)>
       
    82     set seqid12 <($eid1\ 2)>
       
    83    
       
    84     set seqid21 <($eid2\ 1)>
       
    85     set seqid22 <($eid2\ 2)>
       
    86    
       
    87     set g0      dtn-group://group0
       
    88     set g1      dtn-group://group1
       
    89 
       
    90     testlog "waiting for links to establish"
       
    91     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    92     dtn::wait_for_link_state 1 $cl-link:1-0 OPEN
       
    93     dtn::wait_for_link_state 1 $cl-link:1-2 OPEN
       
    94     dtn::wait_for_link_state 2 $cl-link:2-1 OPEN
       
    95     dtn::wait_for_link_state 1 $cl-link:1-3 OPEN
       
    96     dtn::wait_for_link_state 3 $cl-link:3-1 OPEN
       
    97     dtn::wait_for_link_state 2 $cl-link:2-4 OPEN
       
    98     dtn::wait_for_link_state 4 $cl-link:4-2 OPEN
       
    99     
       
   100     testlog "waiting for routes to settle"
       
   101     dtn::wait_for_stats_on_all_links * {0 bundles_inflight 0 bundles_queued}
       
   102 
       
   103     dtn::wait_for_route 0 dtn://host-1/* $cl-link:0-1 {}
       
   104     dtn::wait_for_route 0 dtn://host-2/* $cl-link:0-1 {}
       
   105     dtn::wait_for_route 0 dtn://host-3/* $cl-link:0-1 {}
       
   106     dtn::wait_for_route 0 dtn://host-4/* $cl-link:0-1 {}
       
   107 
       
   108     dtn::wait_for_route 1 dtn://host-0/* $cl-link:1-0 {}
       
   109     dtn::wait_for_route 1 dtn://host-2/* $cl-link:1-2 {}
       
   110     dtn::wait_for_route 1 dtn://host-3/* $cl-link:1-3 {}
       
   111     dtn::wait_for_route 1 dtn://host-4/* $cl-link:1-2 {}
       
   112     
       
   113     dtn::wait_for_route 2 dtn://host-0/* $cl-link:2-1 {}
       
   114     dtn::wait_for_route 2 dtn://host-1/* $cl-link:2-1 {}
       
   115     dtn::wait_for_route 2 dtn://host-3/* $cl-link:2-1 {}
       
   116     dtn::wait_for_route 2 dtn://host-4/* $cl-link:2-4 {}
       
   117     
       
   118     dtn::wait_for_route 3 dtn://host-0/* $cl-link:3-1 {}
       
   119     dtn::wait_for_route 3 dtn://host-1/* $cl-link:3-1 {}
       
   120     dtn::wait_for_route 3 dtn://host-2/* $cl-link:3-1 {}
       
   121     dtn::wait_for_route 3 dtn://host-4/* $cl-link:3-1 {}
       
   122 
       
   123     dtn::wait_for_route 4 dtn://host-0/* $cl-link:4-2 {}
       
   124     dtn::wait_for_route 4 dtn://host-1/* $cl-link:4-2 {}
       
   125     dtn::wait_for_route 4 dtn://host-2/* $cl-link:4-2 {}
       
   126     dtn::wait_for_route 4 dtn://host-3/* $cl-link:4-2 {}
       
   127 
       
   128     testlog "sanity checking stats"
       
   129     dtn::check_bundle_stats 0 {5 pending 0 expired 0 duplicate}
       
   130     dtn::check_bundle_stats 1 {5 pending 0 expired 0 duplicate}
       
   131     dtn::check_bundle_stats 2 {5 pending 0 expired 0 duplicate}
       
   132     dtn::check_bundle_stats 3 {5 pending 0 expired 0 duplicate}
       
   133     dtn::check_bundle_stats 4 {5 pending 0 expired 0 duplicate}
       
   134 
       
   135     testlog "creating custodian registration on node 1"
       
   136     set custodian_regid [tell_dtntest 1 dtn_register $h1 \
       
   137             endpoint=$g0 expiration=0 session_flags=custody]
       
   138     
       
   139     testlog "creating a subscriber registration on node 3"
       
   140     set subscriber_3 [tell_dtntest 3 dtn_register $h3 \
       
   141             endpoint=$g0 expiration=0 session_flags=subscribe]
       
   142 
       
   143     testlog "checking that custodian is notified"
       
   144     set L [tell_dtntest 1 dtn_session_update $h0 10000]
       
   145     testlog "result $L"
       
   146 
       
   147     testlog "creating a publisher registration on node 0"
       
   148     set publisher_0 [tell_dtntest 0 dtn_register $h0 \
       
   149             endpoint=$g0 expiration=0 session_flags=publish]
       
   150 
       
   151     testlog "sending a bundle, checking that it is delivered"
       
   152     tell_dtntest 0 dtn_send $h0 regid=$publisher_0 \
       
   153             source=$g0 dest=$g0 expiration=3600 payload_data="bundle1" \
       
   154             sequence_id=$seqid01
       
   155 
       
   156     array set bundle_data [dtn::tell_dtntest 3 dtn_recv $h3 \
       
   157             payload_mem=true timeout=10000]
       
   158     dtn::check string equal $bundle_data(sequence_id) $seqid01
       
   159 
       
   160     testlog "checking that it is pending at subscribed nodes"
       
   161     dtn::wait_for_bundle_stats 0 {6 pending}
       
   162     dtn::wait_for_bundle_stats 1 {6 pending}
       
   163     dtn::wait_for_bundle_stats 3 {6 pending}
       
   164 
       
   165     testlog "sending an obsoleting bundle, checking that it is delivered"
       
   166     tell_dtntest 0 dtn_send $h0 regid=$publisher_0 \
       
   167             source=$g0 dest=$g0 expiration=3600 payload_data="bundle2" \
       
   168             sequence_id=$seqid02 obsoletes_id=$seqid01
       
   169 
       
   170     array set bundle_data [dtn::tell_dtntest 3 dtn_recv $h3 \
       
   171             payload_mem=true timeout=10000]
       
   172     dtn::check string equal $bundle_data(sequence_id) $seqid02
       
   173 
       
   174     testlog "testing that it obsoleted the old one"
       
   175     dtn::wait_for_bundle_stats 1 {6 pending}
       
   176     dtn::wait_for_bundle_stats 3 {6 pending}
       
   177 
       
   178     testlog "sanity checking stats"
       
   179     dtn::check_bundle_stats 0 {6 pending 0 expired 0 duplicate}
       
   180     dtn::check_bundle_stats 1 {6 pending 0 expired 0 duplicate}
       
   181     dtn::check_bundle_stats 2 {5 pending 0 expired 0 duplicate}
       
   182     dtn::check_bundle_stats 3 {6 pending 0 expired 0 duplicate}
       
   183     dtn::check_bundle_stats 4 {5 pending 0 expired 0 duplicate}
       
   184 
       
   185     testlog "subscribing at node 4"
       
   186     set subscriber_4 [tell_dtntest 4 dtn_register $h4 \
       
   187             endpoint=$g0 expiration=0 session_flags=subscribe]
       
   188 
       
   189     testlog "checking that only the second is delivered"
       
   190     array set bundle_data [dtn::tell_dtntest 4 dtn_recv $h4 \
       
   191             payload_mem=true timeout=10000]
       
   192     dtn::check string equal $bundle_data(sequence_id) $seqid02
       
   193     if {! [catch {
       
   194         dtn::tell_dtntest 4 dtn_recv $h4 payload_mem=true timeout=1000
       
   195     } err]} {
       
   196         error "dtn_recv should have timed out"
       
   197     }
       
   198 
       
   199     testlog "checking it is cached at the newly subscribed nodes"
       
   200     dtn::wait_for_bundle_stats 1 {6 pending}
       
   201     dtn::wait_for_bundle_stats 2 {6 pending}
       
   202     dtn::wait_for_bundle_stats 3 {6 pending}
       
   203     dtn::wait_for_bundle_stats 4 {6 pending}
       
   204     
       
   205     testlog "sanity checking stats"
       
   206     dtn::check_bundle_stats 0 {6 pending 0 expired 0 duplicate}
       
   207     dtn::check_bundle_stats 1 {6 pending 0 expired 0 duplicate}
       
   208     dtn::check_bundle_stats 2 {6 pending 0 expired 0 duplicate}
       
   209     dtn::check_bundle_stats 3 {6 pending 0 expired 0 duplicate}
       
   210     dtn::check_bundle_stats 4 {6 pending 0 expired 0 duplicate}
       
   211 
       
   212     testlog "sending a non-obsoleting bundle"
       
   213     tell_dtntest 0 dtn_send $h0 regid=$publisher_0 \
       
   214             source=$g0 dest=$g0 expiration=3600 payload_data="bundle2" \
       
   215             sequence_id=$seqid11
       
   216 
       
   217     testlog "waiting for it to be delivered"
       
   218     array set bundle_data [dtn::tell_dtntest 3 dtn_recv $h3 \
       
   219             payload_mem=true timeout=10000]
       
   220     dtn::check string equal $bundle_data(sequence_id) $seqid11
       
   221     array set bundle_data [dtn::tell_dtntest 4 dtn_recv $h4 \
       
   222             payload_mem=true timeout=10000]
       
   223     dtn::check string equal $bundle_data(sequence_id) $seqid11
       
   224 
       
   225     testlog "changing topology so that node 4 is now attached to node 3"
       
   226     tell_dtnd 2 link close $cl-link:2-4
       
   227     tell_dtnd 3 link open $cl-link:3-4
       
   228 
       
   229     testlog "waiting for routes to settle"
       
   230     dtn::wait_for_stats_on_all_links * {0 bundles_inflight 0 bundles_queued}
       
   231     
       
   232     dtn::wait_for_route 0 dtn://host-1/* $cl-link:0-1 {}
       
   233     dtn::wait_for_route 0 dtn://host-2/* $cl-link:0-1 {}
       
   234     dtn::wait_for_route 0 dtn://host-3/* $cl-link:0-1 {}
       
   235     dtn::wait_for_route 0 dtn://host-4/* $cl-link:0-1 {}
       
   236 
       
   237     dtn::wait_for_route 1 dtn://host-0/* $cl-link:1-0 {}
       
   238     dtn::wait_for_route 1 dtn://host-2/* $cl-link:1-2 {}
       
   239     dtn::wait_for_route 1 dtn://host-3/* $cl-link:1-3 {}
       
   240     dtn::wait_for_route 1 dtn://host-4/* $cl-link:1-3 {}
       
   241     
       
   242     dtn::wait_for_route 2 dtn://host-0/* $cl-link:2-1 {}
       
   243     dtn::wait_for_route 2 dtn://host-1/* $cl-link:2-1 {}
       
   244     dtn::wait_for_route 2 dtn://host-3/* $cl-link:2-1 {}
       
   245     dtn::wait_for_route 2 dtn://host-4/* $cl-link:2-1 {}
       
   246     
       
   247     dtn::wait_for_route 3 dtn://host-0/* $cl-link:3-1 {}
       
   248     dtn::wait_for_route 3 dtn://host-1/* $cl-link:3-1 {}
       
   249     dtn::wait_for_route 3 dtn://host-2/* $cl-link:3-1 {}
       
   250     dtn::wait_for_route 3 dtn://host-4/* $cl-link:3-4 {}
       
   251 
       
   252     dtn::wait_for_route 4 dtn://host-0/* $cl-link:4-3 {}
       
   253     dtn::wait_for_route 4 dtn://host-1/* $cl-link:4-3 {}
       
   254     dtn::wait_for_route 4 dtn://host-2/* $cl-link:4-3 {}
       
   255     dtn::wait_for_route 4 dtn://host-3/* $cl-link:4-3 {}
       
   256     
       
   257 }
       
   258 
       
   259 test::exit_script {
       
   260     testlog "stopping all dtnds and dtntest"
       
   261     dtn::stop_dtnd *
       
   262     dtn::stop_dtntest *
       
   263 }