---
# System prepended metadata

title: Route Local Testing Trace Example

---

# Route Local Testing Trace Example

## Test Suite

```gherkin
Feature: Local Routing

Topology:
 +-----------------------------------------+
 |  HOST_B------(LAN)DUT(WAN)------HOST_A  |
 +-----------------------------------------+
    @v2 @v3 @full @sanity @route @bvt
    Scenario:
        Given authorize CLI of "DUT"
        *     reload factory-default "DUT"
        *     prepare a "HOST_A" to connect to "DUT"
        *     prepare a "HOST_B" to connect to "DUT" 
        *     set WAN interface on "DUT"
        *     set LAN interface on "DUT"
        When  set "HOST_A" ip address within "DUT"s WAN subnet
        And   set "HOST_B" ip address within "DUT"s LAN subnet
        And   add static route for "HOST_A" routing to "HOST_B"
        And   add static route for "HOST_B" routing to "HOST_A"        
        Then  "HOST_A" will ping "HOST_B" successfully
        And   "HOST_B" will ping "HOST_A" successfully
```

## Trace
### Given authorize CLI of DUT

```mermaid
flowchart TD

    subgraph loginToDUT
        p1 --> make_cli_router
    end
    
    subgraph make_cli_router
        p2 --> p3
        p3 --> p4
    end
    
    p0 --> p-1 -- Load Json to Setup Behave Context Object --> f1
    f1 --> loginToDUT
    loginToDUT -- Create Debug File Handle, Login CLI Session and Return a Router Instance --> f2
    
    f1[Given authorize CLI of DUT]
    f2[reload factory-default DUT]
    p0[test_suite/environment.py:27 -> func:before_all -> func:prepare_json]:::code
    p-1[lib/topology/topology_info.py:8 -> func:prepare_json]:::code
    p1[lib/steps/login.py:9 -> func:loginToDUT]:::code
    p2[lib/mdc/router/cli/rp_api/rp_api.py:88 -> func:make_cli_router]:::code
    p3[lib/mdc/router/cli/utils.py:41 -> func:create_debug_output]:::code
    p4[lib/mdc/session.py:299 -> func:make_opened_session]:::code
    
    classDef code fill:#f96
```

### reload factory-default DUT

```mermaid
flowchart TD
    f2 --> p0
    p0 --> p1 --> p2
    p2 -- Return Config Instance --> p3
    p3 -- Set and Assert HostName to 'init_check' --> p4
    p4 --> p5 --> p6
    p6 -- Router Factory Reset and Close CLI session --> p7
    p7 -- Recreate Debug File Handle, Login CLI Session and Return a Router Instance --> f3
    
    f2[reload factory-default DUT]
    f3[prepare a HOST_A to connect to DUT]
    p0[lib/steps/common.py:88]:::code
    p1[lib/mdc/router/cli/rp_api/rp_api.py:37 -> func:go_config]:::code
    p2[lib/mdc/router/cli/rp_base/rp_base_v2.py:562 class:Config]:::code
    p3[lib/mdc/router/cli/rp_base/rp_base_v2.py:781 -> func:set_hostname]:::code
    p4[lib/mdc/router/cli/rp_api/rp_api.py:34 -> func:main]:::code
    p5[lib/steps/common.py:495 func:reload_factory_default]:::code
    p6[lib/mdc/router/cli/rp_api/rp_api.py:31 func:close]:::code
    p7[lib/steps/login.py:9 -> func:loginToDUT]:::code
    
    classDef code fill:#f96
```

### prepare a HOST_A to connect to DUT

```mermaid
flowchart TD

    
    f3 --> p0
    p0 -- Load HOST_A Information from Behave Context: info --> p1
    p1 --> p2 --> p3 --> p4 -- Return SSH Sessioin and Check  Control Service Enviroment --> f4
    
    
    f3[prepare a HOST_A to connect to DUT]
    p0[lib/steps/common.py:62]:::code
    p1[lib/atb/hosts.py:185 -> func:make_host, param:info]:::code
    p2[lib/atb/hosts.py:162 -> func:make_session, param:info]:::code
    p3[lib/atb/session.py:4 -> class SshSession]:::code
    p4[lib/atb/session.py:34 -> func:login]:::code
    f4[prepare a HOST_B to connect to DUT]

    classDef code fill:#f96
```

### prepare a HOST_B to connect to DUT

```mermaid
flowchart TD

    
    f4 --> p0
    p0 -- Load HOST_B Information from Behave Context: info --> p1
    p1 --> p2 --> p3 --> p4 -- Return SSH Sessioin and Check  Control Service Enviroment --> f5
    
    
    f4[prepare a HOST_A to connect to DUT]
    p0[lib/steps/common.py:62]:::code
    p1[lib/atb/hosts.py:185 -> func:make_host, param:info]:::code
    p2[lib/atb/hosts.py:162 -> func:make_session, param:info]:::code
    p3[lib/atb/session.py:4 -> class SshSession]:::code
    p4[lib/atb/session.py:34 -> func:login]:::code
    f5[set WAN interface on DUT]

    classDef code fill:#f96
```

### set WAN interface on DUT




