Exemple #1
0
    def test_result_notify(self):
        class fake_job(object):
            result = True
            name = 'nameFoo'
            id = 'idFoo'
            results_platform_map = {'NORAD': {'Seeking_Joshua': ['WOPR']}}

        settings.override_value('SERVER', 'hostname', 'chess')
        rpc_client_lib.authorization_headers.expect_call(
            'david', 'http://chess').and_return({'AUTHORIZATION': 'david'})
        rpc_client_lib.get_proxy.expect_call(
            'http://chess/afe/server/rpc/', headers={'AUTHORIZATION': 'david'})
        self.god.stub_function(utils, 'send_email')
        mail.send.expect_any_call()

        my_afe = frontend.AFE(user='******')

        fake_stdout = StringIO()
        self.god.stub_with(sys, 'stdout', fake_stdout)
        my_afe.result_notify(fake_job, 'userA', 'userB')
        self.god.unstub(sys, 'stdout')
        fake_stdout = fake_stdout.getvalue()

        self.god.check_playback()

        self.assert_('PASSED' in fake_stdout)
        self.assert_('WOPR' in fake_stdout)
        self.assert_('http://chess/tko/compose_query.cgi?' in fake_stdout)
        self.assert_('columns=test' in fake_stdout)
        self.assert_('rows=machine_group' in fake_stdout)
        self.assert_("condition=tag~'idFoo-%25'" in fake_stdout)
        self.assert_('title=Report' in fake_stdout)
        self.assert_('Sending email' in fake_stdout)
Exemple #2
0
    def test_result_notify(self):
        class fake_job(object):
            result = True
            name = 'nameFoo'
            id = 'idFoo'
            results_platform_map = {'NORAD' : {'Seeking_Joshua': ['WOPR']}}
        settings.override_value('SERVER', 'hostname', 'chess')
        rpc_client_lib.authorization_headers.expect_call(
                'david', 'http://chess').and_return(
                        {'AUTHORIZATION': 'david'})
        rpc_client_lib.get_proxy.expect_call(
                'http://chess/afe/server/rpc/',
                headers={'AUTHORIZATION': 'david'})
        self.god.stub_function(utils, 'send_email')
        utils.send_email.expect_any_call()

        my_afe = frontend.AFE(user='******')

        fake_stdout = StringIO()
        self.god.stub_with(sys, 'stdout', fake_stdout)
        my_afe.result_notify(fake_job, 'userA', 'userB')
        self.god.unstub(sys, 'stdout')
        fake_stdout = fake_stdout.getvalue()

        self.god.check_playback()

        self.assert_('PASSED' in fake_stdout)
        self.assert_('WOPR' in fake_stdout)
        self.assert_('http://chess/tko/compose_query.cgi?' in fake_stdout)
        self.assert_('columns=test' in fake_stdout)
        self.assert_('rows=machine_group' in fake_stdout)
        self.assert_("condition=tag~'idFoo-%25'" in fake_stdout)
        self.assert_('title=Report' in fake_stdout)
        self.assert_('Sending email' in fake_stdout)
Exemple #3
0
    def _frontend_common_setup(self, fill_data=True):
        self.god = mock.mock_god(ut=self)
        setup_test_environment.set_up()
        settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'False')
        settings.override_value('SERVER', 'rpc_logging', 'False')

        if fill_data:
            self._fill_in_test_data()
Exemple #4
0
    def _frontend_common_setup(self, fill_data=True):
        self.god = mock.mock_god(ut=self)
        setup_test_environment.set_up()
        settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'False')
        settings.override_value('SERVER', 'rpc_logging', 'False')

        if fill_data:
            self._fill_in_test_data()
 def test_decompose_gitweb(self):
     settings.override_value('CLIENT', 'kernel_gitweb', gw)
     settings.override_value('CLIENT', 'stable_kernel_gitweb', sgw)
     correct = [[
         km + 'v3.x/linux-3.0.tar.bz2',
         gw + ';a=snapshot;h=refs/tags/v3.0;sf=tgz'
     ]]
     sample = decompose_kernel('3.0')
     self.assertEqual(sample, correct)
Exemple #6
0
 def test_init(self):
     os.environ['LOGNAME'] = 'unittest-user'
     settings.override_value('SERVER', 'hostname', 'test-host')
     rpc_client_lib.authorization_headers.expect_call(
         'unittest-user',
         'http://test-host').and_return({'AUTHORIZATION': 'unittest-user'})
     rpc_client_lib.get_proxy.expect_call(
         'http://test-host/path',
         headers={'AUTHORIZATION': 'unittest-user'})
     frontend.RpcClient('/path', None, None, None, None, None)
     self.god.check_playback()
