Refactor Gitlab::Elastic::Helper#create_index

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

The #create_index method for Gitlab::Elastic::Helper violates single responsibility principle by also creating an alias as a side effect, depending on the arguments. Additionally, if an alias is not desired, an alias is still a required argument, so the method call ends up looking something like create_index(with_alias: false, alias_name: :noop, ...). Lastly, there are no specs dedicated for testing create_index behavior. I believe this is due to it originally being a private method and later on moved to public.

Proposal

Separate creating an index and creating an alias into separate methods and adding appropriate test coverage for both.

Edited by 🤖 GitLab Bot 🤖