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

HLRC: Add support for XPack Post Start Basic Licence API #33606

Merged

Conversation

vladimirdolzhenko
Copy link
Contributor

HLRC: Add support for XPack Post Start Basic Licence API

Relates to #29827

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM, assuming that you will fix the formatting issue and the test pass. Maybe @hub-cap should give it a look as well.

@vladimirdolzhenko
Copy link
Contributor Author

@elasticmachine test this please

@vladimirdolzhenko
Copy link
Contributor Author

@hub-cap could you please have a look as well ?

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

Lets drop the word post from all this, as we want to keep it to just the name of the action. Of course, in the request converters we will know its a POST, but the HL client should be agnostic of this. Also please move the stuff you put back in protocol back. Sorry about any confusion, the rest client has been in lots of flux.

@hub-cap
Copy link
Contributor

hub-cap commented Sep 19, 2018

as mentioned in #33406 (review), we need to add a LicensingIT test class for testing randomized values in these calls, and negative tests. Please add that. I wanted to just drop a comment before I started reviewing so you know of this quicker.

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

Great work so far. Some stuff to address below, nothing huge.

import org.elasticsearch.action.support.master.AcknowledgedRequest;

public class PostStartBasicRequest extends AcknowledgedRequest<PostStartBasicRequest> {
private boolean acknowledge = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

pls make this boolean final and remove the setter.

import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;

public class PostStartBasicResponse extends AcknowledgedResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class looks like it has a lot of extra stuff that is not needed. In general, we do not need from/to transport serialization. Do we need addCustomFields, as its also toXContent related.

return new PostStartBasicResponse(status, acknowledgements.v2(), acknowledgements.v1());
});

private static final ParseField BASIC_WAS_STARTED = new ParseField("basic_was_started");
Copy link
Contributor

Choose a reason for hiding this comment

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

private Map<String, String[]> acknowledgeMessages;
private String acknowledgeMessage;

public enum Status {
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 a more common class that can be used elsewhere? if so, lets break it out to its own class, and put it in the same package.

import java.util.Map;
import java.util.function.Predicate;

public class PostStartBasicResponseTests extends AbstractStreamableXContentTestCase<PostStartBasicResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

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

These will have to change as well, once you remove the ToXContent portion of the response. You will have to manually construct the parser and then pass that in to the fromXContent of the response.

@@ -0,0 +1,55 @@
[[java-rest-high-post-start-basic]]
Copy link
Contributor

Choose a reason for hiding this comment

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

@hub-cap
Copy link
Contributor

hub-cap commented Sep 19, 2018

Pls also add a LicenseRequestConvertersTests to test your request converter.

@vladimirdolzhenko
Copy link
Contributor Author

@elasticmachine test this please

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

LGTM, one nit then you can merge

}

@Override
public ActionRequestValidationException validate() {
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 leave this out if you are not using it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with ccbc485 StartBasicRequest extends TimedRequest, added couple test routines for that

@vladimirdolzhenko
Copy link
Contributor Author

vladimirdolzhenko commented Oct 4, 2018

there is a dependency for tests on #33406 - I'd rather wait for start trial license to be merged

@hub-cap
Copy link
Contributor

hub-cap commented Oct 15, 2018

if you want to merge, you can always just stub in some Low level rest calls and then @andyb-elastic can clean them up in his PR ;)

@vladimirdolzhenko
Copy link
Contributor Author

@hub-cap thanks for the tip: in fact start trial license did not help as it had been already started.

there are several ways (at least 2) on how to solve the problem:

  • put a hard coded trial license (as it is not possible to bring license-tools to hlrc due to jar hell) - it could works for snapshot build only
  • split license specific tests into a separated gradle task
  • any other

for now I rely on a hard coded trial license approach

@hub-cap
Copy link
Contributor

hub-cap commented Oct 16, 2018

Ahh right it was this issue, and I discussed with @andyb-elastic and he is going to make a new PR with the changes to make a new cluster with the different license test requirements. So it might make sense to merge this and backport it and await his change, so you can also make your change. Your call.

@vladimirdolzhenko vladimirdolzhenko merged commit 230ad53 into elastic:master Oct 16, 2018
@vladimirdolzhenko
Copy link
Contributor Author

thanks @hub-cap for comments 👍

vladimirdolzhenko added a commit that referenced this pull request Oct 16, 2018
@vladimirdolzhenko vladimirdolzhenko deleted the hlrc_post_start_basic branch October 16, 2018 14:06
@andyb-elastic
Copy link
Contributor

Right, looks like you got the case where it starts a basic license working by manually setting a trial license. I'm working on a PR to run the license IT in a separate gradle project (we ran into some issues getting it to work with multiple clusters in the same project)

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

Successfully merging this pull request may close these issues.

6 participants