def setUp(self):
     self.god = mock.mock_god()
     self.god.mock_up(rpc_client_lib, 'rpc_client_lib')
     self.god.stub_function(utils, 'send_email')
     self._saved_environ = dict(os.environ)
     if 'AUTOTEST_WEB' in os.environ:
         del os.environ['AUTOTEST_WEB']
 def setUp(self):
     self.drone_utility = drone_utility.DroneUtility()
     self._fake_command = '!faketest!'
     self._fake_proc_info = {'pid': 3, 'pgid': 4, 'ppid': 2,
                             'comm': self._fake_command, 'args': ''}
     self.god = mock.mock_god()
     self.god.stub_function(self.drone_utility, '_get_process_info')
    def setUp(self):
        self.god = mock.mock_god()

        setup_test_environment.set_up()
        self._patch_sqlite_stuff()
        setup_test_view()
        self._create_initial_data()
    def setUp(self):
        self.god = mock.mock_god()
        self.manager = self.god.create_mock_class(migrate.MigrationManager,
                                                  'manager')

        self.god.stub_function(self.manager, 'execute')
        self.god.stub_function(self.manager, 'get_db_name')
    def setUp(self):
        self.control = "control"
        self.args = ""
        self.resultdir = "results"
        self.uncollected = "results/uncollected_logs"
        self.label = "default"
        self.user = "******"
        self.machines = ('abcd1', 'abcd2', 'abcd3')

        # make god
        self.god = mock.mock_god()

        # stub out some common functions
        self.god.stub_function(os.path, 'exists')
        self.god.stub_function(os, 'mkdir')
        self.god.stub_function(os, 'access')
        self.god.stub_function(os, 'makedirs')
        self.god.stub_function(os.path, 'isdir')
        self.god.stub_function(os, 'chmod')
        self.god.stub_function(os, 'chdir')
        self.god.stub_function(os, 'remove')
        self.god.stub_function(pickle, 'dump')
        self.god.stub_function(server_job, 'get_site_job_data')
        self.god.stub_function(server_job, 'open')
        self.god.stub_function(utils, 'write_keyval')

        logging_manager.configure_logging(logging_config.TestingConfig())

        self.construct_server_job()
Example #6
0
 def _frontend_common_setup(self, fill_data=True):
     self.god = mock.mock_god(ut=self)
     setup_test_environment.set_up()
     global_config.global_config.override_config_value(
             'AUTOTEST_WEB', 'parameterized_jobs', 'False')
     if fill_data:
         self._fill_in_test_data()
Example #7
0
    def add_to_bootloader(self,
                          base_args,
                          args,
                          bootloader_args,
                          bootloader_root,
                          tag='image',
                          image='image',
                          initrd='initrd'):
        god = mock.mock_god()
        bootloader = god.create_mock_class(boottool.boottool, "boottool")

        # record
        bootloader.remove_kernel.expect_call(tag)
        bootloader.add_kernel.expect_call(image,
                                          tag,
                                          initrd=initrd,
                                          args='_dummy_',
                                          root=bootloader_root)

        for a in bootloader_args.split():
            bootloader.add_args.expect_call(kernel=tag, args=a)
        bootloader.remove_args.expect_call(kernel=tag, args='_dummy_')

        # run and check
        kernel._add_kernel_to_bootloader(bootloader, base_args, tag, args,
                                         image, initrd)
        god.check_playback()
Example #8
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_with(setup_job.setup_job, '_get_environ_autodir',
                        classmethod(lambda cls: '/adir'))
     self.job = self.job_class.__new__(self.job_class)
     self.job._job_directory = base_job_unittest.stub_job_directory
     self.job.args = []
Example #9
0
    def setUp(self):
        self.god = mock.mock_god()

        setup_test_environment.set_up()
        self._patch_sqlite_stuff()
        setup_test_view()
        self._create_initial_data()
 def setUp(self):
     self.god = mock.mock_god()
     self.kernel = deb_kernel.DEBKernel()
     self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
     self.host.bootloader = self.god.create_mock_class(
         bootloader.Bootloader, "bootloader")
     self.god.stub_function(utils, "run")
