test/reroute-from-down-link.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #
       
     2 #    Copyright 2007 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 reroute-from-down-link
       
    18 net::num_nodes 2
       
    19 
       
    20 set testopt(cl)       tcp
       
    21 set testopt(downtime) 2
       
    22 run::parse_test_opts
       
    23 
       
    24 set cl $testopt(cl)
       
    25 
       
    26 dtn::config
       
    27 dtn::config_interface $cl
       
    28 
       
    29 dtn::config_linear_topology ALWAYSON $cl false
       
    30 
       
    31 test::script {
       
    32     testlog "running dtnds"
       
    33     dtn::run_dtnd *
       
    34 
       
    35     testlog "waiting for dtnds to start up"
       
    36     dtn::wait_for_dtnd *
       
    37 
       
    38     set source    dtn://host-0/test
       
    39     set dest      dtn://host-1/test
       
    40 
       
    41     dtn::tell_dtnd 1 tcl_registration $dest
       
    42 
       
    43     testlog "waiting for links to establish"
       
    44     dtn::wait_for_link_state 0 null OPEN
       
    45     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    46 
       
    47     testlog "adding a higher priority route to the null link"
       
    48     dtn::tell_dtnd 0 route add $dest null route_priority=100
       
    49 
       
    50     testlog "reconfiguring null link to not send bundles"
       
    51     dtn::tell_dtnd 0 link reconfigure null \
       
    52             can_transmit=false potential_downtime=$testopt(downtime)
       
    53 
       
    54     testlog "sending a couple bundles"
       
    55     set timestamp1 [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    56     set timestamp2 [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    57     set timestamp3 [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    58 
       
    59     testlog "checking that bundles are queued on null link"
       
    60     dtn::wait_for_bundle_stats 0 {3 pending 0 transmitted}
       
    61     dtn::wait_for_link_stats 0 null {3 bundles_queued 0 bundles_transmitted}
       
    62     dtn::check_link_stats 0 $cl-link:0-1 {0 bundles_queued 0 bundles_transmitted}
       
    63 
       
    64     testlog "removing the route from the null link, checking bundles are still queued"
       
    65     dtn::tell_dtnd 0 route del $dest
       
    66     dtn::tell_dtnd 0 route add $dest $cl-link:0-1
       
    67     dtn::check_bundle_stats 0 {3 pending 0 transmitted}
       
    68     dtn::check_link_stats 0 null {3 bundles_queued 0 bundles_transmitted}
       
    69     dtn::check_link_stats 0 $cl-link:0-1 {0 bundles_queued 0 bundles_transmitted}
       
    70 
       
    71     testlog "closing null link, checking that bundles are still queued"
       
    72     dtn::tell_dtnd 0 link close null
       
    73     dtn::wait_for_link_state 0 null UNAVAILABLE
       
    74     dtn::wait_for_bundle_stats 0 {3 pending 0 transmitted}
       
    75     dtn::check_link_stats 0 null {3 bundles_queued}
       
    76 
       
    77     testlog "waiting for reroute timer to expire"
       
    78     after [expr $testopt(downtime) * 1000]
       
    79 
       
    80     testlog "checking that bundles were rerouted and sent"
       
    81     dtn::wait_for_link_stats 0 null         {0 bundles_queued 3 bundles_cancelled}
       
    82     dtn::wait_for_link_stats 0 $cl-link:0-1 {3 bundles_transmitted}
       
    83 
       
    84     testlog "checking bundle stats"
       
    85     dtn::wait_for_bundle_stats 0 {0 pending 3 transmitted}
       
    86     dtn::wait_for_bundle_stats 1 {0 pending 3 received 3 delivered}
       
    87 
       
    88     # XXX/demmer add a test in which the null link comes back
       
    89 }
       
    90 
       
    91 test::exit_script {
       
    92     testlog "stopping all dtnds"
       
    93     dtn::stop_dtnd *
       
    94 }