def run(test, params, env):
    """
    Test complex options of the virt-sandbox command
    """
    status_error = bool("yes" == params.get("status_error", "no"))

    # list of sandbox aggregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        test.fail("Failed to return list of instantiated "
                  "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results()
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    # positive and negative testing #########
    if not status_error:
        if status != 0:
            test.fail("%d not a expected command "
                      "return value" % status)
        else:
            logging.info(cmd_outputs)
Esempio n. 2
0
def run(test, params, env):
    """
    Test complex options of the virt-sandbox command
    """
    status_error = bool("yes" == params.get("status_error", "no"))

    # list of sandbox agregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        raise error.TestFail("Failed to return list of instantiated "
                             "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results()
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    # positive and negative testing #########
    if not status_error:
        if status != 0:
            raise error.TestFail("%d not a expected command "
                                 "return value", status)
        else:
            logging.info(cmd_outputs)
def run(test, params, env):
    """
    Test network options of virt-sandbox command

    1) Positive testing
       1.1) Configure the network interface using dhcp
       1.2) Configure the network interface with the static
            IPv4 or IPv6 address
       1.3) Set the MAC address of the network interface
       1.4) Configure the network interface with the static
            IPv4 or IPv6 route
       1.5) Set multiple network interfaces
    2) Negative testing
       2.1) invalid network option
       2.2) invalid virtual network
       2.3) invalid static IPv4 or IPv6 network
       2.4) invalid MAC address
       2.5) Multicast address as MAC address
       2.6) invalid route argument
       2.7) static route without addresses
       2.8) static route with DHCP
       2.9) static route without gateway
    """
    status_error = bool("yes" == params.get("status_error", "no"))
    timeout = params.get("lvsb_network_timeout", 5)

    # list of sandbox agregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        raise error.TestFail("Failed to return list of instantiated "
                             "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results(int(timeout))
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    _params = dict(params)
    # To get output of the command
    _params['lvsb_result'] = cmd_outputs

    # positive and negative testing #########
    if status_error:
        if status == 0:
            raise error.TestFail("%d not a expected command "
                                 "return value", status)
        else:
            logging.info("It's an expected error: %s", _params['lvsb_result'])
    else:
        if status != 0:
            raise error.TestFail("%d not a expected command "
                                 "return value", status)
        if not verify_network(_params):
            raise error.TestFail("The network doesn't match!!")
def run(test, params, env):
    """
    Test network options of virt-sandbox command

    1) Positive testing
       1.1) Configure the network interface using dhcp
       1.2) Configure the network interface with the static
            IPv4 or IPv6 address
       1.3) Set the MAC address of the network interface
       1.4) Configure the network interface with the static
            IPv4 or IPv6 route
       1.5) Set multiple network interfaces
    2) Negative testing
       2.1) invalid network option
       2.2) invalid virtual network
       2.3) invalid static IPv4 or IPv6 network
       2.4) invalid MAC address
       2.5) Multicast address as MAC address
       2.6) invalid route argument
       2.7) static route without addresses
       2.8) static route with DHCP
       2.9) static route without gateway
    """
    status_error = bool("yes" == params.get("status_error", "no"))
    timeout = params.get("lvsb_network_timeout", 5)

    # list of sandbox agregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        raise error.TestFail("Failed to return list of instantiated "
                             "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results(int(timeout))
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    _params = dict(params)
    # To get output of the command
    _params['lvsb_result'] = cmd_outputs

    # positive and negative testing #########
    if status_error:
        if status == 0:
            raise error.TestFail("%d not a expected command "
                                 "return value", status)
        else:
            logging.info("It's an expected error: %s", _params['lvsb_result'])
    else:
        if status != 0:
            raise error.TestFail("%d not a expected command "
                                 "return value", status)
        if not verify_network(_params):
            raise error.TestFail("The network doesn't match!!")
def run(test, params, env):
    """
    Test security options of virt-sandbox command

    1) Positive testing
       1.1) dynamically allocate an SELinux label, using the default
            base context
       1.2) dynamically allocate an SELinux label, using the base context
            USER:ROLE:TYPE:LEVEL, instead of the default base context
       1.3) staticly allocate an SELinux label, using the selinux context
            USER:ROLE:TYPE:LEVEL
    2) Negative testing
       2.1) invalid security option
       2.2) invalid dynamic_selinux context
       2.3) invalid static selinux context
    """
    status_error = bool("yes" == params.get("status_error", "no"))
    # list of sandbox agregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        raise error.TestFail("Failed to return list of instantiated "
                             "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results()
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # The selinux context should be unique
    if len(cmd_outputs) > 1:
        logging.error("There are different selinux contexts: %s", cmd_outputs)

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    _params = dict(params)
    # To get output of the command
    _params['lvsb_result'] = cmd_outputs[0]

    # positive and negative testing #########
    if status_error:
        if status == 0:
            raise error.TestFail("%d not an expected command "
                                 "return value" % status)
        elif verify_selinux_label(_params):
            raise error.TestFail("To expect selinux context is different!!")
        else:
            logging.info("It's an expected error: %s", _params['lvsb_result'])
    else:
        if status != 0:
            raise error.TestFail("%d not an expected command "
                                 "return value" % status)
        if not verify_selinux_label(_params):
            raise error.TestFail("The selinux context doesn't match!!")
