Skip to content

Remove creation of new index when reindexing #1473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tests/unit/cli/search/test_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ def __init__(self):

self.put_settings = pretend.call_recorder(lambda *a, **kw: None)
self.forcemerge = pretend.call_recorder(lambda *a, **kw: None)

def create(self, index, body):
self.indices[index] = body

def delete(self, index):
self.indices.pop(index, None)
self.delete = pretend.call_recorder(lambda *a, **kw: None)

def exists_alias(self, name):
return name in self.aliases
Expand Down Expand Up @@ -138,6 +133,8 @@ def parallel_bulk(client, iterable):
monkeypatch.setattr(
warehouse.cli.search.reindex, "parallel_bulk", parallel_bulk)

monkeypatch.setattr(os, "urandom", lambda n: b"\xcb" * n)

result = cli.invoke(reindex, obj=config)

assert result.exit_code == -1
Expand All @@ -148,7 +145,9 @@ def parallel_bulk(client, iterable):
]
assert sess_obj.rollback.calls == [pretend.call()]
assert sess_obj.close.calls == [pretend.call()]
assert es_client.indices.indices == {}
assert es_client.indices.delete.calls == [
pretend.call(index='warehouse-cbcbcbcbcb'),
]
assert es_client.indices.put_settings.calls == []
assert es_client.indices.forcemerge.calls == []

Expand Down Expand Up @@ -199,7 +198,7 @@ def project_docs(db):
assert parallel_bulk .calls == [pretend.call(es_client, docs)]
assert sess_obj.rollback.calls == [pretend.call()]
assert sess_obj.close.calls == [pretend.call()]
assert set(es_client.indices.indices) == {"warehouse-cbcbcbcbcb"}
assert es_client.indices.delete.calls == []
assert es_client.indices.aliases == {
"warehouse": ["warehouse-cbcbcbcbcb"],
}
Expand Down Expand Up @@ -267,7 +266,9 @@ def project_docs(db):
assert parallel_bulk.calls == [pretend.call(es_client, docs)]
assert sess_obj.rollback.calls == [pretend.call()]
assert sess_obj.close.calls == [pretend.call()]
assert set(es_client.indices.indices) == {"warehouse-cbcbcbcbcb"}
assert es_client.indices.delete.calls == [
pretend.call('warehouse-aaaaaaaaaa'),
]
assert es_client.indices.aliases == {
"warehouse": ["warehouse-cbcbcbcbcb"],
}
Expand Down
1 change: 0 additions & 1 deletion warehouse/cli/search/reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def reindex(config, **kwargs):
replicas=0,
interval="-1",
)
new_index.create()

# From this point on, if any error occurs, we want to be able to delete our
# in progress index.
Expand Down