```mermaid
flowchart TD
    f4 --> p0 -- Configuration for IP, Mask, VLAN, Port, Gateway --> p1
    p1 --> p2 --> p3 -- Set VLAN ID --> p4 --> p5
    
    p5 --  Set the Switch Port to a Specific VLAN ID and Mode --> p6
    p6 --> p7 --> p8 -- Set the WAN Interface with Given IP Address and Subnet Mask --> p9 --> p10 -- Show Router Information and Assert IP Address Exist --> f5
    
    
    f4[set WAN interface on DUT]
    p0[lib/steps/interface.py:28]:::code
    p1[lib/mdc/router/cli/rp_api/rp_api.py:37 -> func:go_config]:::code
    p2[lib/mdc/router/cli/rp_base/rp_base_v2.py:562 class:Config]:::code
    p3[lib/mdc/router/cli/rp_base/rp_base_v2.py:1050 -> func:set_vlan_id]:::code
    p4[lib/mdc/router/cli/rp_api/rp_api.py:49 -> func:go_config_if_ethernet]:::code
    p5[lib/mdc/router/cli/rp_base/rp_base_v2.py:1625 -> func:set_switchport]:::code
    p6[lib/mdc/router/cli/rp_api/rp_api.py:43 -> func:go_config_if_wan]:::code
    p7[lib/mdc/router/cli/rp_base/rp_base_v2.py:1384 -> class:ConfigIfWan]:::code
    p8[lib/mdc/router/cli/rp_base/rp_base_v2.py:1427 -> func:set_wan_interface]:::code
    p9[lib/mdc/router/cli/rp_api/rp_api.py:34 -> func:main]:::code
    p10[lib/mdc/router/cli/rp_base/rp_base_v2.py:187 -> func:show_interface]:::code
    f5[set LAN interface on DUT]
    
    classDef code fill:#f96
```

### set LAN interface on DUT




```mermaid
flowchart TD
    f5 --> p0 -- Configuration for IP, Mask, VLAN, Port, Gateway --> p4
    p4 --> p5
    
    p5 --  Set the Switch Port to a Specific VLAN ID and Mode --> p6
    p6 --> p7 --> p8 -- Set the LAN Interface --> p9 --> p10 -- Show Router Information and Assert IP Address Exist --> f6
    
    
    f5[set LAN interface on DUT]
    
    
    
    
    
    p0[lib/steps/interface.py:28]:::code
    p4[lib/mdc/router/cli/rp_api/rp_api.py:49 -> func:go_config_if_ethernet]:::code
    p5[lib/mdc/router/cli/rp_base/rp_base_v2.py:1625 -> func:set_switchport]:::code
    p6[lib/mdc/router/cli/rp_api/rp_api.py:40 -> func:go_config_if_lan]:::code
    p7[lib/mdc/router/cli/rp_base/rp_base_v2.py:1237 -> class:ConfigIfLan]:::code
    p8[lib/mdc/router/cli/rp_base/rp_base_v2.py:1329 -> func:set_lan_interface]:::code
    p9[lib/mdc/router/cli/rp_api/rp_api.py:34 -> func:main]:::code
    p10[lib/mdc/router/cli/rp_base/rp_base_v2.py:187 -> func:show_interface]:::code
    f6[set HOST_A ip address within DUT's WAN subnet]
    
    classDef code fill:#f96
```

### set HOST_A ip address within DUT's WAN subnet


```mermaid
flowchart TD

    f6 --> p0 --  Set the IP Address and Subnet Mask of a SSH Host --> f7
    
    f6[set HOST_A ip address within DUT's WAN subnet]
    f7[set HOST_B ip address within DUTs LAN subnet]
    p0[lib/steps/interface.py:132]:::code
    

    classDef code fill:#f96
```

### set HOST_B ip address within DUT's LAN subnet


```mermaid
flowchart TD

    f7 --> p0 --  Set the IP Address and Subnet Mask of a SSH Host --> f8
    
    f7[set HOST_B ip address within DUT's LAN subnet]
    f8[add static route for HOST_A routing to HOST_B]
    p0[lib/steps/interface.py:132]:::code
    

    classDef code fill:#f96
```

### add static route for HOST_A routing to HOST_B

```mermaid
flowchart TD

    f8 --> p0 --> p1 -- Add a Route to the Device --> p2 --> p3  --> f9
    
    f8[add static route for HOST_A routing to HOST_B]
    f9[add static route for HOST_B routing to HOST_A]
    p0[lib/steps/interface.py:206]:::code
    p1[lib/atb/control.py:254 -> func:add_route]:::code
    p2[lib/atb/control.py:10 -> func:login_as_root]:::code
    p3[lib/atb/control.py:23 -> func:logout_from_root]:::code

    classDef code fill:#f96
```

### add static route for HOST_B routing to HOST_A

```mermaid
flowchart TD

    f9 --> p0 --> p1 -- Add a Route to the Device --> p2 --> p3  --> f10
    
    f9[add static route for HOST_B routing to HOST_A]
    f10[HOST_A will ping HOST_B successfully]
    p0[lib/steps/interface.py:206]:::code
    p1[lib/atb/control.py:254 -> func:add_route]:::code
    p2[lib/atb/control.py:10 -> func:login_as_root]:::code
    p3[lib/atb/control.py:23 -> func:logout_from_root]:::code

    classDef code fill:#f96
```

### HOST_A will ping HOST_B successfully

```mermaid
flowchart TD

    f9 --> p0 -- Check Login or not --> p1 -- Ping for 4 times --> f10
    
    
    f9[HOST_A will ping HOST_B successfully]
    f10[HOST_B will ping HOST_A successfully]
    p0[lib/steps/common.py:293]:::code
    p1[lib/steps/common.py:107 -> func:do_ping]:::code
    
    
    classDef code fill:#f96
```

### HOST_B will ping HOST_A successfully

```mermaid
flowchart TD

    f9 --> p0 -- Check Login or not --> p1 -- Ping for 4 times --> f10
    
    
    f9[HOST_B will ping HOST_A successfully]
    f10[END]
    p0[lib/steps/common.py:293]:::code
    p1[lib/steps/common.py:107 -> func:do_ping]:::code
    
    
    classDef code fill:#f96
```

