test/inflight-expiration.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 inflight-expiration
       
    18 net::num_nodes 2
       
    19 
       
    20 dtn::config
       
    21 
       
    22 testlog "Configuring tcp interfaces / links"
       
    23 dtn::config_interface tcp
       
    24 dtn::config_linear_topology ALWAYSON tcp true \
       
    25 	"test_write_delay=1000 sendbuf_len=1024"
       
    26 
       
    27 test::script {
       
    28     testlog "Running dtnds"
       
    29     dtn::run_dtnd *
       
    30 
       
    31     testlog "Waiting for dtnds to start up"
       
    32     dtn::wait_for_dtnd *
       
    33 
       
    34     testlog "Setting up flamebox-ignore"
       
    35     dtn::tell_dtnd 1 log /test always \
       
    36 	    "flamebox-ignore ign1 scheduling IMMEDIATE expiration"
       
    37 
       
    38     testlog "Waiting for link to open"
       
    39     dtn::wait_for_link_state 0 tcp-link:0-1 OPEN
       
    40 
       
    41     set source dtn://host-0/test
       
    42     set dest   dtn://host-1/test
       
    43     
       
    44     dtn::tell_dtnd 1 tcl_registration $dest
       
    45     
       
    46     testlog "Sending bundle"
       
    47     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest \
       
    48 	    length=5000 expiration=2]
       
    49     
       
    50     testlog "Waiting for bundle expiration at source"
       
    51     dtn::wait_for_bundle_stats 0 {1 expired}
       
    52     
       
    53     testlog "Checking that bundle is still in flight"
       
    54     dtn::check_link_stats 0 tcp-link:0-1 {0 bundles_queued 1 bundles_inflight}
       
    55     
       
    56     testlog "Checking that it was received but not delivered"
       
    57     dtn::wait_for_bundle_stats 1 {1 received 1 expired 0 delivered}
       
    58 
       
    59     testlog "Checking that it was really deleted"
       
    60     dtn::wait_for_bundle_stats 0 {0 pending}
       
    61     dtn::wait_for_bundle_stats 1 {0 pending}
       
    62 
       
    63     testlog "Verifying link stats"
       
    64     dtn::wait_for_link_stats 0 tcp-link:0-1 {0 bundles_queued 0 bytes_queued}
       
    65     dtn::wait_for_link_stats 0 tcp-link:0-1 {1 bundles_transmitted}
       
    66     dtn::wait_for_link_stats 0 tcp-link:0-1 {0 bundles_cancelled}
       
    67     
       
    68     testlog "Repeating the test, this time with two bundles in flight"
       
    69     tell_dtnd 0 bundle reset_stats
       
    70     tell_dtnd 1 bundle reset_stats
       
    71     
       
    72     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest \
       
    73 	    length=5000 expiration=2]
       
    74     set timestamp [dtn::tell_dtnd 0 sendbundle $source $dest \
       
    75 	    length=5000 expiration=2]
       
    76     
       
    77     testlog "Waiting for bundle expirations at source"
       
    78     dtn::wait_for_bundle_stats 0 {2 expired}
       
    79 
       
    80     testlog "Checking that only one bundle is still in flight"
       
    81     dtn::wait_for_link_stats 0 tcp-link:0-1 {0 bundles_queued 1 bundles_inflight}
       
    82     
       
    83     testlog "Checking that one was received but not delivered"
       
    84     dtn::wait_for_bundle_stats 1 {1 received 1 expired 0 delivered}
       
    85 
       
    86     testlog "Checking that they both were really deleted"
       
    87     dtn::wait_for_bundle_stats 0 {0 pending}
       
    88     dtn::wait_for_bundle_stats 1 {0 pending}
       
    89 
       
    90     testlog "Checking that only one was transmitted"
       
    91     dtn::wait_for_bundle_stats 0 {1 transmitted}
       
    92     
       
    93     testlog "Verifying link stats"
       
    94     dtn::wait_for_link_stats 0 tcp-link:0-1 {0 bundles_queued 0 bytes_queued}
       
    95     dtn::wait_for_link_stats 0 tcp-link:0-1 {1 bundles_transmitted}
       
    96     dtn::wait_for_link_stats 0 tcp-link:0-1 {1 bundles_cancelled}
       
    97     
       
    98     testlog "Test success!"
       
    99 }
       
   100 
       
   101 test::exit_script {
       
   102     testlog "clearing flamebox ignores"
       
   103     tell_dtnd 1 log /test always "flamebox-ignore-cancel ign1"
       
   104     
       
   105     testlog "Stopping all dtnds"
       
   106     dtn::stop_dtnd *
       
   107 }