예제 #1
0
# TODO: Using this cap should actually fail when we get the error handling correct,
#       see reported issue
test_cap = Capability("test.cap", [{"id": "test", "config": []}])
""" A valid dbus GW cap to test e.g. listing of available caps """
test_cap_dbus = Capability("test.cap.valid-dbus", [{
    "id": "dbus",
    "config": DBUS_GW_CONFIG
}])

test_cap_broken = Capability("test.cap.broken-gw-config",
                             [{
                                 "id": "dbus",
                                 "config": ["malformed"]
                             }])

manifest = StandardManifest(TESTOUTPUT_DIR, "caps-test-manifest.json",
                            [test_cap, test_cap_dbus, test_cap_broken])
""" Sample env gateway config, used for default capabilities """
ENV_GW_CONFIG = [{"name": "TEST_ENV_VAR", "value": "TEST_ENV_VALUE"}]
""" The default capability, just the env gateway config """
default_cap = Capability("test.cap.default.sample", [{
    "id": "env",
    "config": ENV_GW_CONFIG
}])
""" The default manifest contains only the default capability """
default_manifest = DefaultManifest(TESTOUTPUT_DIR, "default-caps.json",
                                   [default_cap])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
예제 #2
0
GW_CONFIG_SINGLE_VAR_VARIATION_2 = [{"name": "MY_ENV_VAR_2", "value": "2"}]

test_cap_7 = Capability("environment.test.cap.7",
                        [{
                            "id": "env",
                            "config": GW_CONFIG_SINGLE_VAR_VARIATION_1
                        }])

test_cap_8 = Capability("environment.test.cap.8",
                        [{
                            "id": "env",
                            "config": GW_CONFIG_SINGLE_VAR_VARIATION_2
                        }])
""" Define the manifest so it can be used by the testframework  """
manifest = StandardManifest(TESTOUTPUT_DIR, "environment-test-manifest.json", [
    test_cap_1, test_cap_2, test_cap_3, test_cap_4, test_cap_5, test_cap_6,
    test_cap_7, test_cap_8
])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


##### Test suites #####


@pytest.mark.usefixtures("testhelper", "create_testoutput_dir", "agent",
예제 #3
0
    "config": CONFIG_TEST_NETCLS
}])

cap_4 = Capability("test.cap.cpu.shares.threshold",
                   [{
                       "id": "cgroups",
                       "config": CONFIG_CPU_SHARES_LOW_THRESHOLD
                   }])

cap_5 = Capability("test.cap.cpu.shares.whitelist",
                   [{
                       "id": "cgroups",
                       "config": CONFIG_CPU_SHARES_WHITELISTING
                   }])

manifest = StandardManifest(TESTOUTPUT_DIR, "cgroup-test-manifest.json",
                            [cap_0, cap_1, cap_2, cap_3, cap_4, cap_5])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


"""##### Test suites #####"""


@pytest.mark.usefixtures("testhelper", "create_testoutput_dir", "agent")
class TestCGroupGateway(object):
예제 #4
0
GW_CONFIG = [{
    "dbus-gateway-config-session": [{
        "direction": "*",
        "interface": "*",
        "object-path": "*",
        "method": "*"
    }],
    "dbus-gateway-config-system": []
}]

test_cap = Capability("test.cap.profiling", [{
    "id": "dbus",
    "config": GW_CONFIG
}])

manifest = StandardManifest(TESTOUTPUT_DIR, "profiling-test-manifest.json",
                            [test_cap])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


def run_test(num_starts=3):
    apps = list()
    for app in range(0, num_starts):
        """ Start numStarts apps in softwarecontainer.
            """
예제 #5
0
test_cap_3 = Capability("double.activation.new.device.1.cap",
                        [{
                            "id": "devicenode",
                            "config": GW_CONFIG_NEW_DEV_1
                        }])
""" Following capability is fed to DynamicConfiguration tests to examine the case
    when exactly same device with same mode is added
"""
test_cap_4 = Capability("double.activation.same.device.same.mode.cap",
                        [{
                            "id": "devicenode",
                            "config": GW_CONFIG_SAME_DEV_SAME_MODE
                        }])
""" Define the manifest so it can be used by the testframework  """
manifest = StandardManifest(
    TESTOUTPUT_DIR, "devicenode-test-manifest.json",
    [test_cap_0, test_cap_1, test_cap_2, test_cap_3, test_cap_4])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


# Test suites