Exemple #7
0
 def test_init(self):
     os.environ['LOGNAME'] = 'unittest-user'
     settings.override_value('SERVER', 'hostname', 'test-host')
     rpc_client_lib.authorization_headers.expect_call(
             'unittest-user', 'http://test-host').and_return(
                     {'AUTHORIZATION': 'unittest-user'})
     rpc_client_lib.get_proxy.expect_call(
             'http://test-host/path',
             headers={'AUTHORIZATION': 'unittest-user'})
     frontend.RpcClient('/path', None, None, None, None, None)
     self.god.check_playback()
 def test_decompose_sha1(self):
     settings.override_value('CLIENT', 'kernel_gitweb', gw)
     settings.override_value('CLIENT', 'stable_kernel_gitweb', sgw)
     correct = [[
         gw +
         ';a=snapshot;h=02f8c6aee8df3cdc935e9bdd4f2d020306035dbe;sf=tgz',
         sgw +
         ';a=snapshot;h=02f8c6aee8df3cdc935e9bdd4f2d020306035dbe;sf=tgz'
     ]]
     sample = decompose_kernel('02f8c6aee8df3cdc935e9bdd4f2d020306035dbe')
     self.assertEqual(sample, correct)
    def test_job(self):
        settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'True')

        test = models.Test.objects.create(
            name='name', author='author', test_class='class',
            test_category='category',
            test_type=model_attributes.TestTypes.SERVER, path='path')
        parameterized_job = models.ParameterizedJob.objects.create(test=test)
        job = self._create_job(hosts=[1], control_file=None,
                               parameterized_job=parameterized_job)

        self.assertEqual(job, parameterized_job.job())
    def test_job(self):
        settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'True')

        test = models.Test.objects.create(
            name='name', author='author', test_class='class',
            test_category='category',
            test_type=model_attributes.TestTypes.SERVER, path='path')
        parameterized_job = models.ParameterizedJob.objects.create(test=test)
        job = self._create_job(hosts=[1], control_file=None,
                               parameterized_job=parameterized_job)

        self.assertEqual(job, parameterized_job.job())
Exemple #11
0
    def test_initialize(self):
        results_hostname = 'results_repo'
        results_install_dir = '/results/install'
        settings.override_value(scheduler_config.CONFIG_SECTION,
                                'results_host_installation_directory',
                                results_install_dir)

        (drones.get_drone.expect_call(self.mock_drone.name)
         .and_return(self.mock_drone))

        results_drone = MockDrone('results_drone')
        self.god.stub_function(results_drone, 'set_autotest_install_dir')
        drones.get_drone.expect_call(results_hostname).and_return(results_drone)
        results_drone.set_autotest_install_dir.expect_call(results_install_dir)

        self.manager.initialize(base_results_dir=self._RESULTS_DIR,
                                drone_hostnames=[self.mock_drone.name],
                                results_repository_hostname=results_hostname)

        self.assert_(self.mock_drone.was_call_queued(
            'initialize', self._DRONE_RESULTS_DIR + '/'))
        self.god.check_playback()
    def test_initialize(self):
        results_hostname = 'results_repo'
        results_install_dir = '/results/install'
        settings.override_value(scheduler_config.CONFIG_SECTION,
                                'results_host_installation_directory',
                                results_install_dir)

        (drones.get_drone.expect_call(self.mock_drone.name)
         .and_return(self.mock_drone))

        results_drone = MockDrone('results_drone')
        self.god.stub_function(results_drone, 'set_autotest_install_dir')
        drones.get_drone.expect_call(results_hostname).and_return(results_drone)
        results_drone.set_autotest_install_dir.expect_call(results_install_dir)

        self.manager.initialize(base_results_dir=self._RESULTS_DIR,
                                drone_hostnames=[self.mock_drone.name],
                                results_repository_hostname=results_hostname)

        self.assert_(self.mock_drone.was_call_queued(
            'initialize', self._DRONE_RESULTS_DIR + '/'))
        self.god.check_playback()
Exemple #13
0
 def test_get_autotest_server_none(self):
     settings.override_value('SERVER', 'hostname', 'Prince')
     self.assertEqual('http://Prince', rpc.get_autotest_server(None))
Exemple #14
0
 def _set_check_dark_mark(value):
     settings.override_value('SCHEDULER', 'check_processes_for_dark_mark',
                             repr(value))
#!/usr/bin/python

try:
    import autotest.common as common  # pylint: disable=W0611
except ImportError:
    import common  # pylint: disable=W0611
import unittest

# This has to be done very early.
from autotest.client.shared.settings import settings

settings.override_value("HOSTS", "default_protection", "NO_PROTECTION")

from autotest.frontend import setup_django_environment  # pylint: disable=W0611
from autotest.frontend import setup_test_environment  # pylint: disable=W0611
from autotest.frontend.shared import resource_test_utils
from autotest.frontend.afe import control_file, models, model_attributes