Example #11
0
    def testGetStatefulUpdateScript(self):
        """ Test that get_stateful_update_script look for stateful_update.

        Check get_stateful_update_script is trying hard to find
        stateful_update and assert if it can't.

        """
        update_url = ('http://172.22.50.205:8082/update/lumpy-chrome-perf/'
                      'R28-4444.0.0-b2996')
        script_loc = os.path.join(autoupdater.STATEFUL_UPDATE_PATH,
                                  autoupdater.STATEFUL_UPDATE_SCRIPT)
        self.god = mock.mock_god()
        self.god.stub_function(os.path, 'exists')
        host = self.mox.CreateMockAnything()
        updater = autoupdater.ChromiumOSUpdater(update_url, host=host)
        os.path.exists.expect_call(script_loc).and_return(False)
        host.path_exists('/usr/local/bin/stateful_update').AndReturn(False)

        self.mox.ReplayAll()
        # No existing files, no URL, we should assert.
        self.assertRaises(autoupdater.ChromiumOSError,
                          updater.get_stateful_update_script)
        self.mox.VerifyAll()

        # No existing files, but stateful URL, we will try.
        self.mox.ResetAll()
        os.path.exists.expect_call(script_loc).and_return(True)
        host.send_file(script_loc, '/tmp/stateful_update',
                       delete_dest=True).AndReturn(True)
        self.mox.ReplayAll()
        self.assertEqual(updater.get_stateful_update_script(),
                         '/tmp/stateful_update')
        self.mox.VerifyAll()
Example #12
0
 def setUp(self):
     self.god = mock.mock_god()
     self.kernel = deb_kernel.DEBKernel()
     self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
     self.host.bootloader = self.god.create_mock_class(
         bootloader.Bootloader, "bootloader")
     self.god.stub_function(utils, "run")
Example #13
0
 def _frontend_common_setup(self, fill_data=True):
     self.god = mock.mock_god(ut=self)
     setup_test_environment.set_up()
     global_config.global_config.override_config_value(
         'AUTOTEST_WEB', 'parameterized_jobs', 'False')
     if fill_data:
         self._fill_in_test_data()
Example #14
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.mock_up(rpc_client_lib, 'rpc_client_lib')
     self.god.stub_function(utils, 'send_email')
     self._saved_environ = dict(os.environ)
     if 'AUTOTEST_WEB' in os.environ:
         del os.environ['AUTOTEST_WEB']
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_with(setup_job.setup_job, '_get_environ_autodir',
                        classmethod(lambda cls: '/adir'))
     self.job = self.job_class.__new__(self.job_class)
     self.job._job_directory = base_job_unittest.stub_job_directory
     self.job.args = []
 def _frontend_common_setup(self, fill_data=True, setup_tables=True):
     self.god = mock.mock_god(ut=self)
     if setup_tables:
         setup_test_environment.set_up()
     global_config.global_config.override_config_value(
             'SERVER', 'rpc_logging', 'False')
     if fill_data and setup_tables:
         self._fill_in_test_data()
Example #17
0
 def setUp(self):
     self.god = mock.mock_god()
     # stub out get_server_dir, global_config.get_config_value
     self.god.stub_with(utils, "get_server_dir", lambda: "/unittest/server")
     self.god.stub_function(global_config.global_config, "get_config_value")
     # stub out the bootloader
     self.real_bootloader = bootloader.Bootloader
     bootloader.Bootloader = lambda arg: object()
    def setUp(self):
        self.god = mock.mock_god(ut=self)
        self.god.stub_with(job.base_client_job, '_get_environ_autodir',
                           classmethod(lambda cls: '/adir'))
        self.job = self.job_class.__new__(self.job_class)
        self.job._job_directory = base_job_unittest.stub_job_directory

        _, self.control_file = tempfile.mkstemp()
Example #19
0
 def setUp(self):
     self.god = mock.mock_god()
     self.db_mock = self.god.create_mock_class(
         source.database.database, 'database')
     self.god.stub_function(source.urllib2, 'urlopen')
     self.addinfourl_mock = self.god.create_mock_class(
         source.urllib2.addinfourl, 'addinfourl')
     self.mime_mock = self.god.create_mock_class(
         httplib.HTTPMessage, 'HTTPMessage')
 def setUp(self):
     self.god = mock.mock_god()
     self._mock_host = self.god.create_mock_class(ssh_host.SSHHost,
                                                  'mock SSHHost')
     self.god.stub_function(drones.drone_utility, 'create_host')
     self.drone_utility_path = 'mock-drone-utility-path'
     self.mock_return = {'results': ['mock results'], 'warnings': []}
     self.god.stub_with(drones._RemoteDrone, '_drone_utility_path',
                        self.drone_utility_path)
Example #21
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(time, "time")
     self.god.stub_function(utils, "system")
     self.god.stub_function(kernel, "_add_kernel_to_bootloader")
     job_ = self.god.create_mock_class(job.job, "job")
     self.kernel = kernel.BootableKernel(job_)
     self.kernel.job.bootloader = self.god.create_mock_class(
         boottool.boottool, "boottool")
