Skip to content
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

Introduce Multi Cluster Management #285

Merged
merged 3 commits into from
May 28, 2018
Merged

Introduce Multi Cluster Management #285

merged 3 commits into from
May 28, 2018

Conversation

Copy link
Contributor

@raphi raphi left a comment

Choose a reason for hiding this comment

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

LGTM, just minor Ruby syntax 🙌 👍

delete(Protocol.cluster_mapping_uri, :write, request_options)
end

def search_user_id(query, clusterName = nil, page = nil, hits_per_page = nil, request_options = {})
Copy link
Contributor

Choose a reason for hiding this comment

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

clusterName => cluster_name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Old habit :D

end

def search_user_id(query, clusterName = nil, page = nil, hits_per_page = nil, request_options = {})
body = {:query => query}
Copy link
Contributor

Choose a reason for hiding this comment

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

{:query => query} => { :query => query }

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW I didn't mark all of them, just one example


def Protocol.cluster_mapping_uri(user_id = nil)
if user_id
user_id = "/#{CGI.escape(user_id)}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually inlined if are written after the statement in Ruby: user_id = "/#{CGI.escape(user_id)}" if user_id

if user_id
user_id = "/#{CGI.escape(user_id)}"
end
"/#{VERSION}/clusters/mapping" + user_id.to_s
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this endpoint valid /#{VERSION}/clusters/mapping if user_id is nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's use to add/remove user IDs, I didn't want to create 2 entries in Protocol but maybe that would be clearer.

end

after(:all) do
# @index.delete_index rescue "not fatal"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ dead code


it "should remove a user_id" do
res = @client.remove_user_id(@user_id)
sleep(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no waitTask for MCM?

Copy link
Contributor Author

@julienbourdeau julienbourdeau May 2, 2018

Choose a reason for hiding this comment

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

No :(
A better way to do this would be to loop and call multiple times to see if it was removed. After X attemps, the test would fail.

end

def assign_user_id(user_id, cluster_name, request_options = {})
if !request_options["headers"].is_a?(Hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use single quotes when there is no interpolation to perform

@@ -26,6 +26,7 @@

RSpec.configure do |config|
config.mock_with :rspec
config.expect_with(:rspec) { |c| c.syntax = :should }
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh my bad, since it is currently working with expect for the oldest Ruby version already, I think it's not necessary to downgrade the syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understood this opposite. I thought expect was the new way and we were using include for older version. I had a warning saying it should be activated explicitely. I'll check again 👌

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, it's the new way but it is working for old rubies; Take a look at the latest Travis run, all green even on 1.8.xx

end

def remove_user_id(user_id, request_options = {})
if !request_options["headers"].is_a?(Hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could factorize it

@julienbourdeau
Copy link
Contributor Author

@raphi Let me know what you think of the 3rd commit.

@coveralls
Copy link

coveralls commented May 14, 2018

Coverage Status

Coverage increased (+2.0%) to 97.073% when pulling 2a4d610 on feat/mcm into 7cff817 on master.

Copy link
Contributor

@raphi raphi left a comment

Choose a reason for hiding this comment

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

You should either add the exclamation mark to your method add_header_to_request_options! to indicate you are modifying the object passed (call to merge!) and then you don't need the variable assignment or use merge in your method

@julienbourdeau
Copy link
Contributor Author

Updated! Thanks for review

@raphi
Copy link
Contributor

raphi commented May 14, 2018

@julienbourdeau np! Please just revert config.expect_with(:rspec) { |c| c.syntax = :should } and LGTM 👍 :ruby: 🙌

raphi
raphi previously approved these changes May 14, 2018
Copy link
Contributor

@raphi raphi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@julienbourdeau
Copy link
Contributor Author

Build is greed ✅

@raphi
Copy link
Contributor

raphi commented May 28, 2018

@julienbourdeau what did you changed though? It seems there might be some concurrency issues in the MCM tests

@julienbourdeau
Copy link
Contributor Author

I think when they run all at once, the delay might be a bit longer to assign/remove user ids but the name shouldn't collide.

@raphi
Copy link
Contributor

raphi commented May 28, 2018

I don't remember the error exactly but on top of my head it was something like "MCM already processing id whatever" so probably a delay issue.

@julienbourdeau
Copy link
Contributor Author

Yes, I think it was occuring when trying to remove a user id while the assigning task wasn't finished. There is no taskID for this type of job :(

@raphi raphi merged commit 2b70f74 into master May 28, 2018
@raphi raphi deleted the feat/mcm branch May 28, 2018 15:59
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.

None yet

3 participants