@pytest.mark.usefixtures("testhelper", "agent")
                        [{
                            "id": "network",
                            "config": GW_CONFIG_ACCEPT_EXAMPLE_COM
                        }])

test_cap_5 = Capability("test.cap.accept-two-domains",
                        [{
                            "id": "network",
                            "config": GW_CONFIG_ACCEPT_EXAMPLE_COM
                        }, {
                            "id": "network",
                            "config": GW_CONFIG_ACCEPT_IANA_ORG
                        }])

manifest = StandardManifest(
    TESTOUTPUT_DIR, "network-test-manifest.json",
    [test_cap_1, test_cap_2, test_cap_3, test_cap_4, test_cap_5])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


##### Test suites #####


@pytest.mark.usefixtures("testhelper", "create_testoutput_dir", "agent")
예제 #7
0
}])
""" Cap with only GW_CONFIG_DENY_ALL """
test_cap_deny_all = Capability("test.cap.denyall",
                               [{
                                   "id": "dbus",
                                   "config": GW_CONFIG_DENY_ALL
                               }])
""" Cap with only GW_CONFIG_ALLOW_PING """
test_cap_allow_ping = Capability("test.cap.allowping",
                                 [{
                                     "id": "dbus",
                                     "config": GW_CONFIG_ALLOW_PING
                                 }])

manifest = StandardManifest(
    TESTOUTPUT_DIR, "dbus-test-manifest.json",
    [test_cap_1, test_cap_2, test_cap_deny_all, test_cap_allow_ping])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


@pytest.mark.usefixtures("dbus_launch", "create_testoutput_dir", "agent",
                         "assert_no_proxy")
class TestDBus(object):
    """ This suite should do some basic testing of the D-Bus setup with the gateway,
예제 #8
0
    return TESTOUTPUT_DIR + "/test.log"


# These default values are used to pass various test specific values and
# configurations to the Container helper. Tests that need to add, remove or
# update entries can simply base their dict on this one for convenience.
DATA = {
    Container.CONFIG: '[{"enableWriteBuffer": false}]',
    Container.BIND_MOUNT_DIR: "/gateways/app",
    Container.HOST_PATH: CURRENT_DIR,
    Container.READONLY: False
}
""" An empty capability for the service manifest """
test_cap = Capability("test.cap.valid-dbus", [])

manifest = StandardManifest(TESTOUTPUT_DIR, "queries-test-manifest.json",
                            [test_cap])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


# This function is used by the testframework 'testhelper' fixture to know where the
# testhelper should be made available when running the tests
def mounted_path_in_host():
    return CURRENT_DIR
예제 #9
0
                            "id": "cgroups",
                            "config": CONFIG_TEST_MEMORY_SHARE
                        }])

test_cap_2 = Capability("test.cap.memory.whitelist",
                        [{
                            "id": "cgroups",
                            "config": CONFIG_TEST_MEMORY_WHITELISTING
                        }])

test_cap_3 = Capability("test.cap.netcls", [{
    "id": "cgroups",
    "config": CONFIG_TEST_NETCLS
}])

manifest = StandardManifest(TESTOUTPUT_DIR, "cgroup-test-manifest.json",
                            [test_cap_0, test_cap_1, test_cap_2, test_cap_3])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


"""##### Test suites #####"""


@pytest.mark.usefixtures("testhelper", "create_testoutput_dir", "agent")
class TestCGroupGateway(object):
예제 #10
0
        "method": "*"
    }],
    "dbus-gateway-config-system": []
}]
""" Cap with only GW_CONFIG"""
test_cap_1 = Capability("test.cap.gwconfig", [{
    "id": "dbus",
    "config": GW_CONFIG
}])
""" Cap with only WL_CONFIG """
test_cap_2 = Capability("test.cap.wlconfig", [{
    "id": "dbus",
    "config": WL_CONFIG
}])

manifest = StandardManifest(TESTOUTPUT_DIR, "dbus-test-manifest.json",
                            [test_cap_1, test_cap_2])


def service_manifests():
    """ The agent fixture calls this function when it creates the service manifests
        that should be used with this test module. The agent fixture expects a list
        of StandardManifest and/or DefaultManifest objects.
    """
    return [manifest]


@pytest.mark.usefixtures("dbus_launch", "create_testoutput_dir", "agent",
                         "assert_no_proxy")
class TestDBus(object):
    """ This suite should do some basic testing of the D-Bus setup with the gateway,
        an app in a container, the proxy, etc. After that, the main point is to