Example #22
0
    def setUp(self):
        self.god = mock.mock_god()
        self.db_mock = self.god.create_mock_class(
                source.database.database, 'database')

        # Set fixed timezone so parsing time values does not break.
        self._old_tz = getattr(os.environ, 'TZ', '')
        os.environ['TZ'] = 'America/Los_Angeles'
        time.tzset()
Example #23
0
    def setUp(self):
        self.god = mock.mock_god()
        self.db_mock = self.god.create_mock_class(
                source.database.database, 'database')

        # Set fixed timezone so parsing time values does not break.
        self._old_tz = getattr(os.environ, 'TZ', '')
        os.environ['TZ'] = 'America/Los_Angeles'
        time.tzset()
Example #24
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(time, "time")
     self.god.stub_function(utils, "system")
     self.god.stub_function(kernel, "_add_kernel_to_bootloader")
     job_ = self.god.create_mock_class(job.job, "job")
     self.kernel = kernel.BootableKernel(job_)
     self.kernel.job.bootloader = self.god.create_mock_class(
                           boottool.boottool, "boottool")
Example #25
0
    def setUp(self):
        # make god
        self.god = mock.mock_god(ut=self)

        # need to set some environ variables
        self.autodir = "autodir"
        os.environ['AUTODIR'] = self.autodir

        # set up some variables
        self.control = "control"
        self.jobtag = "jobtag"

        # get rid of stdout and logging
        sys.stdout = StringIO.StringIO()
        logging_manager.configure_logging(logging_config.TestingConfig())
        logging.disable(logging.CRITICAL)

        def dummy_configure_logging(*args, **kwargs):
            pass

        self.god.stub_with(logging_manager, 'configure_logging',
                           dummy_configure_logging)
        real_get_logging_manager = logging_manager.get_logging_manager

        def get_logging_manager_no_fds(manage_stdout_and_stderr=False,
                                       redirect_fds=False):
            return real_get_logging_manager(manage_stdout_and_stderr, False)

        self.god.stub_with(logging_manager, 'get_logging_manager',
                           get_logging_manager_no_fds)

        # stub out some stuff
        self.god.stub_function(os.path, 'exists')
        self.god.stub_function(os.path, 'isdir')
        self.god.stub_function(os, 'makedirs')
        self.god.stub_function(os, 'mkdir')
        self.god.stub_function(os, 'remove')
        self.god.stub_function(shutil, 'rmtree')
        self.god.stub_function(shutil, 'copyfile')
        self.god.stub_function(job, 'open')
        self.god.stub_function(utils, 'system')
        self.god.stub_function(utils, 'drop_caches')
        self.god.stub_function(harness, 'select')
        self.god.stub_function(sysinfo, 'log_per_reboot_data')

        self.god.stub_class(config, 'config')
        self.god.stub_class(job.local_host, 'LocalHost')
        self.god.stub_class(boottool, 'boottool')
        self.god.stub_class(sysinfo, 'sysinfo')

        self.god.stub_class_method(job.base_client_job,
                                   '_cleanup_debugdir_files')
        self.god.stub_class_method(job.base_client_job, '_cleanup_results_dir')

        self.god.stub_with(job.base_job.job_directory, '_ensure_valid',
                           lambda *_: None)
Example #26
0
    def setUp(self):
        super(cli_unittest, self).setUp()
        self.god = mock.mock_god(debug=CLI_UT_DEBUG, ut=self)
        self.god.stub_class_method(rpc.afe_comm, 'run')
        self.god.stub_function(sys, 'exit')

        def stub_authorization_headers(*args, **kwargs):
            return {}
        self.god.stub_with(rpc_client_lib, 'authorization_headers',
                           stub_authorization_headers)
Example #27
0
 def setUp(self):
     self.god = mock.mock_god()
     # stub out get_server_dir, global_config.get_config_value
     self.god.stub_with(utils, "get_server_dir",
                        lambda: "/unittest/server")
     self.god.stub_function(global_config.global_config,
                            "get_config_value")
     # stub out the bootloader
     self.real_bootloader = bootloader.Bootloader
     bootloader.Bootloader = lambda arg: object()
Example #28
0
 def setUp(self):
     self.god = mock.mock_god()
     # creates a bootloader with _run_boottool mocked out
     self.bt_mock = boottool.boottool()
     self.god.stub_function(self.bt_mock, '_run_grubby_get_return')
     self.god.stub_function(self.bt_mock, '_run_grubby_get_output')
     self.god.stub_function(self.bt_mock, '_run_get_output_err')
     self.god.stub_function(self.bt_mock, '_get_entry_selection')
     self.god.stub_function(self.bt_mock, 'get_info')
     self.god.stub_function(self.bt_mock, 'get_info_lines')
