---
# System prepended metadata

title: Auto test framework

---

# Auto test framework
## Install outline

```graphviz

digraph G {
    rankdir=LR;
    compound=true
    node [shape=record];
    label="Auto test framework"
      
    subgraph cluster_NN{
        label = "Name Node";
        subgraph cluster_NN_itf1 {
            label = "interface 1"
            NN_itf1_IP[label="192.168.142.1"]
        }
        subgraph cluster_NN_itf2 {
            label = "interface 2"
            NN_itf2_IP[label="192.168.42.1"]
        }
    }
    
    subgraph cluster_DNB{
        label = "Data Node balance"
        subgraph cluster_DNB_itf1 {
            label = "interface 1"
            DNB_itf1_IP[label="192.168.42.2"]
        }
        subgraph cluster_DNB_itf2 {
            label = "interface 2"
            DNB_itf2_IP[label="192.168.100.1"]
        }
    }
    subgraph cluster_DN{
        label = "Log Server";
        subgraph cluster_DN_itf1 {
            label = "interface 1"
            DN_itf1_IP[label="192.168.100.2"]
        }
    }
    
    vc58_1x10_net_ifc -> NN_itf1_IP
    NN_itf2_IP -> DNB_itf1_IP
    DNB_itf2_IP -> DN_itf1_IP
}

```
### Name Node:
* net environment setting
    * setting fix ip in interface (e.g.192.168.142.1 and 192.168.42.1)
    * Add following cmd
        clean routing in tables
        ```shell
        $ sudo ip -6 route del fe80::/64
        $ sudo ip -6 route del ff02::/16
        ```
        set multi cast routing table
        ```shell
        $ sudo ip -6 route add ff02::/16 dev <interface 1> table main
        $ sudo ip -6 route add ff02::/16 dev <interface 1> table local
        ```
        set unicat routing table
    
        ```shell
        $ sudo ip route add fe80::/64 dev <interface 1> table main
        $ sudo ip route add fe80::/64 dev <interface 1> table local
        ```
* start up:
```shell
auto_test_framework$ ./start_srv_vc58 nn_sv start 1
```

### Data Node Balance
* Insert kernel module
```shell
ktcpd$ make clean;make
ktcpd$ sudo insmod ktdb_vpoll.ko part=12345 backlog=40960
```

* start up:
```shell
auto_test_framework$ ./start_srv_vc58 baldb_sv start 1
```
### Log Server
* Insert kernel module
```shell
ktcpd$ make clean;make
ktcpd$ sudo insmod ktdb_vpoll.ko part=12345 backlog=40960
```

* start up registration: (in new shell)
```shell
auto_test_framework$ ./start_srv_vc58 log_sv_reg start 1
```
* start up disk management : (in new shell)
```shell
auto_test_framework$ ./start_srv_vc58 log_sv_dsmg start 1
```

* start up registration: (in new shell)
```shell
auto_test_framework$ ./start_srv_vc58 log_sv start 1
```

## How to add new control cmd
### Add select menu
``` auto_test_framework/auto_test/vc58/vc58_dev.py ```
Is ths section add new cmd index
```python
class vc58_tc(enum.Enum):
    BASIC_CMD = 0
    QUIT = 0
    SET_DBG_LV = enum.auto()
    LOAD_IMAGE = enum.auto()
    UPLOAD_IMAGE = enum.auto()
    # SET_IMAGE_TYPE = enum.auto()
    # net work setting
    SET_DEST_IP = enum.auto()
    SET_DEST_PORT = enum.auto()
    # program image to dest
    VC58_START_PROG = enum.auto()  # VC58_CMD = 0x0010
    MOD_START_PROG = enum.auto()  # MOD_CMD = 0x0020
    # send cmd
    VC58_SEND_CMD_TO_MOD = enum.auto()
    VC58_SEND_CMD_TO_58 = enum.auto()
    # system cmd
    VC58_CENT_NV_DATA = enum.auto()
    VC58_GET_IP_ADDR = enum.auto()
    VC58_GET_VER = enum.auto()
    VC58_GET_OTA_STA = enum.auto()
    VC58_SET_DBG_FG_STA = enum.auto()
    VC58_REBOOT = enum.auto()
    MOD_REBOOT = enum.auto()
    RELOAD_CONF = enum.auto()
```
conver to real index
```python

QUIT = vc58_tc.QUIT.value
SET_DBG_LV = vc58_tc.SET_DBG_LV.value
LOAD_IMAGE = vc58_tc.LOAD_IMAGE.value
UPLOAD_IMAGE = vc58_tc.UPLOAD_IMAGE.value
# SET_IMAGE_TYPE   = \
#     vc58_tc.SET_IMAGE_TYPE.value
# net work setting
SET_DEST_IP = vc58_tc.SET_DEST_IP.value
SET_DEST_PORT = vc58_tc.SET_DEST_PORT.value
# program image to dest
VC58_START_PROG = vc58_tc.VC58_START_PROG.value
MOD_START_PROG = vc58_tc.MOD_START_PROG.value
# send cmd
VC58_SEND_CMD_TO_MOD = vc58_tc.VC58_SEND_CMD_TO_MOD.value
VC58_SEND_CMD_TO_58 = vc58_tc.VC58_SEND_CMD_TO_58.value
# system cmd
VC58_CENT_NV_DATA = vc58_tc.VC58_CENT_NV_DATA.value
VC58_GET_IP_ADDR = vc58_tc.VC58_GET_IP_ADDR.value
VC58_GET_VER = vc58_tc.VC58_GET_VER.value
VC58_GET_OTA_STA = vc58_tc.VC58_GET_OTA_STA.value
VC58_REBOOT = vc58_tc.VC58_REBOOT.value
MOD_REBOOT = vc58_tc.MOD_REBOOT.value
RELOAD_CONF = vc58_tc.RELOAD_CONF.value
```

