def test_success(self): stdout = MagicMock() containers = ['cond-0', 'cond-1'] with patch('conductr_cli.sandbox_common.resolve_running_docker_containers', return_value=containers), \ patch('conductr_cli.terminal.docker_rm') as mock_docker_rm: logging_setup.configure_logging(MagicMock(**self.default_args), stdout) sandbox_stop.stop(MagicMock(**self.default_args)) self.assertEqual('Stopping ConductR..\n', self.output(stdout)) mock_docker_rm.assert_called_once_with(containers)
def run(args, features): """ Starts the ConductR core and agent. :param args: args parsed from the input arguments :param features: list of features which are specified via -f switch. This is only relevant for Docker based sandbox since the features decides what port to expose :return: SandboxRunResult """ nr_of_core_instances, nr_of_agent_instances = instance_count( args.image_version, args.nr_of_instances) validate_jvm_support() validate_64bit_support() sandbox_stop.stop(args) log = logging.getLogger(__name__) log.info(headline('Starting ConductR')) bind_addrs = find_bind_addrs( max(nr_of_core_instances, nr_of_agent_instances), args.addr_range) core_extracted_dir, agent_extracted_dir = obtain_sandbox_image( args.image_dir, args.image_version, args.offline_mode) core_addrs = bind_addrs[0:nr_of_core_instances] core_pids = start_core_instances(core_extracted_dir, core_addrs, args.conductr_roles, features, args.log_level) agent_addrs = bind_addrs[0:nr_of_agent_instances] agent_pids = start_agent_instances(agent_extracted_dir, bind_addrs[0:nr_of_agent_instances], core_addrs, args.conductr_roles, features, args.log_level) return SandboxRunResult(core_pids, core_addrs, agent_pids, agent_addrs)
def test_stop_jvm_error(self): mock_sandbox_stop_features = MagicMock(return_value=True) mock_sandbox_stop_docker = MagicMock(return_value=True) mock_sandbox_stop_jvm = MagicMock(return_value=False) input_args = MagicMock(**self.default_args) with patch('conductr_cli.sandbox_stop_docker.stop', mock_sandbox_stop_docker), \ patch('conductr_cli.sandbox_stop_jvm.stop', mock_sandbox_stop_jvm), \ patch('conductr_cli.sandbox_features.stop_features', mock_sandbox_stop_features): self.assertFalse(sandbox_stop.stop(input_args)) mock_sandbox_stop_features.assert_called_once_with() mock_sandbox_stop_docker.assert_called_once_with(input_args) mock_sandbox_stop_jvm.assert_called_once_with(input_args)
def test_success(self): mock_sandbox_stop_proxy = MagicMock(return_value=True) mock_sandbox_stop_docker = MagicMock(return_value=True) mock_sandbox_stop_jvm = MagicMock(return_value=True) input_args = MagicMock(**self.default_args) with patch('conductr_cli.sandbox_stop_docker.stop', mock_sandbox_stop_docker), \ patch('conductr_cli.sandbox_stop_jvm.stop', mock_sandbox_stop_jvm), \ patch('conductr_cli.sandbox_proxy.stop_proxy', mock_sandbox_stop_proxy): self.assertTrue(sandbox_stop.stop(input_args)) mock_sandbox_stop_proxy.assert_called_once_with() mock_sandbox_stop_docker.assert_called_once_with(input_args) mock_sandbox_stop_jvm.assert_called_once_with(input_args)
def scale_cluster(args, nr_of_containers, features): sandbox_stop.stop(args) return start_nodes(args, nr_of_containers, features)
def run(args, features): """ Starts the ConductR core and agent. :param args: args parsed from the input arguments :param features: list of features which are specified via -f switch. This is only relevant for Docker based sandbox since the features decides what port to expose :return: SandboxRunResult """ nr_of_core_instances, nr_of_agent_instances = instance_count(args.image_version, args.nr_of_instances) validate_jvm_support() validate_hostname_lookup() validate_64bit_support() validate_bintray_credentials(args.image_version, args.offline_mode) sandbox_stop.stop(args) log = logging.getLogger(__name__) log.info(h1('Starting ConductR')) cleanup_tmp_dir(args.tmp_dir) bind_addrs = find_bind_addrs(max(nr_of_core_instances, nr_of_agent_instances), args.addr_range) core_extracted_dir, agent_extracted_dir = obtain_sandbox_image(args.image_dir, args.image_version, args.offline_mode) core_addrs = bind_addrs[0:nr_of_core_instances] core_pids = start_core_instances(core_extracted_dir, args.tmp_dir, args.envs, args.envs_core, args.args, args.args_core, core_addrs, args.conductr_roles, features, args.log_level) sandbox_common.wait_for_start(WaitForConductrArgs(core_addrs[0])) try: license_validation.validate_license(args.image_version, core_addrs[0], nr_of_agent_instances, DEFAULT_LICENSE_FILE) except LicenseValidationError as e: sandbox_stop.stop(args) raise e agent_addrs = bind_addrs[0:nr_of_agent_instances] agent_pids = start_agent_instances(agent_extracted_dir, args.tmp_dir, args.envs, args.envs_agent, args.args, args.args_agent, bind_addrs[0:nr_of_agent_instances], core_addrs, args.conductr_roles, features, args.log_level) return SandboxRunResult(core_pids, core_addrs, agent_pids, agent_addrs, wait_for_conductr=False)
def scale_cluster(args, features): sandbox_stop.stop(args) return start_nodes(args, features)