Example #29
0
    def setUp(self):
        super(cli_unittest, self).setUp()
        self.god = mock.mock_god(debug=CLI_UT_DEBUG, ut=self)
        self.god.stub_class_method(rpc.afe_comm, 'run')
        self.god.stub_function(sys, 'exit')

        def stub_authorization_headers(*args, **kwargs):
            return {}
        self.god.stub_with(rpc_client_lib, 'authorization_headers',
                           stub_authorization_headers)
    def setUp(self):
        self.god = mock.mock_god()
        self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
        self.god.stub_class(source_kernel.autotest_remote, "Autotest")
        self.kernel_autotest = source_kernel.autotest_remote.Autotest.expect_new()
        self.k = "kernel"
        self.source_kernel = source_kernel.SourceKernel(self.k)

        # call configure to set config_file
        self.config = "config_file"
        self.source_kernel.configure(self.config)
Example #31
0
    def setUp(self):
        self.god = mock.mock_god()

        self.god.stub_function(database.cPickle, "load")
        self.god.stub_function(database.cPickle, "dump")
        self.god.stub_function(database.tempfile, "mkstemp")
        self.god.stub_function(database.os, "fdopen")
        self.god.stub_function(database.os, "close")
        self.god.stub_function(database.os, "rename")
        self.god.stub_function(database.os, "unlink")
        self._open_mock = self.god.create_mock_function("open")
        self._file_instance = self.god.create_mock_class(file, "file")
 def setUp(self):
     self.drone_utility = drone_utility.DroneUtility()
     self._fake_command = '!faketest!'
     self._fake_proc_info = {
         'pid': 3,
         'pgid': 4,
         'ppid': 2,
         'comm': self._fake_command,
         'args': ''
     }
     self.god = mock.mock_god()
     self.god.stub_function(self.drone_utility, '_get_process_info')
Example #33
0
    def setUp(self):
        self.god = mock.mock_god()

        self.god.stub_function(database.cPickle, 'load')
        self.god.stub_function(database.cPickle, 'dump')
        self.god.stub_function(database.tempfile, 'mkstemp')
        self.god.stub_function(database.os, 'fdopen')
        self.god.stub_function(database.os, 'close')
        self.god.stub_function(database.os, 'rename')
        self.god.stub_function(database.os, 'unlink')
        self._open_mock = self.god.create_mock_function('open')
        self._file_instance = self.god.create_mock_class(file, 'file')
    def setUp(self):
        self.god = mock.mock_god()
        self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
        self.god.stub_class(source_kernel.autotest_remote, "Autotest")
        self.kernel_autotest = source_kernel.autotest_remote.Autotest.expect_new(
        )
        self.k = "kernel"
        self.source_kernel = source_kernel.SourceKernel(self.k)

        # call configure to set config_file
        self.config = "config_file"
        self.source_kernel.configure(self.config)
Example #35
0
    def setUp(self):
        self.god = mock.mock_god()

        self.god.stub_function(database.cPickle, 'load')
        self.god.stub_function(database.cPickle, 'dump')
        self.god.stub_function(database.tempfile, 'mkstemp')
        self.god.stub_function(database.os, 'fdopen')
        self.god.stub_function(database.os, 'close')
        self.god.stub_function(database.os, 'rename')
        self.god.stub_function(database.os, 'unlink')
        self._open_mock = self.god.create_mock_function('open')
        self._file_instance = self.god.create_mock_class(file, 'file')
Example #36
0
    def setUp(self):
        # make god
        self.god = mock.mock_god(ut=self)

        # need to set some environ variables
        self.autodir = "autodir"
        os.environ['AUTODIR'] = self.autodir

        # set up some variables
        self.control = "control"
        self.jobtag = "jobtag"

        # get rid of stdout and logging
        sys.stdout = StringIO.StringIO()
        logging_manager.configure_logging(logging_config.TestingConfig())
        logging.disable(logging.CRITICAL)
        def dummy_configure_logging(*args, **kwargs):
            pass
        self.god.stub_with(logging_manager, 'configure_logging',
                           dummy_configure_logging)
        real_get_logging_manager = logging_manager.get_logging_manager
        def get_logging_manager_no_fds(manage_stdout_and_stderr=False,
                                       redirect_fds=False):
            return real_get_logging_manager(manage_stdout_and_stderr, False)
        self.god.stub_with(logging_manager, 'get_logging_manager',
                           get_logging_manager_no_fds)

        # stub out some stuff
        self.god.stub_function(os.path, 'exists')
        self.god.stub_function(os.path, 'isdir')
        self.god.stub_function(os, 'makedirs')
        self.god.stub_function(os, 'mkdir')
        self.god.stub_function(os, 'remove')
        self.god.stub_function(shutil, 'rmtree')
        self.god.stub_function(shutil, 'copyfile')
        self.god.stub_function(job, 'open')
        self.god.stub_function(utils, 'system')
        self.god.stub_function(utils, 'drop_caches')
        self.god.stub_function(harness, 'select')
        self.god.stub_function(sysinfo, 'log_per_reboot_data')

        self.god.stub_class(config, 'config')
        self.god.stub_class(job.local_host, 'LocalHost')
        self.god.stub_class(boottool, 'boottool')
        self.god.stub_class(sysinfo, 'sysinfo')

        self.god.stub_class_method(job.base_client_job,
                                   '_cleanup_debugdir_files')
        self.god.stub_class_method(job.base_client_job, '_cleanup_results_dir')

        self.god.stub_with(job.base_job.job_directory, '_ensure_valid',
                           lambda *_: None)
