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 setUp(self): self.god = mock.mock_god() setup_test_environment.set_up() self._patch_sqlite_stuff() setup_test_view() self._create_initial_data()
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()
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() 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.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")
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.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.god = mock.mock_god(ut=self) def utils_run(*args, **kargs): return TestBridge.FakeCmd(*args, **kargs) self.god.stub_with(utils, 'run', utils_run)
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 _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 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")
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()
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()
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")
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 = io.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_memory, '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)
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() # 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')
def setUp(self): self.god = mock.mock_god() # stub out get_server_dir, settings.get_value self.god.stub_with(utils, "get_server_dir", lambda: "/unittest/server") self.god.stub_function(settings.settings, "get_value") # stub out the bootloader self.real_bootloader = bootloader.Bootloader bootloader.Bootloader = lambda arg: object()
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)
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_memory, '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)
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(ut=self) self.god.stub_with(utils, "run", utils_run) all_nodes = tempfile.NamedTemporaryFile(delete=False) all_nodes.write(all_nodes_contents) all_nodes.close() online_nodes = tempfile.NamedTemporaryFile(delete=False) online_nodes.write(online_nodes_contents) online_nodes.close() self.all_nodes_path = all_nodes.name self.online_nodes_path = online_nodes.name self.numa_node = utils_misc.NumaNode(-1, self.all_nodes_path, self.online_nodes_path)
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)
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, "grep") 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") self.god.stub_function(distro, "detect") 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() 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"
def setUp(self): self.god = mock.mock_god(ut=self) self.god.stub_with(utils, 'run', utils_run) all_nodes = tempfile.NamedTemporaryFile(delete=False) all_nodes.write(all_nodes_contents) all_nodes.close() online_nodes = tempfile.NamedTemporaryFile(delete=False) online_nodes.write(online_nodes_contents) online_nodes.close() self.all_nodes_path = all_nodes.name self.online_nodes_path = online_nodes.name self.numa_node = utils_misc.NumaNode(-1, self.all_nodes_path, self.online_nodes_path)
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)
def add_to_bootloader(self, base_args, args, bootloader_args, 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(path=image, title=tag, initrd=initrd, args=bootloader_args) # run and check kernel._add_kernel_to_bootloader(bootloader, base_args, tag, args, image, initrd) god.check_playback()
def setUp(self): # The normal iscsi with iscsi server should configure following # parameters. As this will need env support only test emulated # iscsi in local host. # self.iscsi_params = {"target": "", # "portal_ip": "", # "initiator": ""} self.iscsi_emulated_params = {"emulated_image": "/tmp/iscsitest", "target": "iqn.iscsitest", "image_size": "1024K"} self.god = mock.mock_god() self.god.stub_function(os_dep, "command") self.god.stub_function(utils, "system") self.god.stub_function(utils, "system_output") self.god.stub_function(os.path, "isfile")
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()
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(client_utils, "get_os_vendor") 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.settings, "get_value") self.god.stub_function(autotest_remote, "_server_system_wide_install") self.god.stub_function(autotest_remote, "_client_system_wide_install") self.god.stub_function(logging, "exception") self.god.stub_class(autotest_remote, "_Run") self.god.stub_class(autotest_remote, "log_collector")
def setUp(self): # Get rid of logging errors def dumm(*args, **kvargs): pass self.god = mock.mock_god(ut=self) self.god.stub_with(qemu_qtree.logging, 'error', dumm) info = qtree_header info = combine(info, dev_ide_disk, 1) info = combine(info, dev_usb_disk, 1) info = combine(info, dev_dummy_mmio, 1) info += "\n" self.no_disks = 2 self.qtree = qemu_qtree.QtreeContainer() self.qtree.parse_info_qtree(info) self.disks = qemu_qtree.QtreeDisksContainer(self.qtree.get_nodes())
def setUp(self): self.nfs_params = {"nfs_mount_dir": "/mnt/nfstest", "nfs_mount_options": "rw", "nfs_mount_src": "127.0.0.1:/mnt/nfssrc", "setup_local_nfs": "yes", "export_options": "rw,no_root_squash"} self.god = mock.mock_god() self.god.stub_function(os_dep, "command") self.god.stub_function(utils, "system") self.god.stub_function(utils, "system_output") self.god.stub_function(os.path, "isfile") self.god.stub_function(os, "makedirs") self.god.stub_function(utils_misc, "is_mounted") self.god.stub_function(utils_misc, "mount") self.god.stub_function(utils_misc, "umount") self.god.stub_function(service, "SpecificServiceManager") attr = getattr(nfs, "Exportfs") setattr(attr, "already_exported", False) mock_class = self.god.create_mock_class_obj(attr, "Exportfs") self.god.stub_with(nfs, "Exportfs", mock_class)
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_function(local_host.utils, 'run') self.tmpdir = autotemp.tempdir(unique_id='localhost_unittest')
def setUp(self): self.god = mock.mock_god() self.kernel = rpm_kernel.RPMKernel() self.god.stub_function(utils, "run") self.kernel.source_material = "source.rpm"
def setUp(self): self.god = mock.mock_god()
def setUp(self): self.god = mock.mock_god(ut=self) self.god.stub_function(base_utils, "open")
def setUp(self): self.god = mock.mock_god(ut=self) self.god.stub_function(base_utils.logging, 'warn') self.god.stub_function(base_utils.logging, 'debug') self.version = 1