Add cmd label Tag
```python
class vc58_tc_str(enum.Enum):

    QUTI_STR = "EXIT"
    SET_DBG_LV_STR = "Setting server debug level"
    LOAD_IMAGE_STR = "Load Image"
    UPLOAD_IMAGE_STR = "Upload Image"

    # SET_IMAGE_TYPE_STR = "Set Image for ic type"
    # net work setting
    SET_DEST_IP_STR = "Set destination address"
    SET_DEST_PORT_STR = "Set destination Port"
    # program image to dest
    VC58_START_PROG_STR = "Program vc58"
    MOD_START_PROG_STR = "Program module"
    # send cmd
    VC58_SEND_CMD_TO_MOD_STR = "Send cmd to dut"
    VC58_SEND_CMD_TO_58_STR = "Send cmd to vc58"
    # system cmd
    VC58_CENT_NV_DATA_STR = "Set init vc58 chip and board id"
    VC58_GET_IP_ADDR_STR = "Get vc58 ip address"
    VC58_GET_VER_STR = "Get vc58 image version"
    VC58_GET_OTA_STA_STR = "Get Ota image status"
    VC58_SET_DBG_FG_STR = "Setting 58 debug flag"
    VC58_REBOOT_STR = "Reboot vc58"
    MOD_REBOOT_STR = "Reboot dut"
    RELOAD_CONF_STR = "reload config file"
```

Add to cmd table for program auto loading
```python
cmd_table_str = {
        QUIT: vc58_tc_str.QUTI_STR.value,
        SET_DBG_LV: vc58_tc_str.SET_DBG_LV_STR.value,
        LOAD_IMAGE: vc58_tc_str.LOAD_IMAGE_STR.value,
        UPLOAD_IMAGE: vc58_tc_str.UPLOAD_IMAGE_STR.value,
        # SET_IMAGE_TYPE:     vc58_tc_str.SET_IMAGE_TYPE_STR.value,
        # net work setting
        SET_DEST_IP: vc58_tc_str.SET_DEST_IP_STR.value,
        SET_DEST_PORT: vc58_tc_str.SET_DEST_PORT_STR.value,
        # program image to dest
        VC58_START_PROG: vc58_tc_str.VC58_START_PROG_STR.value,
        MOD_START_PROG: vc58_tc_str.MOD_START_PROG_STR.value,
        # send cmd
        VC58_SEND_CMD_TO_MOD: vc58_tc_str.VC58_SEND_CMD_TO_MOD_STR.value,
        VC58_SEND_CMD_TO_58: vc58_tc_str.VC58_SEND_CMD_TO_58_STR.value,
        # system cmd
        VC58_CENT_NV_DATA: vc58_tc_str.VC58_CENT_NV_DATA_STR.value,
        VC58_GET_IP_ADDR: vc58_tc_str.VC58_GET_IP_ADDR_STR.value,
        VC58_GET_VER: vc58_tc_str.VC58_GET_VER_STR.value,
        VC58_GET_OTA_STA: vc58_tc_str.VC58_GET_OTA_STA_STR.value,
        VC58_REBOOT: vc58_tc_str.VC58_REBOOT_STR.value,
        MOD_REBOOT: vc58_tc_str.MOD_REBOOT_STR.value,
        RELOAD_CONF: vc58_tc_str.RELOAD_CONF_STR.value,
    }
```
### Add callback
Add callback in this table, and the callback shuold define in other module
```python
def init_cli_table():
        vc58_dev.cmd_table_list = [
            vc58_dev.basic_cmd.quit_func,
            vc58_dev.basic_cmd.cli_set_dbg_level,
            vc58_dev.fwupg.cli_load_image,
            vc58_dev.fwupg.upload_image_to58,
            # vc58_dev.fwupg.cli_set_ota_ic_type,
            # net work setting
            vc58_dev.udp_client.cli_set_dst_ip,
            vc58_dev.udp_client.cli_set_dst_port,
            # program image to dest
            vc58_dev.basic_cmd.start_program_vc58,
            vc58_dev.basic_cmd.cli_start_program_dut,
            # send cmd
            vc58_dev.basic_cmd.cli_send_cmd_to_dut,
            vc58_dev.basic_cmd.cli_send_cli_cmd_to_58,
# system cmd
            vc58_dev.basic_cmd.set_cent_nv_data,
            vc58_dev.basic_cmd.set_58_ip_addr,
            vc58_dev.basic_cmd.get_58_ver,
            vc58_dev.basic_cmd.get_58_ota_img_sta,
            vc58_dev.basic_cmd.set_58_dbg_fg,
            vc58_dev.basic_cmd.cli_reboot_vc58,
            vc58_dev.basic_cmd.cli_reboot_dut,
            vc58_dev.basic_cmd.reload_config_file,
        ]
```