Example #37
0
    def setUp(self):
        self.god = mock.mock_god()
        self.god.stub_function(utils, "system")
        self.god.stub_function(utils, "system_output")
        self.god.stub_function(utils, "module_is_loaded")
        self.god.stub_function(net_utils, "open")
        self.god.stub_function(time, 'sleep')

        self.god.stub_with(net_utils, "bond", net_utils.bonding)
        self.god.stub_with(os, 'open', net_utils_mock.os_open)
        self.god.stub_with(net_utils, 'netif', net_utils_mock.netutils_netif)

        os.environ['AUTODIR'] = "autodir"
Example #38
0
    def setUp(self):
        """Setup mocks for rpc calls and system exit.
        """
        super(cli_unittest, self).setUp()
        self.god = mock.mock_god(debug=CLI_UT_DEBUG, ut=self)
        self.god.stub_class_method(rpc.afe_comm, 'run')
        self.god.stub_function(sys, 'exit')

        def stub_authorization_headers(*args, **kwargs):
            """No auth headers required for testing."""
            return {}
        self.god.stub_with(rpc_client_lib, 'authorization_headers',
                           stub_authorization_headers)
Example #39
0
    def setUp(self):
        self.god = mock.mock_god()

        self.god.stub_function(os, "getpid")
        self.god.stub_function(os.path, "isdir")
        self.god.stub_function(os, "chdir")
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(os, "makedirs")
        self.god.stub_function(os, "remove")
        self.god.stub_function(utils, "system")

        self.prefix = "prefix"
        self.target = "target"
Example #40
0
    def setUp(self):
        # make god
        self.god = mock.mock_god(ut=self)

        # need to set some environ variables
        self.autodir = "autodir"
        os.environ["AUTODIR"] = self.autodir

        # set up some variables
        self.control = "control"
        self.jobtag = "jobtag"

        # get rid of stdout and logging
        sys.stdout = StringIO.StringIO()
        logging_manager.configure_logging(logging_config.TestingConfig())
        logging.disable(logging.CRITICAL)

        def dummy_configure_logging(*args, **kwargs):
            pass

        self.god.stub_with(logging_manager, "configure_logging", dummy_configure_logging)
        real_get_logging_manager = logging_manager.get_logging_manager

        def get_logging_manager_no_fds(manage_stdout_and_stderr=False, redirect_fds=False):
            return real_get_logging_manager(manage_stdout_and_stderr, False)

        self.god.stub_with(logging_manager, "get_logging_manager", get_logging_manager_no_fds)

        # stub out some stuff
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(os.path, "isdir")
        self.god.stub_function(os, "makedirs")
        self.god.stub_function(os, "mkdir")
        self.god.stub_function(os, "remove")
        self.god.stub_function(shutil, "rmtree")
        self.god.stub_function(shutil, "copyfile")
        self.god.stub_function(job, "open")
        self.god.stub_function(utils, "system")
        self.god.stub_function(utils, "drop_caches")
        self.god.stub_function(harness, "select")
        self.god.stub_function(sysinfo, "log_per_reboot_data")

        self.god.stub_class(config, "config")
        self.god.stub_class(job.local_host, "LocalHost")
        self.god.stub_class(boottool, "boottool")
        self.god.stub_class(sysinfo, "sysinfo")

        self.god.stub_class_method(job.base_client_job, "_cleanup_debugdir_files")
        self.god.stub_class_method(job.base_client_job, "_cleanup_results_dir")

        self.god.stub_with(job.base_job.job_directory, "_ensure_valid", lambda *_: None)
