Skip to content

cli: add index list option to init#192

Open
carantunes wants to merge 5 commits intoinveniosoftware:masterfrom
carantunes:cli/add-index-list-option-to-init
Open

cli: add index list option to init#192
carantunes wants to merge 5 commits intoinveniosoftware:masterfrom
carantunes:cli/add-index-list-option-to-init

Conversation

@carantunes
Copy link
Copy Markdown

@carantunes carantunes commented Nov 21, 2019

Add option to init to allow initialization of indices by name.

Usage:
$ invenio index init -i records-authorities-authority-v1.0.0 -i another-index
$ invenio index init -i index-a -i index-b

@carantunes carantunes force-pushed the cli/add-index-list-option-to-init branch from 16aa473 to b0caec5 Compare November 22, 2019 16:06
@carantunes carantunes force-pushed the cli/add-index-list-option-to-init branch from b0caec5 to f1d5bf1 Compare November 22, 2019 16:21
@carantunes carantunes changed the title [WIP] cli: add index list option to init cli: add index list option to init Nov 22, 2019
@carantunes carantunes force-pushed the cli/add-index-list-option-to-init branch from acf4f5b to cc3ec15 Compare November 25, 2019 09:36
@carantunes carantunes requested a review from ntarocco April 28, 2020 18:00
Copy link
Copy Markdown
Contributor

@ntarocco ntarocco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I added a couple of small comments.


assert current_search_client.indices.exists(list(search.mappings.keys()))

# Test option --index-name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to test this!
A minor comment: does it make sense to maybe split in smaller tests?

assert 0 == result.exit_code
assert current_search_client.indices.exists(list(search.mappings.keys()))
aliases = current_search_client.indices.get_alias()
assert 8 == sum(len(idx.get('aliases', {})) for idx in aliases.values())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a lot of issues in the past (on cds-videos, another Invenio installation) with tests that contains these numbers, like 8 ==, because when changing something, it is hard to know what number to put there and why such number.

Could you try to replace the number with a named constant or maybe explain in a comment?

@with_appcontext
@es_version_check
def init(force):
def init(force, index_list):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of adding the default value?

Suggested change
def init(force, index_list):
def init(force, index_list=[]):

or

Suggested change
def init(force, index_list):
def init(force, index_list=None):

:returns: A string with the index name unsuffixed.
"""
search_ext = app.extensions['invenio-search'] if app else current_search
suffix = suffix if suffix is not None else search_ext.current_suffix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suffixes are also timestamps, and if they are not matched, then init creates a new index, I think we should also include this in the test cases (I saw it happening on integration testing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants