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 51 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 @@ -130,6 +130,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Adds support for tracing runnable scenarios ([#8831](https://github.com/opensearch-project/OpenSearch/pull/8831))
- [Refactor] MediaTypeParser to MediaTypeParserRegistry ([#8636](https://github.com/opensearch-project/OpenSearch/pull/8636))
- 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))
- Add support for aggregation profiler with concurrent aggregation ([#8801](https://github.com/opensearch-project/OpenSearch/pull/8801))
- [Remove] Deprecated Fractional ByteSizeValue support #9005 ([#9005](https://github.com/opensearch-project/OpenSearch/pull/9005))
- Make MultiBucketConsumerService thread safe to use across slices during search ([#9047](https://github.com/opensearch-project/OpenSearch/pull/9047))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ public WaitForHttpResource(String protocol, String host, int numberOfNodes) thro
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(
new URL(
protocol
+ "://"
+ username
+ ":"
+ password
+ "@"
+ host
+ "/_cluster/health?wait_for_nodes=>="
+ numberOfNodes
+ "&wait_for_status=yellow"
)
);
}

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 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
private final FileSystemOperations fileSystemOperations;
private final ArchiveOperations archiveOperations;
private int nodeIndex = 0;

private int zoneCount = 1;

public OpenSearchCluster(
Expand All @@ -100,7 +99,6 @@ public OpenSearchCluster(
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 @@ public void keystorePassword(String password) {
nodes.all(each -> each.keystorePassword(password));
}

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

@Override
public void cliSetup(String binTool, CharSequence... args) {
nodes.all(each -> each.cliSetup(binTool, args));
Expand Down Expand Up @@ -367,6 +370,7 @@ private void commonNodeConfig() {
} 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 @@ public OpenSearchNode singleNode() {
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();
if (getFirstNode().getCredentials().isEmpty() == false) {
wait.setUsername(credentials.get(0).get("useradd"));
wait.setPassword(credentials.get(0).get("-p"));
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(
"https",
getFirstNode().getHttpSocketURI(),
getFirstNode().getCredentials().get(0).get("username"),
getFirstNode().getCredentials().get(0).get("password"),
nodes.size()
);
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"));
}
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 @@ public class OpenSearchNode implements TestClusterConfiguration {
private final Path httpPortsFile;
private final Path tmpDir;

private boolean secure = false;
private int currentDistro = 0;
private TestDistribution testDistribution;
private final List<OpenSearchDistribution> distributions = new ArrayList<>();
Expand Down Expand Up @@ -209,6 +210,7 @@ public class OpenSearchNode implements TestClusterConfiguration {
setTestDistribution(TestDistribution.INTEG_TEST);
setVersion(VersionProperties.getOpenSearch());
this.zone = zone;
this.credentials.add(new HashMap<>());
scrawfor99 marked this conversation as resolved.
Show resolved Hide resolved
}

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

@Internal
public boolean isSecure() {
return secure;
}

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

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

@Override
public void freeze() {
requireNonNull(testDistribution, "null testDistribution passed when configuring test cluster `" + this + "`");
Expand All @@ -471,6 +483,17 @@ public Stream<String> logLines() throws IOException {
@Override
public synchronized void start() {
LOGGER.info("Starting `{}`", this);
if (System.getProperty("tests.opensearch.secure").equalsIgnoreCase("true")) {
secure = Boolean.getBoolean(System.getProperty("tests.opensearch.secure"));
}
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"));
}
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"));
}
if (Files.exists(getExtractedDistributionDir()) == false) {
throw new TestClustersException("Can not start " + this + ", missing: " + getExtractedDistributionDir());
}
Expand Down Expand Up @@ -1349,6 +1372,11 @@ public List<?> getExtraConfigFiles() {
return extraConfigFiles.getNormalizedCollection();
}

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

@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