Example #41
0
 def test_get_wireless_ssid(self):
     """Test is_in_same_subnet function."""
     god = mock.mock_god()
     god.stub_function_to_return(utils.CONFIG, 'get_config_value',
                                 self.DEFAULT_SSID)
     god.stub_function_to_return(
         utils.CONFIG, 'get_config_value_regex', {
             'wireless_ssid_1.2.3.4/24': self.SSID_1,
             'wireless_ssid_4.3.2.1/16': self.SSID_2
         })
     self.assertEqual(self.SSID_1, utils.get_wireless_ssid('1.2.3.100'))
     self.assertEqual(self.SSID_2, utils.get_wireless_ssid('4.3.2.100'))
     self.assertEqual(self.DEFAULT_SSID,
                      utils.get_wireless_ssid('100.0.0.100'))
Example #42
0
    def setUp(self):
        self.god = mock.mock_god()

        logging.disable(logging.CRITICAL)

        self.god.stub_function(time, "time")
        self.god.stub_function(os, "mkdir")
        self.god.stub_function(os, "chdir")
        self.god.stub_function(os, "symlink")
        self.god.stub_function(os, "remove")
        self.god.stub_function(os.path, "isdir")
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(os.path, "isfile")
        self.god.stub_function(os_dep, "commands")
        self.god.stub_function(kernel, "open")
        self.god.stub_function(utils, "system")
        self.god.stub_function(utils, "system_output")
        self.god.stub_function(utils, "get_file")
        self.god.stub_function(utils, "get_current_kernel_arch")
        self.god.stub_function(utils, "cat_file_to_cmd")
        self.god.stub_function(utils, "force_copy")
        self.god.stub_function(utils, "extract_tarball_to_dir")
        self.god.stub_function(utils, "count_cpus")
        self.god.stub_function(utils, "get_os_vendor")
        self.god.stub_function(kernelexpand, "expand_classic")
        self.god.stub_function(kernel_config, "modules_needed")
        self.god.stub_function(glob, "glob")

        def dummy_mark(filename, msg):
            pass

        self.god.stub_with(kernel, '_mark', dummy_mark)

        self.job = self.god.create_mock_class(job.job, "job")
        self.job.bootloader = self.god.create_mock_class(
            boottool.boottool, "boottool")

        class DummyLoggingManager(object):
            def tee_redirect_debug_dir(self, *args, **kwargs):
                pass

            def restore(self, *args, **kwargs):
                pass

        self.job.logging = DummyLoggingManager()

        self.job.autodir = "autodir"
        self.base_tree = "2.6.24"
        self.tmp_dir = "tmpdir"
        self.subdir = "subdir"
