Ejemplo n.º 1
0
def update_tests_in_db(tests,
                       dry_run=False,
                       add_experimental=False,
                       add_noncompliant=False,
                       autotest_dir=None):
    """
    Scans through all tests and add them to the database.

    This function invoked when -t supplied and for update_all.
    When test code is discovered in the file system new tests may be added

    @param tests: list of tests found in the filesystem.
    @param dry_run: not used at this time.
    @param add_experimental: add tests with experimental attribute set.
    @param add_noncompliant: attempt adding test with invalid control files.
    @param autotest_dir: prepended to path strings
            (see global_config.ini, COMMON, autotest_top_path).
    """
    site_set_attributes_module = utils.import_site_module(
        __file__, 'autotest.utils.site_test_importer_attributes')

    for test in tests:
        new_test = models.Test.objects.get_or_create(
            path=test.replace(autotest_dir, '').lstrip('/'))[0]
        logging.info("Processing %s", new_test.path)

        # Set the test's attributes
        data = tests[test]
        _set_attributes_clean(new_test, data)

        # Custom Attribute Update
        if site_set_attributes_module:
            site_set_attributes_module._set_attributes_custom(new_test, data)

        # This only takes place if --add-noncompliant is provided on the CLI
        if not new_test.name:
            test_new_test = test.split('/')
            if test_new_test[-1] == 'control':
                new_test.name = test_new_test[-2]
            else:
                control_name = "%s:%s"
                control_name %= (test_new_test[-2], test_new_test[-1])
                new_test.name = control_name.replace('control.', '')

        # Experimental Check
        if not add_experimental and new_test.experimental:
            continue

        _log_or_execute(repr(new_test), new_test.save)
        add_label_dependencies(new_test)

        # save TestParameter
        for para_name in data.test_parameters:
            test_parameter = models.TestParameter.objects.get_or_create(
                test=new_test, name=para_name)[0]
            test_parameter.save()
Ejemplo n.º 2
0
def update_tests_in_db(tests, dry_run=False, add_experimental=False, add_noncompliant=False, autotest_dir=None):
    """
    Scans through all tests and add them to the database.

    This function invoked when -t supplied and for update_all.
    When test code is discovered in the file system new tests may be added

    :param tests: list of tests found in the filesystem.
    :param dry_run: not used at this time.
    :param add_experimental: add tests with experimental attribute set.
    :param add_noncompliant: attempt adding test with invalid control files.
    :param autotest_dir: prepended to path strings
            (see global_config.ini, COMMON, autotest_top_path).
    """
    site_set_attributes_module = utils.import_site_module(__file__, "autotest.utils.site_test_importer_attributes")

    for test in tests:
        # if test path is not inside base test dir, the subsequent
        # test load will fail so instead notify user right away
        if not test.startswith(autotest_dir):
            raise Exception("Test path " + "%s not in %s, did you forget to use -z option?" % (test, autotest_dir))

        new_test = models.Test.objects.get_or_create(path=test.replace(autotest_dir, "").lstrip("/"))[0]
        logging.info("Processing %s", new_test.path)

        # Set the test's attributes
        data = tests[test]
        _set_attributes_clean(new_test, data)

        # Custom Attribute Update
        if site_set_attributes_module:
            site_set_attributes_module._set_attributes_custom(new_test, data)

        # This only takes place if --add-noncompliant is provided on the CLI
        if not new_test.name:
            test_new_test = test.split("/")
            if test_new_test[-1] == "control":
                new_test.name = test_new_test[-2]
            else:
                control_name = "%s:%s"
                control_name %= (test_new_test[-2], test_new_test[-1])
                new_test.name = control_name.replace("control.", "")

        # Experimental Check
        if not add_experimental and new_test.experimental:
            continue

        _log_or_execute(repr(new_test), new_test.save)
        add_label_dependencies(new_test)

        # save TestParameter
        for para_name in data.test_parameters:
            test_parameter = models.TestParameter.objects.get_or_create(test=new_test, name=para_name)[0]
            test_parameter.save()
