def test_cm_default_container_options_geoserver(self, mock_port_bindings_prop): mock_port_bindings = mock.Mock() mock_port_bindings_prop.return_value = mock_port_bindings expected_options = dict( name='tethys_geoserver', image='ciwater/geoserver:2.8.2-clustered', environment=dict( ENABLED_NODES='1', REST_NODES='1', MAX_TIMEOUT='60', NUM_CORES='4', MAX_MEMORY='1024', MIN_MEMORY='1024', ), volumes=[ '/var/log/supervisor:rw', '/var/geoserver/data:rw', '/var/geoserver:rw', ], host_config=dict(port_bindings=mock_port_bindings), ) container = cli_docker_commands.GeoServerContainerMetadata() self.assertDictEqual(expected_options, container.default_container_options())
def test_cm_ip_geoserver_non_clustered(self): cm = cli_docker_commands.GeoServerContainerMetadata() expected_msg = "\nGeoServer:" \ "\n Host: 127.0.0.1" \ "\n Port: 8181" \ "\n Endpoint: http://127.0.0.1:8181/geoserver/rest" self.assertEqual(expected_msg, cm.ip)
def test_cm_get_container_options_geoserver_defaults( self, mock_default_options): mock_default_options.return_value = mock.Mock() container = cli_docker_commands.GeoServerContainerMetadata() self.assertEqual(mock_default_options.return_value, container.get_container_options(defaults=False)) mock_default_options.assert_called()
def test_cm_ip_geoserver(self, mock_is_cluster): mock_is_cluster.return_value = True cm = cli_docker_commands.GeoServerContainerMetadata() expected_msg = "\nGeoServer:" \ "\n Host: 127.0.0.1" \ "\n Primary Port: 8181" \ "\n Node Ports: 8081, 8082, 8083, 8084" \ "\n Endpoint: http://127.0.0.1:8181/geoserver/rest" self.assertEqual(expected_msg, cm.ip)
def test_cm_get_container_options_geoserver_no_cluster( self, mock_default_options, mock_is_cluster): mock_default_options.return_value = dict() mock_is_cluster.return_value = False container = cli_docker_commands.GeoServerContainerMetadata() self.assertEqual(mock_default_options.return_value, container.get_container_options(defaults=False)) mock_default_options.assert_called() mock_is_cluster.assert_called()
def test_port_bindings_geoserver(self, mock_is_cluster): mock_is_cluster.return_value = True cm = cli_docker_commands.GeoServerContainerMetadata() self.assertDictEqual( { 8181: 8181, 8081: 8081, 8082: 8082, 8083: 8083, 8084: 8084, }, cm.port_bindings)
def test_cm_get_container_options_geoserver_numprocessors_bind( self, mock_is_cluster, mock_default_options, mock_dir_input, mock_choice_input, mock_numeric_input, mock_pretty_output, mock_mount): mock_is_cluster.return_value = True mock_default_options.return_value = dict(environment={}, host_config={}) mock_mount.return_value = mock.Mock() mock_numeric_input.side_effect = [ '1', # Number of GeoServer Instances Enabled '1', # Number of GeoServer Instances with REST API Enabled '2', # Number of Processors '60', # Maximum request timeout in seconds '1024', # Maximum memory to allocate to each GeoServer instance in MB '0', # Minimum memory to allocate to each GeoServer instance in MB ] mock_choice_input.side_effect = [ 'c', # Would you like to specify number of Processors (c) OR set limits (e) 'y', # Bind the GeoServer data directory to the host? ] mock_dir_input.side_effect = [ '/tmp' # Specify location to bind data directory ] expected_options = dict( environment=dict( ENABLED_NODES='1', REST_NODES='1', MAX_TIMEOUT='60', NUM_CORES='2', MAX_MEMORY='1024', MIN_MEMORY='0', ), host_config=dict(mounts=[mock_mount.return_value])) container = cli_docker_commands.GeoServerContainerMetadata() self.assertDictEqual(expected_options, container.get_container_options(defaults=False)) po_call_args = mock_pretty_output.call_args_list self.assertEqual(2, len(po_call_args)) self.assertIn( 'The GeoServer docker can be configured to run in a clustered mode', po_call_args[0][0][0]) self.assertIn( 'GeoServer can be configured with limits to certain types of requests', po_call_args[1][0][0])
def test_cm_get_container_options_geoserver_limits_no_bind( self, mock_is_cluster, mock_default_options, mock_choice_input, mock_numeric_input, mock_pretty_output): mock_is_cluster.return_value = True mock_default_options.return_value = dict(environment={}, host_config={}) mock_numeric_input.side_effect = [ '1', # Number of GeoServer Instances Enabled '1', # Number of GeoServer Instances with REST API Enabled '100', # Maximum number of simultaneous OGC web service requests '8', # Maximum number of simultaneous GetMap requests '16', # Maximum number of simultaneous GeoWebCache tile renders '60', # Maximum request timeout in seconds '1024', # Maximum memory to allocate to each GeoServer instance in MB '0', # Minimum memory to allocate to each GeoServer instance in MB ] mock_choice_input.side_effect = [ 'e', # Would you like to specify number of Processors (c) OR set limits (e) 'n', # Bind the GeoServer data directory to the host? ] expected_options = dict(environment=dict( ENABLED_NODES='1', REST_NODES='1', MAX_TIMEOUT='60', MAX_MEMORY='1024', MIN_MEMORY='0', MAX_OWS_GLOBAL='100', MAX_WMS_GETMAP='8', MAX_OWS_GWC='16', ), host_config={}) container = cli_docker_commands.GeoServerContainerMetadata() actual_options = container.get_container_options(defaults=False) self.assertDictEqual(expected_options, actual_options) po_call_args = mock_pretty_output.call_args_list self.assertEqual(2, len(po_call_args)) self.assertIn( 'The GeoServer docker can be configured to run in a clustered mode', po_call_args[0][0][0]) self.assertIn( 'GeoServer can be configured with limits to certain types of requests', po_call_args[1][0][0])
def test_port_bindings_geoserver_non_clustered(self): cm = cli_docker_commands.GeoServerContainerMetadata() self.assertDictEqual({8080: 8181}, cm.port_bindings)