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 31 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 @@ -102,6 +102,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Exclude 'benchmarks' from codecov report ([#8805](https://github.com/opensearch-project/OpenSearch/pull/8805))
- [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))

### Deprecated
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 setHttpProtocol(String httpProtocol) {
nodes.all(each -> each.setHttpProtocol(httpProtocol));
}

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

String httpProtocol = nodes.stream().map(OpenSearchNode::getHttpProtocol).findFirst().orElse("http");

OpenSearchNode firstNode = null;
for (OpenSearchNode node : nodes) {
// Can only configure master nodes if we have node names defined
if (nodeNames != null) {
commonNodeConfig(node, nodeNames, firstNode);
commonNodeConfig(node, nodeNames, firstNode, httpProtocol);
}
if (firstNode == null) {
firstNode = node;
Expand All @@ -383,7 +389,7 @@ private void commonNodeConfig() {
}
}

private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchNode firstNode) {
private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchNode firstNode, String httpProtocol) {
if (node.getVersion().onOrAfter("7.0.0")) {
node.defaultConfig.keySet()
.stream()
Expand All @@ -400,6 +406,7 @@ private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchN
}
node.defaultConfig.put("discovery.seed_providers", "file");
node.defaultConfig.put("discovery.seed_hosts", "[]");
node.defaultConfig.put("http.protocol", httpProtocol);
} else {
node.defaultConfig.put("discovery.zen.master_election.wait_for_joins_timeout", "5s");
if (nodes.size() > 1) {
Expand Down Expand Up @@ -488,7 +495,7 @@ private OpenSearchNode upgradeNodeToNextVersion() {
OpenSearchNode node = nodes.getByName(clusterName + "-" + nodeIndex);
node.stop(false);
node.goToNextVersion();
commonNodeConfig(node, null, null);
commonNodeConfig(node, null, null, node.getHttpProtocol());
nodeIndex += 1;
return node;
}
Expand Down Expand Up @@ -554,7 +561,11 @@ public OpenSearchNode singleNode() {
private void addWaitForClusterHealth() {
waitConditions.put("cluster health yellow", (node) -> {
try {
WaitForHttpResource wait = new WaitForHttpResource("http", getFirstNode().getHttpSocketURI(), nodes.size());
WaitForHttpResource wait = new WaitForHttpResource(
getFirstNode().getHttpProtocol(),
scrawfor99 marked this conversation as resolved.
Show resolved Hide resolved
getFirstNode().getHttpSocketURI(),
nodes.size()
);

List<Map<String, String>> credentials = getFirstNode().getCredentials();
if (getFirstNode().getCredentials().isEmpty() == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class OpenSearchNode implements TestClusterConfiguration {
private static final TimeUnit NODE_UP_TIMEOUT_UNIT = TimeUnit.MINUTES;
private static final int ADDITIONAL_CONFIG_TIMEOUT = 15;
private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS;
private static final List<String> OVERRIDABLE_SETTINGS = Arrays.asList("path.repo", "discovery.seed_providers", "discovery.seed_hosts");
private static final List<String> OVERRIDABLE_SETTINGS = Arrays.asList("path.repo", "discovery.seed_providers", "discovery.seed_hosts", "http.protocol");

private static final int TAIL_LOG_MESSAGES_COUNT = 40;
private static final List<String> MESSAGES_WE_DONT_CARE_ABOUT = Arrays.asList(
Expand Down Expand Up @@ -160,6 +160,7 @@ public class OpenSearchNode implements TestClusterConfiguration {
private final Path httpPortsFile;
private final Path tmpDir;

private String httpProtocol = "http";
private int currentDistro = 0;
private TestDistribution testDistribution;
private final List<OpenSearchDistribution> distributions = new ArrayList<>();
Expand Down Expand Up @@ -217,6 +218,11 @@ public String getName() {
return nameCustomization.apply(name);
}

@Internal
public String getHttpProtocol() {
return httpProtocol;
}

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

@Override
public void setHttpProtocol(String protocol) {
this.httpProtocol = protocol;
}

@Override
public void freeze() {
requireNonNull(testDistribution, "null testDistribution passed when configuring test cluster `" + this + "`");
Expand Down Expand Up @@ -1144,6 +1155,7 @@ private void createConfiguration() {
baseConfig.put("node.attr.zone", zone);
}
baseConfig.put("node.portsfile", "true");
baseConfig.put("http.protocol", httpProtocol);
baseConfig.put("http.port", httpPort);
baseConfig.put("transport.port", transportPort);
// Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public interface TestClusterConfiguration {

void setPreserveDataDir(boolean preserveDataDir);

void setHttpProtocol(String protocol);
scrawfor99 marked this conversation as resolved.
Show resolved Hide resolved

void freeze();

void start();
Expand Down
2 changes: 2 additions & 0 deletions gradle/run.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ apply plugin: 'opensearch.testclusters'

def numNodes = findProperty('numNodes') as Integer ?: 1
def numZones = findProperty('numZones') as Integer ?: 1
def httpProto = findProperty('httpProtocol') as String ?: "http"

testClusters {
runTask {
testDistribution = 'archive'
if (numZones > 1) numberOfZones = numZones
if (numNodes > 1) numberOfNodes = numNodes
if (httpProto != "http") httpProtocol = httpProto
scrawfor99 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down