Ejemplo n.º 3
0
def update_tests_in_db(tests, dry_run=False, add_experimental=False,
                       add_noncompliant=False, autotest_dir=None):
    """
    Scans through all tests and add them to the database.

    This function invoked when -t supplied and for update_all.
    When test code is discovered in the file system new tests may be added

    @param tests: list of tests found in the filesystem.
    @param dry_run: not used at this time.
    @param add_experimental: add tests with experimental attribute set.
    @param add_noncompliant: attempt adding test with invalid control files.
    @param autotest_dir: prepended to path strings
            (see global_config.ini, COMMON, autotest_top_path).
    """
    site_set_attributes_module = utils.import_site_module(
        __file__, 'autotest.utils.site_test_importer_attributes')

    for test in tests:
        new_test = models.Test.objects.get_or_create(
                path=test.replace(autotest_dir, '').lstrip('/'))[0]
        logging.info("Processing %s", new_test.path)

        # Set the test's attributes
        data = tests[test]
        _set_attributes_clean(new_test, data)

        # Custom Attribute Update
        if site_set_attributes_module:
            site_set_attributes_module._set_attributes_custom(new_test, data)

        # This only takes place if --add-noncompliant is provided on the CLI
        if not new_test.name:
            test_new_test = test.split('/')
            if test_new_test[-1] == 'control':
                new_test.name = test_new_test[-2]
            else:
                control_name = "%s:%s"
                control_name %= (test_new_test[-2],
                                 test_new_test[-1])
                new_test.name = control_name.replace('control.', '')

        # Experimental Check
        if not add_experimental and new_test.experimental:
            continue

        _log_or_execute(repr(new_test), new_test.save)
        add_label_dependencies(new_test)

        # save TestParameter
        for para_name in data.test_parameters:
            test_parameter = models.TestParameter.objects.get_or_create(
                test=new_test, name=para_name)[0]
            test_parameter.save()
Ejemplo n.º 4
0
Usage?  Just run it.
    utils/build_externals.py
"""

import compileall, logging, os, shutil, sys, tempfile, time, urllib2
import subprocess, re
try:
    import autotest.common as common
except ImportError:
    import common
from autotest.client.shared import logging_config, logging_manager
from autotest.client.shared import utils
from autotest.utils import external_packages

# bring in site packages as well
utils.import_site_module(__file__, 'autotest.utils.site_external_packages')

# Where package source be fetched to relative to the top of the autotest tree.
PACKAGE_DIR = 'ExternalSource'

# Where packages will be installed to relative to the top of the autotest tree.
INSTALL_DIR = 'site-packages'

# Installs all packages, even if the system already has the version required
INSTALL_ALL = False

# Want to add more packages to fetch, build and install?  See the class
# definitions at the end of external_packages.py for examples of how to do it.


class BuildExternalsLoggingConfig(logging_config.LoggingConfig):
Ejemplo n.º 5
0
import httplib2
import sys
import traceback
import cgi

from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.http import HttpResponseServerError
from django.template import Context, loader
from autotest.client.shared import utils
from autotest.frontend import views_common
from autotest.frontend.afe import models, rpc_handler, rpc_interface
from autotest.frontend.afe import rpc_utils

site_rpc_interface = utils.import_site_module(
    __file__, 'autotest.frontend.afe.site_rpc_interface',
    dummy=object())

# since site_rpc_interface is later in the list, its methods will override those
# of rpc_interface
rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface, site_rpc_interface),
                                         document_module=rpc_interface)


def handle_rpc(request):
    return rpc_handler_obj.handle_rpc_request(request)


def rpc_documentation(request):
    return rpc_handler_obj.get_rpc_documentation()

Ejemplo n.º 6
0
import cgi
import sys
import traceback

import httplib2
from autotest.client.shared import utils
from autotest.frontend import views_common
from autotest.frontend.afe import models, rpc_handler, rpc_interface
from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.http import HttpResponseServerError
from django.template import Context, loader

site_rpc_interface = utils.import_site_module(
    __file__, 'autotest.frontend.afe.site_rpc_interface', dummy=object())

# since site_rpc_interface is later in the list, its methods will override those
# of rpc_interface
rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface, site_rpc_interface),
                                         document_module=rpc_interface)


def handle_rpc(request):
    return rpc_handler_obj.handle_rpc_request(request)


def rpc_documentation(request):
    return rpc_handler_obj.get_rpc_documentation()


def model_documentation(request):
    model_names = ('Label', 'Host', 'Test', 'User', 'AclGroup', 'Job',
Ejemplo n.º 7
0
import compileall
import logging
import os
import sys

try:
    import autotest.common as common  # pylint: disable=W0611
except ImportError:
    import common  # pylint: disable=W0611
from autotest.client.shared import logging_config, logging_manager
from autotest.client.shared import utils
from autotest.utils import external_packages

# bring in site packages as well
utils.import_site_module(__file__, "autotest.utils.site_external_packages")

# Where package source be fetched to relative to the top of the autotest tree.
PACKAGE_DIR = "ExternalSource"

# Where packages will be installed to relative to the top of the autotest tree.
INSTALL_DIR = "site-packages"

# Installs all packages, even if the system already has the version required
INSTALL_ALL = False


# Want to add more packages to fetch, build and install?  See the class
# definitions at the end of external_packages.py for examples of how to do it.