def run(test, params, env):
    """
    Test security options of virt-sandbox command

    1) Positive testing
       1.1) dynamically allocate an SELinux label, using the default
            base context
       1.2) dynamically allocate an SELinux label, using the base context
            USER:ROLE:TYPE:LEVEL, instead of the default base context
       1.3) staticly allocate an SELinux label, using the selinux context
            USER:ROLE:TYPE:LEVEL
    2) Negative testing
       2.1) invalid security option
       2.2) invalid dynamic_selinux context
       2.3) invalid static selinux context
    """
    status_error = bool("yes" == params.get("status_error", "no"))
    # list of sandbox agregation managers
    sb_list = make_sandboxes(params, env)
    if not sb_list:
        raise error.TestFail("Failed to return list of instantiated "
                             "lvsb_testsandboxes classes")

    # Run a sandbox until timeout or finished w/ output
    # store list of stdout's for the sandbox in aggregate type
    cmd_output_list = sb_list[0].results()
    # Remove all duplicate items from result list
    cmd_outputs = list(set(cmd_output_list[0].splitlines()))

    # The selinux context should be unique
    if len(cmd_outputs) > 1:
        logging.error("There are different selinux contexts: %s", cmd_outputs)

    # To get exit codes of the command
    status = sb_list[0].are_failed()

    _params = dict(params)
    # To get output of the command
    _params['lvsb_result'] = cmd_outputs[0]

    # positive and negative testing #########
    if status_error:
        if status == 0:
            raise error.TestFail("%d not an expected command "
                                 "return value" % status)
        elif verify_selinux_label(_params):
            raise error.TestFail("To expect selinux context is different!!")
        else:
            logging.info("It's an expected error: %s", _params['lvsb_result'])
    else:
        if status != 0:
            raise error.TestFail("%d not an expected command "
                                 "return value" % status)
        if not verify_selinux_label(_params):
            raise error.TestFail("The selinux context doesn't match!!")
Esempio n. 7
0
def run(test, params, env):
    """
    Executes date command in a sanbox and verifies it is correct

    1) Gather parameters
    2) Create configured sandbox aggregater(s)
    3) Run and stop all sandboxes in all agregators
    4) Handle results
    """
    # Record time for comparison when finished
    start_time = datetime.datetime.now()
    status_error = bool('yes' == params.get('status_error', 'no'))
    # list of sandbox agregation managers (list of lists of list of sandboxes)
    sb_agg_list = make_sandboxes(params, env)
    # Number of sandboxes for each aggregate type
    agg_count = [agg.count for agg in sb_agg_list]
    # Run all sandboxes until timeout or finished w/ output
    # store list of stdout's for each sandbox in each aggregate type
    result_list = [agg.results() for agg in sb_agg_list]
    # Timeouts throw SandboxException, if normal exit, record ending time
    stop_time = datetime.datetime.now()

    # Number of sandboxs with non-zero exit codes for each aggregate type
    failed_list = [agg.are_failed() for agg in sb_agg_list]

    # handle results
    if status_error:  # Negative test
        if not some_failed(failed_list) and verify_datetime(start_time,
                                                            stop_time,
                                                            result_list) < 1:
            raise error.TestFail("Error test failed on only %s of %s sandboxes"
                                 % (failed_list, agg_count))
    else:  # Positive test
        if some_failed(failed_list):
            raise error.TestFail("Some sandboxes had non-zero exit codes")
        if verify_datetime(start_time, stop_time, result_list) > 0:
            raise error.TestFail("Some sandboxes reported invalid date/time")
Esempio n. 8
0
def run(test, params, env):
    """
    Executes date command in a sanbox and verifies it is correct

    1) Gather parameters
    2) Create configured sandbox aggregater(s)
    3) Run and stop all sandboxes in all agregators
    4) Handle results
    """
    # Record time for comparison when finished
    start_time = datetime.datetime.now()
    status_error = bool('yes' == params.get('status_error', 'no'))
    # list of sandbox agregation managers (list of lists of list of sandboxes)
    sb_agg_list = make_sandboxes(params, env)
    # Number of sandboxes for each aggregate type
    agg_count = [agg.count for agg in sb_agg_list]
    # Run all sandboxes until timeout or finished w/ output
    # store list of stdout's for each sandbox in each aggregate type
    result_list = [agg.results() for agg in sb_agg_list]
    # Timeouts throw SandboxException, if normal exit, record ending time
    stop_time = datetime.datetime.now()

    # Number of sandboxs with non-zero exit codes for each aggregate type
    failed_list = [agg.are_failed() for agg in sb_agg_list]

    # handle results
    if status_error:  # Negative test
        if not some_failed(failed_list) and verify_datetime(
                start_time, stop_time, result_list) < 1:
            raise error.TestFail(
                "Error test failed on only %s of %s sandboxes" %
                (failed_list, agg_count))
    else:  # Positive test
        if some_failed(failed_list):
            raise error.TestFail("Some sandboxes had non-zero exit codes")
        if verify_datetime(start_time, stop_time, result_list) > 0:
            raise error.TestFail("Some sandboxes reported invalid date/time")