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

Migrate setup passwords packaging test from bats #49337

Merged
merged 17 commits into from
Nov 28, 2019

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Nov 19, 2019

This commit moves the packaging tests for elasticsearch-setup-passwords
to java from bats. The change also enables future tests to enable
security in Elasticsearch and automatically have waitForElasticsearch
work correctly, at least to the same extent it worked in bats, by
waiting on the ES port instead of health check.

relates #46005

This commit moves the packaging tests for elasticsearch-setup-passwords
to java from bats. The change also enables future tests to enable
security in Elasticsearch and automatically have waitForElasticsearch
work correctly, at least to the same extent it worked in bats, by
waiting on the ES port instead of health check.

relates elastic#46005
@rjernst rjernst added >test Issues or PRs that are addressing/adding tests :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts v8.0.0 v7.6.0 labels Nov 19, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Packaging)

@rjernst rjernst requested a review from jaymode November 19, 2019 21:17
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 95 to 105
try (Socket s = new Socket(InetAddress.getLoopbackAddress(), 9200)) {
return;
} catch (IOException e) {
try {
// ignore, only want to establish a connection
Thread.sleep(1000);
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
return;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

this is just a preference, but I think it is easier to read like this:

try (Socket s = new Socket(InetAddress.getLoopbackAddress(), 9200)) {
    return;
} catch (IOException e) {
    // ignore, only want to establish a connection
}

try {
    Thread.sleep(1000);
} catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    return;
}

return sh.run(path.toString() + " " + args);
}

protected void assertWhileRunning(Platforms.PlatformAction assertions) throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be helpful to have some javadocs on this method indicating the method runs elasticsearch, performs the assertions, and then stops elasticsearch

// nothing, "installing" docker image is running it
}

} catch (Exception e ){
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (Exception e ){
} catch (Exception e){

@rjernst
Copy link
Member Author

rjernst commented Nov 21, 2019

@jaymode I addressed your comments, and also migrated the bootstrap password tests as those were tightly couple with setup-passwords behavior.

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

public void test30AddBootstrapPassword() throws Exception {
installation.executables().elasticsearchKeystore.run(sh, "add --stdin bootstrap.password", BOOTSTRAP_PASSWORD);

FileUtils.rm(installation.data); // wipe auto generated passwords from previous test
Copy link
Member

Choose a reason for hiding this comment

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

minor nit, can this be the first line of the test?

@rjernst
Copy link
Member Author

rjernst commented Nov 22, 2019

@elasticmachine run elasticsearch-ci/bwc

@rjernst
Copy link
Member Author

rjernst commented Nov 22, 2019

@elasticmachine run elasticsearch-ci/packaging-matrix

dataFiles.forEach(file -> {
if (distribution.platform != Distribution.Platform.WINDOWS) {
FileUtils.rm(file);
}
Copy link
Member

Choose a reason for hiding this comment

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

should we have an else here or a return?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, yes, i meant for a return.

@rjernst
Copy link
Member Author

rjernst commented Nov 27, 2019

@elasticmachine run elasticsearch-ci/packaging-matrix

@rjernst rjernst merged commit a9f7bfc into elastic:master Nov 28, 2019
@rjernst rjernst deleted the distro_tests33 branch November 28, 2019 00:01
rjernst added a commit that referenced this pull request Nov 28, 2019
This commit moves the packaging tests for elasticsearch-setup-passwords
to java from bats. The change also enables future tests to enable
security in Elasticsearch and automatically have waitForElasticsearch
work correctly, at least to the same extent it worked in bats, by
waiting on the ES port instead of health check.

relates #46005
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team >test Issues or PRs that are addressing/adding tests v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants