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

Allow test clusters to run with TLS #8900

Merged
merged 55 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c59a6d8
Basic idea
scrawfor99 Jul 26, 2023
e93561d
Make configurable
scrawfor99 Jul 26, 2023
485ea16
Update change log
scrawfor99 Jul 26, 2023
b47521c
Have to ask around
scrawfor99 Jul 27, 2023
df95f72
add http protocol configuration
scrawfor99 Jul 27, 2023
65520a6
Fix failure
scrawfor99 Jul 27, 2023
43bcc51
Update settings
scrawfor99 Jul 27, 2023
fe27fa8
Fix config
scrawfor99 Jul 28, 2023
ed769e6
retry integ
scrawfor99 Jul 28, 2023
3cf6e15
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Jul 28, 2023
29b5999
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Jul 28, 2023
7d6d786
retry integ
scrawfor99 Jul 28, 2023
51279c1
Fix failure to find
scrawfor99 Jul 28, 2023
51ce73d
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Jul 28, 2023
5ae72ed
spotless
scrawfor99 Jul 28, 2023
150498b
fix assigment
scrawfor99 Jul 28, 2023
3ecc305
fix npe
scrawfor99 Jul 28, 2023
3d35b67
set default
scrawfor99 Jul 28, 2023
2514fef
set default
scrawfor99 Jul 28, 2023
0a51d91
Spotless
scrawfor99 Jul 28, 2023
f112deb
prevent empty string
scrawfor99 Jul 28, 2023
b82f768
Swap optional use
scrawfor99 Jul 31, 2023
89595f6
Swap back run setup
scrawfor99 Jul 31, 2023
46c53f3
try stream fix
scrawfor99 Jul 31, 2023
86e23cd
store
scrawfor99 Jul 31, 2023
0d160b2
remove config mentioons
scrawfor99 Jul 31, 2023
83bb8cd
fix failure
scrawfor99 Jul 31, 2023
932fabe
spotless
scrawfor99 Jul 31, 2023
021a20f
Merge branch 'main' into bwcFix
scrawfor99 Jul 31, 2023
af330f1
Readd setting to config
scrawfor99 Aug 4, 2023
3f34fb8
readd overridable
scrawfor99 Aug 4, 2023
aa355f7
Spotless
scrawfor99 Aug 4, 2023
8ce7bd8
Add setting to env
scrawfor99 Aug 4, 2023
5434d53
spotless
scrawfor99 Aug 4, 2023
44db288
trigger retry
scrawfor99 Aug 4, 2023
49eefd4
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Aug 8, 2023
6fc3ef3
Buildable
scrawfor99 Aug 11, 2023
d8f1427
update cert passing
scrawfor99 Aug 11, 2023
7067655
remove log
scrawfor99 Aug 11, 2023
561da1c
buildable no logs
scrawfor99 Aug 11, 2023
8302871
Spotless
scrawfor99 Aug 11, 2023
840cb37
remove uneeded configs
scrawfor99 Aug 11, 2023
2496184
Pass old creds
scrawfor99 Aug 11, 2023
71a5c06
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Aug 14, 2023
b7b1aae
fix bad logs
scrawfor99 Aug 14, 2023
634d5e1
spotless
scrawfor99 Aug 14, 2023
24e956e
Merge branch 'opensearch-project:main' into bwcFix
scrawfor99 Aug 15, 2023
68ee6b4
Reta's requests
scrawfor99 Aug 15, 2023
8b68f99
Swap to boolean
scrawfor99 Aug 15, 2023
3f06cd6
trigger retry
scrawfor99 Aug 15, 2023
1f4f641
Make bool
scrawfor99 Aug 15, 2023
e483cdc
fix npe
scrawfor99 Aug 15, 2023
d612bb8
spotless
scrawfor99 Aug 15, 2023
8a19538
Merge branch 'main' into bwcFix
scrawfor99 Aug 16, 2023
c320559
failed with string logic
scrawfor99 Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change InternalSignificantTerms to sum shard-level superset counts only in final reduce ([#8735](https://github.com/opensearch-project/OpenSearch/pull/8735))
- Exclude 'benchmarks' from codecov report ([#8805](https://github.com/opensearch-project/OpenSearch/pull/8805))
- Create separate SourceLookup instance per segment slice in SignificantTextAggregatorFactory ([#8807](https://github.com/opensearch-project/OpenSearch/pull/8807))
- Allow test clusters to run with TLS ([#8900](https://github.com/opensearch-project/OpenSearch/pull/8900))
- Replace the deprecated IndexReader APIs with new storedFields() & termVectors() ([#7792](https://github.com/opensearch-project/OpenSearch/pull/7792))
- [Remote Store] Add support to restore only unassigned shards of an index ([#8792](https://github.com/opensearch-project/OpenSearch/pull/8792))
- Add safeguard limits for file cache during node level allocation ([#8208](https://github.com/opensearch-project/OpenSearch/pull/8208))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@
this(new URL(protocol + "://" + host + "/_cluster/health?wait_for_nodes=>=" + numberOfNodes + "&wait_for_status=yellow"));
}

public WaitForHttpResource(String protocol, String host, String username, String password, int numberOfNodes)
throws MalformedURLException {
this(

Check warning on line 88 in buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java#L88

Added line #L88 was not covered by tests
new URL(
protocol
+ "://"
+ username
+ ":"
+ password
+ "@"
+ host
+ "/_cluster/health?wait_for_nodes=>="
+ numberOfNodes
+ "&wait_for_status=yellow"
)
);
}

Check warning on line 102 in buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java#L102

Added line #L102 was not covered by tests

public WaitForHttpResource(URL url) {
this.url = url;
}
Expand Down
peternied marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
private final FileSystemOperations fileSystemOperations;
private final ArchiveOperations archiveOperations;
private int nodeIndex = 0;

private int zoneCount = 1;

public OpenSearchCluster(
Expand All @@ -100,7 +99,6 @@
this.archiveOperations = archiveOperations;
this.workingDirBase = workingDirBase;
this.nodes = project.container(OpenSearchNode.class);

// Always add the first node
String zone = hasZoneProperty() ? "zone-1" : "";
addNode(clusterName + "-0", zone);
Expand Down Expand Up @@ -265,6 +263,11 @@
nodes.all(each -> each.keystorePassword(password));
}

@Override
public void setSecure(boolean secure) {
nodes.all(each -> each.setSecure(secure));
}

Check warning on line 269 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L268-L269

Added lines #L268 - L269 were not covered by tests

@Override
public void cliSetup(String binTool, CharSequence... args) {
nodes.all(each -> each.cliSetup(binTool, args));
Expand Down Expand Up @@ -367,6 +370,7 @@
} else {
nodeNames = nodes.stream().map(OpenSearchNode::getName).map(this::safeName).collect(Collectors.joining(","));
}

OpenSearchNode firstNode = null;
for (OpenSearchNode node : nodes) {
// Can only configure master nodes if we have node names defined
Expand Down Expand Up @@ -554,12 +558,25 @@
private void addWaitForClusterHealth() {
waitConditions.put("cluster health yellow", (node) -> {
try {
WaitForHttpResource wait = new WaitForHttpResource("http", getFirstNode().getHttpSocketURI(), nodes.size());

List<Map<String, String>> credentials = getFirstNode().getCredentials();
if (getFirstNode().getCredentials().isEmpty() == false) {
wait.setUsername(credentials.get(0).get("useradd"));
wait.setPassword(credentials.get(0).get("-p"));
WaitForHttpResource wait;
if (!getFirstNode().isSecure()) {
wait = new WaitForHttpResource("http", getFirstNode().getHttpSocketURI(), nodes.size());
List<Map<String, String>> credentials = getFirstNode().getCredentials();

Check warning on line 564 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L563-L564

Added lines #L563 - L564 were not covered by tests
if (getFirstNode().getCredentials().isEmpty() == false) {
wait.setUsername(credentials.get(0).get("useradd"));
wait.setPassword(credentials.get(0).get("-p"));

Check warning on line 567 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L566-L567

Added lines #L566 - L567 were not covered by tests
Comment on lines +566 to +567

Choose a reason for hiding this comment

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

Why useradd and -p and not username and password?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was support for the previous testing

}
} else {
wait = new WaitForHttpResource(

Check warning on line 570 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L569-L570

Added lines #L569 - L570 were not covered by tests
"https",
getFirstNode().getHttpSocketURI(),
getFirstNode().getCredentials().get(0).get("username"),
getFirstNode().getCredentials().get(0).get("password"),
nodes.size()

Check warning on line 575 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L572-L575

Added lines #L572 - L575 were not covered by tests
);
wait.setUsername(getFirstNode().getCredentials().get(0).get("username"));
wait.setPassword(getFirstNode().getCredentials().get(0).get("password"));
Comment on lines +573 to +578

Choose a reason for hiding this comment

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

Why do you set credentials twice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One constructs the URL, one configures the the object.

wait.setCertificateAuthorities(getFirstNode().getExtraConfigFilesMap().get("root-ca.pem"));

Check warning on line 579 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java#L577-L579

Added lines #L577 - L579 were not covered by tests
}
return wait.wait(500);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
private final Path httpPortsFile;
private final Path tmpDir;

private boolean secure = false;

Check warning on line 163 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L163

Added line #L163 was not covered by tests
private int currentDistro = 0;
private TestDistribution testDistribution;
private final List<OpenSearchDistribution> distributions = new ArrayList<>();
Expand Down Expand Up @@ -209,6 +210,7 @@
setTestDistribution(TestDistribution.INTEG_TEST);
setVersion(VersionProperties.getOpenSearch());
this.zone = zone;
this.credentials.add(new HashMap<>());

Check warning on line 213 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L213

Added line #L213 was not covered by tests
scrawfor99 marked this conversation as resolved.
Show resolved Hide resolved
}

@Input
Expand All @@ -217,6 +219,11 @@
return nameCustomization.apply(name);
}

@Internal
public boolean isSecure() {
return secure;

Check warning on line 224 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L224

Added line #L224 was not covered by tests
}

@Internal
public Version getVersion() {
return Version.fromString(distributions.get(currentDistro).getVersion());
Expand Down Expand Up @@ -452,6 +459,11 @@
this.preserveDataDir = preserveDataDir;
}

@Override
public void setSecure(boolean secure) {
this.secure = secure;
}

Check warning on line 465 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L464-L465

Added lines #L464 - L465 were not covered by tests

@Override
public void freeze() {
requireNonNull(testDistribution, "null testDistribution passed when configuring test cluster `" + this + "`");
Expand All @@ -471,6 +483,18 @@
@Override
public synchronized void start() {
LOGGER.info("Starting `{}`", this);
if (System.getProperty("tests.opensearch.secure") != null
&& System.getProperty("tests.opensearch.secure").equalsIgnoreCase("true")) {
secure = true;

Check warning on line 488 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L488

Added line #L488 was not covered by tests
}
if (System.getProperty("tests.opensearch.username") != null) {
this.credentials.get(0).put("username", System.getProperty("tests.opensearch.username"));
LOGGER.info("Overwriting username to: " + this.getCredentials().get(0).get("username"));

Check warning on line 492 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L491-L492

Added lines #L491 - L492 were not covered by tests
}
if (System.getProperty("tests.opensearch.password") != null) {
this.credentials.get(0).put("password", System.getProperty("tests.opensearch.password"));
LOGGER.info("Overwriting password to: " + this.getCredentials().get(0).get("password"));

Check warning on line 496 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L495-L496

Added lines #L495 - L496 were not covered by tests
}
if (Files.exists(getExtractedDistributionDir()) == false) {
throw new TestClustersException("Can not start " + this + ", missing: " + getExtractedDistributionDir());
}
Expand Down Expand Up @@ -1349,6 +1373,11 @@
return extraConfigFiles.getNormalizedCollection();
}

@Internal
public Map<String, File> getExtraConfigFilesMap() {
return extraConfigFiles;

Check warning on line 1378 in buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L1378

Added line #L1378 was not covered by tests
}

@Override
@Internal
public boolean isProcessAlive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public interface TestClusterConfiguration {

void setPreserveDataDir(boolean preserveDataDir);

void setSecure(boolean secure);

void freeze();

void start();
Expand Down