def setUp(self): super(CopytoolTestCase, self).setUp() from chroma_agent.config_store import ConfigStore self.mock_config = ConfigStore(tempfile.mkdtemp()) patch("chroma_agent.copytool_monitor.config", self.mock_config).start() self.ct_id = "42" self.ct_bin_path = "/usr/sbin/lhsmtool_foo" self.ct_filesystem = "testfs" self.ct_mountpoint = "/mnt/testfs" self.ct_archive = 2 self.ct_index = 0 self.ct = Copytool( self.ct_id, self.ct_index, self.ct_bin_path, self.ct_archive, self.ct_filesystem, self.ct_mountpoint, "", ) self.addCleanup(patch.stopall)
def setUp(self): super(TestCopytoolManagement, self).setUp() from chroma_agent.config_store import ConfigStore self.mock_config = ConfigStore(tempfile.mkdtemp()) mock.patch('chroma_agent.action_plugins.manage_copytool.config', self.mock_config).start() mock.patch('chroma_agent.copytool_monitor.config', self.mock_config).start() mock.patch('chroma_agent.action_plugins.settings_management.config', self.mock_config).start() mock.patch('chroma_agent.action_plugins.manage_copytool._write_service_init').start() self.mock_os_remove = mock.MagicMock() mock.patch('os.remove', self.mock_os_remove).start() from chroma_agent.action_plugins.settings_management import reset_agent_config reset_agent_config() self.ct_id = '42' self.ct_index = 0 self.ct_archive = 1 self.ct_bin_path = '/usr/sbin/lhsmtool_foo' self.ct_arguments = '-p /archive/testfs' self.ct_filesystem = 'testfs' self.ct_mountpoint = '/mnt/testfs' self._configure_copytool() self.ct_vars = _copytool_vars(self.ct_id) self.addCleanup(mock.patch.stopall)
def setUp(self): super(AgentStoreConversionTests, self).setUp() self.env_path_patch = patch("chroma_agent.conf.ENV_PATH", new=tempfile.mkdtemp()) self.env_path = self.env_path_patch.start() self.config = ConfigStore(tempfile.mkdtemp())
def setUp(self): super(ConfigStoreTests, self).setUp() self.config = ConfigStore(tempfile.mkdtemp()) self.data = { 'foo': 1, 'bar': "1", 'baz': ['qux', 'quux', 'corge'], 'grault': { 'garply': "waldo", 'fred': ['plugh', 'xyzzy'] }, 'thud': False }
def setUp(self): super(ConfigStoreTests, self).setUp() self.config = ConfigStore(tempfile.mkdtemp()) self.data = { "foo": 1, "bar": "1", "baz": ["qux", "quux", "corge"], "grault": { "garply": "waldo", "fred": ["plugh", "xyzzy"] }, "thud": False, }
def setUp(self): super(ApiTestCaseWithTestReset, self).setUp() if config.get('simulator', False): # When we're running with the simulator, parts of the simulated # Copytools use agent code, and the agent code expects to find # a populated agent-side configuration. The safe way to handle # this requirement is to use mock to patch in a fresh # ConfigStore instance for each test run. try: from chroma_agent.config_store import ConfigStore except ImportError: raise ImportError( "Cannot import agent, do you need to do a 'setup.py develop' of it?" ) import mock # Mock is only available when running the simulator, hence local inclusion self.mock_config = ConfigStore(tempfile.mkdtemp()) mock.patch('chroma_agent.config', self.mock_config).start() from chroma_agent.action_plugins.settings_management import reset_agent_config, set_agent_config reset_agent_config() # Allow the worker to create a fifo in /tmp rather than /var/spool set_agent_config('copytool_fifo_directory', self.COPYTOOL_TESTING_FIFO_ROOT) try: from cluster_sim.simulator import ClusterSimulator except ImportError: raise ImportError( "Cannot import simulator, do you need to do a 'setup.py develop' of it?" ) # The simulator's state directory will be left behind when a test fails, # so make sure it has a unique-per-run name timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H%M%S") state_path = 'simulator_state_%s.%s_%s' % ( self.__class__.__name__, self._testMethodName, timestamp) if os.path.exists(state_path): raise RuntimeError( "Simulator state folder already exists at '%s'!" % state_path) # Hook up the agent log to a file from chroma_agent.agent_daemon import daemon_log handler = logging.FileHandler( os.path.join(config.get('log_dir', '/var/log/'), 'chroma_test_agent.log')) handler.setFormatter( logging.Formatter('[%(asctime)s] %(message)s', '%d/%b/%Y:%H:%M:%S')) daemon_log.addHandler(handler) daemon_log.setLevel(logging.DEBUG) self.simulator = ClusterSimulator( state_path, config['chroma_managers'][0]['server_http_url']) volume_count = max( [len(s['device_paths']) for s in self.config_servers]) self.simulator.setup(len(self.config_servers), len(self.config_workers), volume_count, self.SIMULATOR_NID_COUNT, self.SIMULATOR_CLUSTER_SIZE, len(config['power_distribution_units']), su_size=0) self.remote_operations = SimulatorRemoteOperations( self, self.simulator) if self.TESTS_NEED_POWER_CONTROL: self.simulator.power.start() else: self.remote_operations = RealRemoteOperations(self) if self.quick_setup is False: # Ensure that all servers are up and available for server in self.TEST_SERVERS: logger.info( "Checking that %s is running and restarting if necessary..." % server['fqdn']) self.remote_operations.await_server_boot(server['fqdn'], restart=True) logger.info("%s is running" % server['fqdn']) self.remote_operations.inject_log_message( server['fqdn'], "==== " "starting test %s " "=====" % self) if config.get('reset', True): self.reset_cluster() elif config.get('soft_reset', True): # Reset the manager via the API self.wait_until_true(self.api_contactable) self.remote_operations.unmount_clients() self.api_force_clear() self.remote_operations.clear_ha(self.TEST_SERVERS) self.remote_operations.clear_lnet_config(self.TEST_SERVERS) if config.get('managed'): # Ensure that config from previous runs doesn't linger into # this one. self.remote_operations.remove_config(self.TEST_SERVERS) # If there are no configuration options for a given server # (e.g. corosync_config), then this is a noop and no config file # is written. self.remote_operations.write_config(self.TEST_SERVERS) # cleanup linux devices self.cleanup_linux_devices(self.TEST_SERVERS) # cleanup zfs pools self.cleanup_zfs_pools( self.config_servers, self.CZP_EXPORTPOOLS | (self.CZP_RECREATEZPOOLS if config.get( 'new_zpools_each_test', False) else self.CZP_REMOVEDATASETS), None, True) # Enable agent debugging self.remote_operations.enable_agent_debug(self.TEST_SERVERS) self.wait_until_true(self.supervisor_controlled_processes_running) self.initial_supervisor_controlled_process_start_times = self.get_supervisor_controlled_process_start_times( )
def setUp(self): super(AgentStoreConversionTests, self).setUp() self.config = ConfigStore(tempfile.mkdtemp())