Example #1
0
    def test_recreate_existing_managed_index(self, es):
        es.indices.exists.return_value = True

        index = track.Index(name="test-index",
                            auto_managed=True,
                            types=[
                                track.Type(
                                    name="test-type",
                                    mapping={"test-type": "empty-for-test"})
                            ])
        index_settings = {"index.number_of_replicas": 0}
        expected_body = {
            "settings": {
                "index.number_of_replicas": 0
            },
            "mappings": {
                "test-type": "empty-for-test"
            }
        }
        driver.setup_index(es, index, index_settings)

        es.indices.exists.assert_called_with(index="test-index")
        es.indices.delete.assert_called_with(index="test-index")
        es.indices.create.assert_called_with(index="test-index",
                                             body=expected_body)
Example #2
0
    def test_recreate_existing_managed_index(self, es):
        es.indices.exists.return_value = True

        index = track.Index(name="test-index",
                            auto_managed=True,
                            types=[track.Type(name="test-type", mapping_file=['{"mapping": "empty-for-test"}'])])
        index_settings = {
            "index.number_of_replicas": 0
        }
        driver.setup_index(es, index, index_settings, source=io.StringAsFileSource)

        es.indices.exists.assert_called_with(index="test-index")
        es.indices.delete.assert_called_with(index="test-index")
        es.indices.create.assert_called_with(index="test-index", body=index_settings)
        es.indices.put_mapping.assert_called_with(index="test-index", doc_type="test-type", body={"mapping": "empty-for-test"})
Example #3
0
    def test_recreate_existing_managed_index(self, es):
        es.indices.exists.return_value = True

        index = track.Index(name="test-index",
                            auto_managed=True,
                            types=[track.Type(name="test-type", mapping={"test-type": "empty-for-test"})])
        index_settings = {
            "index.number_of_replicas": 0
        }
        expected_body = {
            "settings": {
                "index.number_of_replicas": 0
            },
            "mappings": {
                "test-type": "empty-for-test"
            }
        }
        driver.setup_index(es, index, index_settings)

        es.indices.exists.assert_called_with(index="test-index")
        es.indices.delete.assert_called_with(index="test-index")
        es.indices.create.assert_called_with(index="test-index", body=expected_body)
Example #4
0
    def test_setup_auto_managed_index(self, es):
        es.indices.exists.return_value = False

        index = track.Index(name="test-index",
                            auto_managed=True,
                            types=[track.Type(name="test-type", mapping_file=['{"test-type": "empty-for-test"}'])])
        index_settings = {
            "index.number_of_replicas": 0
        }
        expected_body = {
            "settings": {
                "index.number_of_replicas": 0
            },
            "mappings": {
                "test-type": "empty-for-test"
            }
        }
        driver.setup_index(es, index, index_settings, source=io.StringAsFileSource)

        es.indices.exists.assert_called_with(index="test-index")
        es.indices.delete.assert_not_called()
        es.indices.create.assert_called_with(index="test-index", body=expected_body)
Example #5
0
 def test_do_not_change_manually_managed_index(self, es):
     index = track.Index(name="test-index", auto_managed=False, types=[])
     driver.setup_index(es, index, index_settings=None)
     es.assert_not_called()
Example #6
0
 def test_do_not_change_manually_managed_index(self, es):
     index = track.Index(name="test-index", auto_managed=False, types=[])
     driver.setup_index(es, index, index_settings=None)
     es.assert_not_called()