Esempio n. 1
0
def platform_dependent_modifications():
    """Changes test 1 based on selected platform

    Parameters:
    None: global test_utils.selected_platform decides what to do

    Returns:
    Nothing

    Raises:
    'Unknown platform' if platform not supported

    """

    if test_utils.selected_platform == test_utils.Platforms.xi_6:
        tests[1] = test_utils.Test(
            "Check mounts", "mounts-xi6", "JENKINS_BUILD_NUMBER=",
            "Mounts a sample text file into the container and attempts to read it"
        )
    elif test_utils.selected_platform == test_utils.Platforms.virtual_machine:
        # nothing to do, already selected proper one
        pass
    else:
        raise Exception('Unknown platform')
Esempio n. 2
0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils

# in case we would like to change container name
container_name = "sleepy"

tests = (
    test_utils.Test("Create bundle",
                    container_name,
                    "Dobby Bundle Generator Tool",
                    "Generates bundle with DobbyBundleGenerator"),
    test_utils.Test("Diff bundles",
                    container_name,
                    "",
                    "Compares between original bundle and newly generated one"),
    test_utils.Test("Remove bundle",
                    container_name,
                    "",
                    "Removes files created by this test group"),
)


def execute_test():

    # this testcase is using tarball bundle so it gets all empty folders. They would get skipped by git. So in that
Esempio n. 3
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils
from time import sleep
import subprocess
from os.path import basename

# in case we would like to change container name
container_name = "network1"

tests = (test_utils.Test("Test communication to host", container_name,
                         "DOBBY_TEST",
                         "Tests port forwarding from container to host."), )


class netcat_listener:
    """ Starts netcat listener on port 7357 """
    def __init__(self):

        # as this process is running infinitely we cannot use run_command_line as it waits for execution to end
        self.subproc = subprocess.Popen(["netcat", "-l", "localhost", "7357"],
                                        universal_newlines=True,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)

    def __enter__(self):
        return self
Esempio n. 4
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(test_utils.Test())
    suite.addTest(test_clean_fasta.Test())
    return suite
Esempio n. 5
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils
from subprocess import check_output
import subprocess
from time import sleep
import multiprocessing
from os.path import basename

tests = (
    test_utils.Test("Start DobbyDaemon",
                    "No container",
                    "started Dobby daemon",
                    "Starts \"DobbyDaemon\" and check if it opened successfully"),
    test_utils.Test("Check DobbyDaemon running",
                    "No container",
                    "sudo DobbyDaemon --nofork --journald",
                    "Check if DobbyDaemon process is running"),
    test_utils.Test("Stop DobbyDaemon",
                    "No container",
                    "stopped Dobby daemon",
                    "Stops \"DobbyDaemon\" and check if it stopped successfully"),
    test_utils.Test("Check DobbyDaemon stopped",
                    "No container",
                    "sudo DobbyDaemon --nofork --journald",
                    "Check if DobbyDaemon process was killed"),

)
Esempio n. 6
0
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils
from os.path import basename

tests = [
    test_utils.Test(
        "Check echo", "echo", "hello world",
        "Prints \"Hello World\" to the console as a baseline functionality test"
    ),
    test_utils.Test(
        "Check mounts", "mounts-vm", "lorem ipsum",
        "Mounts a sample text file into the container and attempts to read it"
    ),
    test_utils.Test("Check environment variables", "envvar", "12345",
                    "Set environment variables"),
    ### Skip ram test, which is currently not working as intended due to file access issues. Likely related to lack of access to cgroups
    ### namespace in containers which used to work beforehand with crun.
    #test_utils.Test("Check ram",
    #                "ram",
    #                "2998272",
    #                "Creates a container a 3MB RAM limit. Checks this limit by reading the value of /sys/fs/cgroup/memory/memory.limit_in_bytes"),
    test_utils.Test(
        "Check private network", "wget-private",
Esempio n. 7
0
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils
from os.path import basename

tests = [
    test_utils.Test(
        "Logging to file", "filelogging",
        ["hello world 1", "hello world 2", "hello world 10"],
        "Prints hello world 10 times, output should be contained in the logfile"
    ),
    test_utils.Test("No logging", "nolog", "",
                    "Starts a container without any logfile"),
]


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 = []
Esempio n. 8
0
import test_utils

container_name = "sleepy-thunder"

tests = (test_utils.Test(
    "Run plugin launcher", container_name, "Plugins run successfully",
    "Runs plugins launcher and check if it runned properly"), )


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)
Esempio n. 9
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import test_utils
import subprocess

container_name = "sleepy-thunder"
hook_name = "createRuntime"

tests = (
    test_utils.Test("Run plugin launcher",
                    container_name,
                    "Hook %s completed" % hook_name,
                    "Runs plugins launcher and check if it ran properly"),
)


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.
Esempio n. 10
0
import test_utils
from os.path import basename

tests = [
    test_utils.Test("Check echo",
                    "echo",
                    "hello world",
                    "Prints \"Hello World\" to the console as a baseline functionality test"),
    test_utils.Test("Check mounts",
                    "mounts-vm",
                    "lorem ipsum",
                    "Mounts a sample text file into the container and attempts to read it"),
    test_utils.Test("Check environment variables",
                    "envvar",
                    "12345",
                    "Set environment variables"),
    test_utils.Test("Check ram",
                    "ram",
                    "2998272",
                    "Creates a container a 3MB RAM limit. Checks this limit by reading the value of /sys/fs/cgroup/memory/memory.limit_in_bytes"),
    test_utils.Test("Check private network",
                    "wget-private",
                    "unable to resolve host address",
                    "With Private networking, the container should not be able to reach external webpages"),
    test_utils.Test("Check network",
                    "wget",
                    "HTTP request sent, awaiting response... 200 OK",
                    "With NAT networking, the container should be able to fetch webpages"),
]