示例#1
0
def sample_test() -> None:
    log.info("\n------------sample_test-------------")
    if check_if_test_setup_is_free(
            TEST_SETUP_ID) and set_test_setup_and_devices_busy(TEST_SETUP_ID):
        atexit.register(free_test_setup_clean_up)
        device_info = get_test_setup_devices_and_connections(TEST_SETUP_ID)
        if device_info:
            result = create_test_run_result(
                name="Sample Date Test",
                identifier=str(uuid.uuid4),
                description="Get date",
                team_id=TEAM_ID,
                test_setup=TEST_SETUP_ID,
            )
            if result["data"]:
                test_exe_details = result["data"]
                test_exe_id = test_exe_details["id"]

                date_action_outcome = 1
                start = datetime.datetime.now()
                output = device_info[DEV_ID].connection.send_command(
                    cmd="date +%F", timeout=60)

                if str(datetime.date.today()) in output["message"]:
                    date_action_outcome = 0
                else:
                    log.error(
                        f"date action failed, date on device: {output['message']} date on system: {str(datetime.date.today())}"
                    )

                date_test_action_result = save_test_action_result(
                    test_run_id=test_exe_id,
                    description="Date",
                    outcome=date_action_outcome,
                    logs=" ".join(map(str, output["message"])),
                    start_time=start,
                    end_time=datetime.datetime.now(),
                )

                log.info(date_test_action_result["message"])

                data_list1 = [
                    {
                        "Interval": 0,
                        "Transfer Mbytes": 121,
                        "Bandwidth Mbits/sec": 1014,
                        "Jitter ms": 0.059,
                    },
                    {
                        "Interval": 1,
                        "Transfer Mbytes": 121,
                        "Bandwidth Mbits/sec": 1013,
                        "Jitter ms": 0.058,
                    },
                ]
                data_source1_name = "iperf data 1"

                data_list2 = [
                    {
                        "Interval": 0,
                        "Transfer Mbytes": 108,
                        "Bandwidth Mbits/sec": 909,
                        "Jitter ms": 0.061,
                    },
                    {
                        "Interval": 1,
                        "Transfer Mbytes": 103,
                        "Bandwidth Mbits/sec": 861,
                        "Jitter ms": 0.070,
                    },
                ]
                data_source2_name = "iperf data 2"

                json_data1 = {
                    "data_source": data_source1_name,
                    "data_list": data_list1,
                }
                json_data2 = {
                    "data_source": data_source2_name,
                    "data_list": data_list2,
                }

                json_table1 = {
                    "title":
                    "Demo Iperf Table Small",
                    "table_type":
                    "static",
                    "columns":
                    "Interval,Bandwidth Mbits/sec",
                    "data_source_list":
                    data_source1_name + "," + data_source2_name,
                }

                json_table2 = {
                    "title":
                    "Demo Iperf Table Full",
                    "data_source_list":
                    data_source1_name + "," + data_source2_name,
                }

                x_axis1 = {
                    "key": "Interval",
                    "options": {
                        "label": "Interval ms",
                        "type": "linear",
                        "position": "bottom",
                    },
                }
                y_axis1 = {
                    "series_list": [
                        {
                            "data_source": data_source1_name,
                            "key": "Bandwidth Mbits/sec",
                            "label": "TestData_iperflink1",
                        },
                        {
                            "data_source": data_source2_name,
                            "key": "Bandwidth Mbits/sec",
                            "label": "TestData_iperflink2",
                        },
                    ],
                    "options": {
                        "label": "Bandwidth Mbits/sec",
                        "fill": "false"
                    },
                }
                chart_options = {"display_type": "line", "tension": "true"}
                json_chart = {
                    "title": "Iperf Chart",
                    "axes": {
                        "x_axis1": x_axis1,
                        "y_axis1": y_axis1,
                    },
                    "chart_type": "static",
                    "options": chart_options,
                }

                ctf_json_data_all = {
                    "ctf_data": [json_data1, json_data2],
                    "ctf_tables": [json_table1, json_table2],
                    "ctf_charts": [json_chart],
                }

                save_test_action_result_json_data(
                    test_action_result_id=date_test_action_result["data"]
                    ["test_action_result_id"],
                    ctf_json_data_all=json.dumps(ctf_json_data_all),
                )

                test_outcome = save_test_run_outcome(test_exe_id)
                log.info(test_outcome["message"])
            else:
                log.error("Unable to create test run result")
        else:
            log.error("Unable to find device")
    else:
        log.error("Unable to reserve test setup")
    set_test_setup_and_devices_free(TEST_SETUP_ID)
示例#2
0
heatmap_action_res = save_test_action_result(
    test_run_id=test_exe_id,
    description="Heatmap Action",
    outcome=0,
    logs=
    "This action is to demonstrate the association of heatmap data files with an action",
    start_time=datetime.datetime.now(),
    end_time=datetime.datetime.now(),
)

tg_add_test_action_heatmap(
    test_exe_id=test_exe_id,
    test_action_result_id=heatmap_action_res["data"]["test_action_result_id"],
    initiator_file_path="/Users/patrickhsu/Downloads/DUT-2_2_full_fw_stat.txt",
    responder_file_path="/Users/patrickhsu/Downloads/DUT-1_1_full_fw_stat.txt",
    description="Association from DUT1 to DUT2",
)

tg_add_test_action_heatmap(
    test_exe_id=test_exe_id,
    test_action_result_id=heatmap_action_res["data"]["test_action_result_id"],
    initiator_file_path="/Users/patrickhsu/Downloads/DUT-3_3_full_fw_stat.txt",
    responder_file_path="/Users/patrickhsu/Downloads/DUT-1_1_full_fw_stat.txt",
    description="Association from DUT1 to DUT3",
)

test_outcome = save_test_run_outcome(test_exe_id)

set_test_setup_and_devices_free(TEST_SETUP_ID)
示例#3
0
def free_test_setup_clean_up() -> None:
    log.info("\n------------free_test_setup_clean_up-------------")
    set_test_setup_and_devices_free(TEST_SETUP_ID)