class AfeResourceTestCase(resource_test_utils.ResourceTestCase):
    URI_PREFIX = "http://testserver/afe/server/resources"

    CONTROL_FILE_CONTENTS = "my control file contents"

    def setUp(self):
        super(AfeResourceTestCase, self).setUp()
        self._add_additional_data()

    def _add_additional_data(self):
        models.Test.objects.create(name="mytest", test_type=model_attributes.TestTypes.SERVER, path="/path/to/mytest")
 def test_decompose_gitweb(self):
     settings.override_value('CLIENT', 'kernel_gitweb', gw)
     settings.override_value('CLIENT', 'stable_kernel_gitweb', sgw)
     correct = [[km + 'v3.x/linux-3.0.tar.bz2', km + 'v3.x/linux-3.0.tar.xz', gw + ';a=snapshot;h=refs/tags/v3.0;sf=tgz']]
     sample = decompose_kernel('3.0')
     self.assertEqual(sample, correct)
Exemple #17
0
 def setUp(self):
     self.god = mock.mock_god(ut=self)
     settings.override_value('CLIENT', 'kernel_mirror', km)
     settings.override_value('CLIENT', 'kernel_gitweb', '')
     settings.override_value('CLIENT', 'stable_kernel_gitweb', '')
 def test_decompose_sha1(self):
     settings.override_value('CLIENT', 'kernel_gitweb', gw)
     settings.override_value('CLIENT', 'stable_kernel_gitweb', sgw)
     correct = [[gw + ';a=snapshot;h=02f8c6aee8df3cdc935e9bdd4f2d020306035dbe;sf=tgz', sgw + ';a=snapshot;h=02f8c6aee8df3cdc935e9bdd4f2d020306035dbe;sf=tgz']]
     sample = decompose_kernel('02f8c6aee8df3cdc935e9bdd4f2d020306035dbe')
     self.assertEqual(sample, correct)
 def test_get_autotest_server_none(self):
     settings.override_value('SERVER', 'hostname', 'Prince')
     self.assertEqual('http://Prince', rpc.get_autotest_server(None))
 def test_check_parameterized_jobs_enabled(self):
     settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'True')
     self.assertRaises(Exception, models.Job.check_parameterized_job,
                       control_file=object(), parameterized_job=None)
 def _set_check_dark_mark(value):
     settings.override_value("SCHEDULER", "check_processes_for_dark_mark", repr(value))
Exemple #22
0
#!/usr/bin/python

try:
    import autotest.common as common
except ImportError:
    import common
import unittest

# This has to be done very early.
from autotest.client.shared.settings import settings
settings.override_value('HOSTS', 'default_protection', 'NO_PROTECTION')

from autotest.frontend import setup_django_environment
from autotest.frontend import setup_test_environment
from autotest.frontend.shared import resource_test_utils
from autotest.frontend.afe import control_file, models, model_attributes


class AfeResourceTestCase(resource_test_utils.ResourceTestCase):
    URI_PREFIX = 'http://testserver/afe/server/resources'

    CONTROL_FILE_CONTENTS = 'my control file contents'

    def setUp(self):
        super(AfeResourceTestCase, self).setUp()
        self._add_additional_data()

    def _add_additional_data(self):
        models.Test.objects.create(name='mytest',
                                   test_type=model_attributes.TestTypes.SERVER,
                                   path='/path/to/mytest')
 def test_check_parameterized_jobs_enabled(self):
     settings.override_value('AUTOTEST_WEB', 'parameterized_jobs', 'True')
     self.assertRaises(Exception, models.Job.check_parameterized_job,
                       control_file=object(), parameterized_job=None)
#!/usr/bin/python

try:
    import autotest.common as common
except ImportError:
    import common
import unittest

# This has to be done very early.
from autotest.client.shared.settings import settings
settings.override_value('HOSTS', 'default_protection', 'NO_PROTECTION')

from autotest.frontend import setup_django_environment
from autotest.frontend import setup_test_environment
from autotest.frontend.shared import resource_test_utils
from autotest.frontend.afe import control_file, models, model_attributes


class AfeResourceTestCase(resource_test_utils.ResourceTestCase):
    URI_PREFIX = 'http://testserver/afe/server/resources'

    CONTROL_FILE_CONTENTS = 'my control file contents'

    def setUp(self):
        super(AfeResourceTestCase, self).setUp()
        self._add_additional_data()

    def _add_additional_data(self):
        models.Test.objects.create(name='mytest',
                                   test_type=model_attributes.TestTypes.SERVER,
                                   path='/path/to/mytest')
 def _set_check_dark_mark(value):
     settings.override_value('SCHEDULER', 'check_processes_for_dark_mark',
                             repr(value))