Example #43
0
    def setUp(self):
        self.god = mock.mock_god()

        logging.disable(logging.CRITICAL)

        self.god.stub_function(time, "time")
        self.god.stub_function(os, "mkdir")
        self.god.stub_function(os, "chdir")
        self.god.stub_function(os, "symlink")
        self.god.stub_function(os, "remove")
        self.god.stub_function(os.path, "isdir")
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(os.path, "isfile")
        self.god.stub_function(os_dep, "commands")
        self.god.stub_function(kernel, "open")
        self.god.stub_function(utils, "system")
        self.god.stub_function(utils, "system_output")
        self.god.stub_function(utils, "get_file")
        self.god.stub_function(utils, "get_current_kernel_arch")
        self.god.stub_function(utils, "cat_file_to_cmd")
        self.god.stub_function(utils, "force_copy")
        self.god.stub_function(utils, "extract_tarball_to_dir")
        self.god.stub_function(utils, "count_cpus")
        self.god.stub_function(utils, "get_os_vendor")
        self.god.stub_function(kernelexpand, "expand_classic")
        self.god.stub_function(kernel_config, "modules_needed")
        self.god.stub_function(glob, "glob")
        def dummy_mark(filename, msg):
            pass
        self.god.stub_with(kernel, '_mark', dummy_mark)

        self.job = self.god.create_mock_class(job.job, "job")
        self.job.bootloader = self.god.create_mock_class(boottool.boottool,
                                                         "boottool")

        class DummyLoggingManager(object):
            def tee_redirect_debug_dir(self, *args, **kwargs):
                pass


            def restore(self, *args, **kwargs):
                pass

        self.job.logging = DummyLoggingManager()

        self.job.autodir = "autodir"
        self.base_tree = "2.6.24"
        self.tmp_dir = "tmpdir"
        self.subdir = "subdir"
    def setUp(self):
        self.god = mock.mock_god(ut=self)
        self.god.stub_function(utils.logging, 'warning')
        self.god.stub_function(utils.logging, 'debug')

        # Log level -> StringIO.StringIO.
        self.logs = {}
        for level in self.LOG_LEVELS:
            self.logs[level] = StringIO.StringIO()

        # Override logging_manager.LoggingFile to return buffers.
        def logging_file(level=None, prefix=None):
            return self.logs[level]

        self.god.stub_with(utils.logging_manager, 'LoggingFile', logging_file)
 def setUp(self):
     self._tempdir = autotemp.tempdir(unique_id='test_process_refresher')
     self.addCleanup(self._tempdir.clean)
     self._fake_command = '!faketest!'
     self._fake_proc_info = {
         'pid': 3,
         'pgid': 4,
         'ppid': 2,
         'comm': self._fake_command,
         'args': ''
     }
     self.god = mock.mock_god()
     self.god.stub_function(drone_utility, '_get_process_info')
     self._mock_get_process_info = drone_utility._get_process_info
     self.god.stub_function(drone_utility, '_process_has_dark_mark')
     self._mock_process_has_dark_mark = (
         drone_utility._process_has_dark_mark)
    def setUp(self):
        self.god = mock.mock_god()
        self.mock_drone_manager = self.god.create_mock_class(
            drone_manager.DroneManager, 'drone_manager')
        self.god.stub_with(drone_manager, '_the_instance',
                           self.mock_drone_manager)
        self.god.stub_with(pidfile_monitor, '_get_pidfile_timeout_secs',
                           self._mock_get_pidfile_timeout_secs)

        self.pidfile_id = object()

        (self.mock_drone_manager.get_pidfile_id_from.expect_call(
            self.execution_tag,
            pidfile_name=drone_manager.AUTOSERV_PID_FILE).and_return(
                self.pidfile_id))

        self.monitor = pidfile_monitor.PidfileRunMonitor()
        self.monitor.attach_to_existing_process(self.execution_tag)
    def setUp(self):
        # create god
        self.god = mock.mock_god()

        # create mock host object
        self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
        self.host.hostname = "hostname"
        self.host.job = self.god.create_mock_class(server_job.server_job,
                                                   "job")
        self.host.job.run_test_cleanup = True
        self.host.job.last_boot_tag = 'Autotest'
        self.host.job.sysinfo = self.god.create_mock_class(
            sysinfo.sysinfo, "sysinfo")
        self.host.job.profilers = self.god.create_mock_class(
            profilers.profilers, "profilers")
        self.host.job.profilers.add_log = {}
        self.host.job.tmpdir = "/job/tmp"
        self.host.job.default_profile_only = False
        self.host.job.args = []
        self.host.job.record = lambda *args: None

        # stubs
        self.god.stub_function(utils, "get_server_dir")
        self.god.stub_function(utils, "run")
        self.god.stub_function(utils, "get")
        self.god.stub_function(utils, "read_keyval")
        self.god.stub_function(utils, "write_keyval")
        self.god.stub_function(utils, "system")
        self.god.stub_function(tempfile, "mkstemp")
        self.god.stub_function(tempfile, "mktemp")
        self.god.stub_function(os, "getcwd")
        self.god.stub_function(os, "system")
        self.god.stub_function(os, "chdir")
        self.god.stub_function(os, "makedirs")
        self.god.stub_function(os, "remove")
        self.god.stub_function(os, "fdopen")
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(autotest_remote, "open")
        self.god.stub_function(autotest_remote.global_config.global_config,
                               "get_config_value")
        self.god.stub_function(logging, "exception")
        self.god.stub_class(autotest_remote, "_Run")
        self.god.stub_class(autotest_remote, "log_collector")
Example #48
0
    def add_to_bootloader(self, base_args, args, bootloader_args,
                          bootloader_root, tag='image', image='image',
                          initrd='initrd'):
        god = mock.mock_god()
        bootloader = god.create_mock_class(boottool.boottool, "boottool")

        # record
        bootloader.remove_kernel.expect_call(tag)
        bootloader.add_kernel.expect_call(image, tag, initrd=initrd,
                                          args='_dummy_', root=bootloader_root)

        for a in bootloader_args.split():
            bootloader.add_args.expect_call(kernel=tag, args=a)
        bootloader.remove_args.expect_call(kernel=tag, args='_dummy_')

        # run and check
        kernel._add_kernel_to_bootloader(bootloader, base_args, tag, args,
                                         image, initrd)
        god.check_playback()
