test/alwayson-links.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     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 tcp-alwayson-links
       
    18 net::num_nodes 3
       
    19 
       
    20 set cl tcp
       
    21 set link_opts ""
       
    22 
       
    23 for {set i 0} {$i < [llength $opt(opts)]} {incr i} {
       
    24     set var [lindex $opt(opts) $i]
       
    25     if {$var == "-cl" || $var == "cl"} {
       
    26 	set val [lindex $opt(opts) [incr i]]
       
    27 	set cl $val
       
    28     } elseif {$var == "fast" || $var == "-fast_retries"} {
       
    29 	append link_opts " min_retry_interval=1 max_retry_interval=10 data_timeout=1000"
       
    30     } else {
       
    31 	testlog error "ERROR: unrecognized test option '$var'"
       
    32 	exit 1
       
    33     }
       
    34 }
       
    35 
       
    36 dtn::config
       
    37 dtn::config_interface $cl
       
    38 
       
    39 dtn::config_linear_topology ALWAYSON $cl true $link_opts
       
    40 
       
    41 test::script {
       
    42     testlog "running dtnds"
       
    43     dtn::run_dtnd *
       
    44 
       
    45     testlog "waiting for dtnds to start up"
       
    46     dtn::wait_for_dtnd *
       
    47 
       
    48     set source    dtn://host-0/test
       
    49     set dest      dtn://host-2/test
       
    50 
       
    51     dtn::tell_dtnd 2 tcl_registration $dest
       
    52 
       
    53     testlog "checking that link is open"
       
    54     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    55 
       
    56     testlog "sending bundle"
       
    57     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    58 
       
    59     testlog "waiting for bundle arrival"
       
    60     dtn::wait_for_bundle 2 "$source,$timestamp" 5
       
    61     
       
    62     testlog "killing daemon 1"
       
    63     dtn::stop_dtnd 1
       
    64     
       
    65     testlog "checking that link is unavailable"
       
    66     dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE
       
    67 
       
    68     testlog "waiting for a few retry timers"
       
    69     after 10000
       
    70     
       
    71     testlog "checking that link is still UNAVAILABLE"
       
    72     dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE
       
    73     
       
    74     testlog "restarting daemon 1"
       
    75     dtn::run_dtnd 1
       
    76     dtn::wait_for_dtnd 1
       
    77     
       
    78     testlog "checking that link is OPEN"
       
    79     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    80 
       
    81     testlog "sending bundle"
       
    82     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    83 
       
    84     testlog "waiting for bundle arrival"
       
    85     dtn::wait_for_bundle 2 "$source,$timestamp" 5
       
    86     
       
    87     testlog "waiting for the idle timer, making sure the link is open"
       
    88     after 10000
       
    89     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
    90 
       
    91     testlog "forcibly closing the link"
       
    92     dtn::tell_dtnd 0 link close $cl-link:0-1
       
    93     dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE
       
    94 
       
    95     testlog "sending another bundle, checking that the link stays closed"
       
    96     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest]
       
    97     after 2000
       
    98     dtn::wait_for_link_state 0 $cl-link:0-1 UNAVAILABLE
       
    99 
       
   100     testlog "forcibly re-opening the link"
       
   101     dtn::tell_dtnd 0 link open $cl-link:0-1
       
   102     dtn::wait_for_link_state 0 $cl-link:0-1 OPEN
       
   103 
       
   104     testlog "waiting for bundle arrival"
       
   105     dtn::wait_for_bundle 2 "$source,$timestamp" 5
       
   106 
       
   107     testlog "test success!"
       
   108 }
       
   109 
       
   110 test::exit_script {
       
   111     testlog "stopping all dtnds"
       
   112     dtn::stop_dtnd *
       
   113 }