示例#1
0
def execute_test():

    output_table = []

    with test_utils.dobby_daemon(), test_utils.untar_bundle(container_name) as bundle_path:

        # createRuntime fails with the networking plugin without a container present with
        # permission issues. The networking plugin is not designed to work with standalone
        # DobbyPluginLauncher at the moment, so we can ignore the message. The test will
        # succeed because the networking plugin is set to required=false in the bundle config.

        # Test 0
        test = tests[0]
        command = ["DobbyPluginLauncher",
                   "-v",
                   "-h", hook_name,
                   "-c", bundle_path + "/config.json"]

        # cannot be simple run_command as we need input in this case
        # status = test_utils.run_command_line(command)

        # The state of the container MUST be passed to hooks over stdin so that they may
        # do work appropriate to the current state of the container.
        crun_input = """
        {
        "ociVersion": "1.0.2",
        "id": "%s",
        "status": "running",
        "pid":12345,
        "bundle": "%s",
        "annotations": {
            "myKey": "myValue"
            }
        }
        """ % (container_name, bundle_path)

        status = subprocess.run(command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            input=crun_input,
                            universal_newlines=True)

        result = test.expected_output.lower() in status.stderr.lower()
        output = test_utils.create_simple_test_output(test, result, log_content=status.stderr)

        output_table.append(output)
        test_utils.print_single_result(output)

    return test_utils.count_print_results(output_table)
示例#2
0
def execute_test():
    output_table = []

    with test_utils.dobby_daemon():
        for test in tests:
            process = dobby_tool_command(test.command, test.container_id)
            test_utils.print_log("command output = %s" % process.stdout,
                                 test_utils.Severity.debug)
            result = test.expected_output in process.stdout
            if test.negation:
                result = not result
            output = test_utils.create_simple_test_output(test, result)
            output_table.append(output)
            test_utils.print_single_result(output)

    return test_utils.count_print_results(output_table)
示例#3
0
def execute_test():
    if test_utils.selected_platform == test_utils.Platforms.no_selection:
        return test_utils.print_unsupported_platform(
            basename(__file__), test_utils.selected_platform)

    with test_utils.dobby_daemon():
        output_table = []

        for test in tests:
            result = test_container(test.container_id, test.expected_output)
            output = test_utils.create_simple_test_output(
                test, result[0], result[1])

            output_table.append(output)
            test_utils.print_single_result(output)

    return test_utils.count_print_results(output_table)
示例#4
0
def execute_test():
    if test_utils.selected_platform == test_utils.Platforms.no_selection:
        return test_utils.print_unsupported_platform(basename(__file__), test_utils.selected_platform)

    tests = create_tests()

    wpeframework = start_wpeframework()

    output_table = []

    with test_utils.dobby_daemon(), test_utils.untar_bundle(container_name) as bundle_path:
        for test in tests:
            full_command = create_curl_command(test, bundle_path)
            result = test_utils.run_command_line(full_command)
            # success = test.expected_output in result.stdout
            success = search(test.expected_output, result.stdout) is not None
            output = test_utils.create_simple_test_output(test, success, log_content=result.stdout+result.stderr)

            output_table.append(output)
            test_utils.print_single_result(output)

    stop_wpeframework(wpeframework)

    return test_utils.count_print_results(output_table)
示例#5
0
def execute_test():

    output_table = []

    with test_utils.dobby_daemon(), test_utils.untar_bundle(
            container_name) as bundle_path:

        # Test 0
        test = tests[0]
        command = [
            "DobbyPluginLauncher", "-v", "-h", "createRuntime", "-c",
            bundle_path + "/config.json"
        ]

        status = test_utils.run_command_line(command)

        result = test.expected_output.lower() in status.stderr.lower()
        output = test_utils.create_simple_test_output(
            test, result, log_content=status.stderr)

        output_table.append(output)
        test_utils.print_single_result(output)

    return test_utils.count_print_results(output_table)
示例#6
0
def execute_test():

    # We use a preconfigured tarball bundle for this test, the container has the following arg:
    #
    #   echo DOBBY_TEST | netcat 100.64.11.1 7357
    #
    # This will send 'DOBBY_TEST' to the dobby0 bridge device at port 7357. We're expecting
    # this to be received on the listening port 7357 on the localhost because of the added
    # networking configuration in the bundle config:
    #
    #   "portForwarding": {
    #       "containerToHost": [
    #           {
    #               "port": 7357,
    #               "protocol": "udp"
    #           },
    #           {
    #               "port": 7357,
    #               "protocol": "tcp"
    #           }
    #       ]
    #   }
    #

    # netcat is not available on RDK builds, skip test
    if test_utils.selected_platform == test_utils.Platforms.xi_6:
        return test_utils.print_unsupported_platform(
            basename(__file__), test_utils.selected_platform)

    output_table = []

    with test_utils.dobby_daemon(), netcat_listener(
    ) as nc, test_utils.untar_bundle(container_name) as bundle_path:
        # Test 0
        test = tests[0]
        command = ["DobbyTool", "start", container_name, bundle_path]

        status = test_utils.run_command_line(command)

        message = ""
        result = True

        # give container time to start and send message before checking netcat listener
        sleep(2)

        nc_message = nc.get_output().rstrip("\n")

        # check if netcat listener received message
        if test.expected_output.lower() not in nc_message.lower():
            message = "Received '%s' from container, expected '%s'" % (
                nc_message.lower(), test.expected_output.lower())
            result = False
        else:
            message = "Successfully received message '%s' from container" % nc_message

        output = test_utils.create_simple_test_output(test, result, message,
                                                      status.stderr)
        output_table.append(output)
        test_utils.print_single_result(output)

    return test_utils.count_print_results(output_table)