Example #49
0
    def setUp(self):
        # create god
        self.god = mock.mock_god()

        # create mock host object
        self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
        self.host.hostname = "hostname"
        self.host.job = self.god.create_mock_class(server_job.server_job,
                                                   "job")
        self.host.job.run_test_cleanup = True
        self.host.job.last_boot_tag = 'Autotest'
        self.host.job.sysinfo = self.god.create_mock_class(
            sysinfo.sysinfo, "sysinfo")
        self.host.job.profilers = self.god.create_mock_class(
            profilers.profilers, "profilers")
        self.host.job.profilers.add_log = {}
        self.host.job.tmpdir = "/job/tmp"
        self.host.job.default_profile_only = False
        self.host.job.args = []
        self.host.job.record = lambda *args: None

        # stubs
        self.god.stub_function(utils, "get_server_dir")
        self.god.stub_function(utils, "run")
        self.god.stub_function(utils, "get")
        self.god.stub_function(utils, "read_keyval")
        self.god.stub_function(utils, "write_keyval")
        self.god.stub_function(utils, "system")
        self.god.stub_function(tempfile, "mkstemp")
        self.god.stub_function(tempfile, "mktemp")
        self.god.stub_function(os, "getcwd")
        self.god.stub_function(os, "system")
        self.god.stub_function(os, "chdir")
        self.god.stub_function(os, "makedirs")
        self.god.stub_function(os, "remove")
        self.god.stub_function(os, "fdopen")
        self.god.stub_function(os.path, "exists")
        self.god.stub_function(autotest, "open")
        self.god.stub_function(autotest.global_config.global_config,
                               "get_config_value")
        self.god.stub_function(logging, "exception")
        self.god.stub_class(autotest, "_Run")
        self.god.stub_class(autotest, "log_collector")
Example #50
0
    def setUp(self):
        self.god = mock.mock_god()
        self.god.stub_with(drones, 'AUTOTEST_INSTALL_DIR',
                           self._DRONE_INSTALL_DIR)
        self.manager = drone_manager.DroneManager()
        self.god.stub_with(self.manager, '_results_dir', self._RESULTS_DIR)

        # we don't want this to ever actually get called
        self.god.stub_function(drones, 'get_drone')

        # we don't want the DroneManager to go messing with global config
        def do_nothing():
            pass

        self.god.stub_with(self.manager, 'refresh_drone_configs', do_nothing)

        self.results_drone = MockDrone('results_drone', 0, 10)
        self.manager._results_drone = self.results_drone
        self.drone_utility_path = 'mock-drone-utility-path'
        self.mock_return = {'results': ['mock results'], 'warnings': []}
Example #51
0
    def setUp(self):
        self.god = mock.mock_god()
        self.god.stub_with(drones, 'AUTOTEST_INSTALL_DIR',
                           self._DRONE_INSTALL_DIR)
        self.manager = drone_manager.DroneManager()
        self.god.stub_with(self.manager, '_results_dir', self._RESULTS_DIR)

        # we don't want this to ever actually get called
        self.god.stub_function(drones, 'get_drone')
        # we don't want the DroneManager to go messing with global config
        def do_nothing():
            pass
        self.god.stub_with(self.manager, 'refresh_drone_configs', do_nothing)

        # set up some dummy drones
        self.mock_drone = MockDrone('mock_drone')
        self.manager._drones[self.mock_drone.name] = self.mock_drone
        self.results_drone = MockDrone('results_drone', 0, 10)
        self.manager._results_drone = self.results_drone

        self.mock_drone_process = drone_manager.Process(self.mock_drone.name, 0)
    def setUp(self):
        self.god = mock.mock_god()
        self.god.stub_with(drones, 'AUTOTEST_INSTALL_DIR',
                           self._DRONE_INSTALL_DIR)
        self.manager = drone_manager.DroneManager()
        self.god.stub_with(self.manager, '_results_dir', self._RESULTS_DIR)

        # we don't want this to ever actually get called
        self.god.stub_function(drones, 'get_drone')
        # we don't want the DroneManager to go messing with global config
        def do_nothing():
            pass
        self.god.stub_with(self.manager, 'refresh_drone_configs', do_nothing)

        # set up some dummy drones
        self.mock_drone = MockDrone('mock_drone')
        self.manager._drones[self.mock_drone.name] = self.mock_drone
        self.results_drone = MockDrone('results_drone', 0, 10)
        self.manager._results_drone = self.results_drone

        self.mock_drone_process = drone_manager.Process(self.mock_drone.name, 0)
Example #53
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.mock_io()
Example #54
0
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(models.job, 'read_keyval')
     self.god.stub_function(version_0.job, 'find_hostname')
     self.god.stub_function(models.test, 'parse_host_keyval')
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(utils, "open")
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(utils.logging, 'warn')
     self.god.stub_function(utils.logging, 'debug')
 def setUp(self):
     self.god = mock.mock_god()
     self.god.stub_function(utils, "open")
     self.god.stub_function(os.path, "isdir")
Example #58
0
 def setUp(self):
     self.god = mock.mock_god()
     self.tempdir = tempfile.mkdtemp()