Skip to content

Commit

Permalink
[7.17] Convert smoke test multinode (#92774) (#92794)
Browse files Browse the repository at this point in the history
* Convert smoke test multinode (#92774)

# Conflicts:
#	qa/smoke-test-multinode/build.gradle
#	qa/smoke-test-multinode/src/yamlRestTest/java/org/elasticsearch/smoketest/SmokeTestMultiNodeClientYamlTestSuiteIT.java

* Remove unknown roles from test cluster
  • Loading branch information
mark-vieira committed Jan 10, 2023
1 parent 17dc33d commit 689a2b3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
18 changes: 4 additions & 14 deletions qa/smoke-test-multinode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,20 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

restResources {
restTests {
includeCore '*'
}
}

File repo = file("$buildDir/testclusters/repo")
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
numberOfNodes = 2
setting 'path.repo', repo.absolutePath
}

testClusters.configureEach {
setting 'xpack.security.enabled', 'false'
dependencies {
clusterModules project(":modules:mapper-extras")
clusterModules project(":modules:ingest-common")
}

tasks.named("yamlRestTest").configure {
doFirst {
project.delete(repo)
repo.mkdirs()
}
systemProperty 'tests.rest.blacklist', [
'cat.templates/10_basic/No templates',
'cat.templates/10_basic/Sort templates',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,34 @@
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;

import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;

@TimeoutSuite(millis = 40 * TimeUnits.MINUTE) // some of the windows test VMs are slow as hell
public class SmokeTestMultiNodeClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {

private static TemporaryFolder repoDirectory = new TemporaryFolder();

private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.nodes(2)
.module("mapper-extras")
.module("ingest-common")
.setting("path.repo", () -> repoDirectory.getRoot().getPath())
// The first node does not have the ingest role so we're sure ingest requests are forwarded:
.node(0, n -> n.setting("node.roles", "[master,data,remote_cluster_client]"))
.feature(FeatureFlag.TIME_SERIES_MODE)
.build();

@ClassRule
// Ensure the shared repo dir is created before cluster start
public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);

public SmokeTestMultiNodeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
Expand All @@ -27,4 +49,9 @@ public SmokeTestMultiNodeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandi
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

public class DefaultEnvironmentProvider implements EnvironmentProvider {
private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname";
Expand All @@ -34,6 +35,9 @@ public Map<String, String> get(LocalNodeSpec nodeSpec) {
environment.put("HOSTNAME", HOSTNAME_OVERRIDE);
environment.put("COMPUTERNAME", COMPUTERNAME_OVERRIDE);

// Use the same timezone as the test executor
environment.put("TZ", TimeZone.getDefault().getID());

return environment;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ private void writeConfiguration() {

try {
// Write settings to elasticsearch.yml
Map<String, String> pathSettings = new HashMap<>();
pathSettings.put("path.repo", workingDir.resolve("repo").toString());
pathSettings.put("path.data", workingDir.resolve("data").toString());
pathSettings.put("path.logs", workingDir.resolve("logs").toString());
Map<String, String> finalSettings = new HashMap<>();
finalSettings.put("path.repo", workingDir.resolve("repo").toString());
finalSettings.put("path.data", workingDir.resolve("data").toString());
finalSettings.put("path.logs", workingDir.resolve("logs").toString());
finalSettings.putAll(spec.resolveSettings());

Files.writeString(
configFile,
Stream.concat(spec.resolveSettings().entrySet().stream(), pathSettings.entrySet().stream())
finalSettings.entrySet()
.stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.collect(Collectors.joining("\n")),
StandardOpenOption.TRUNCATE_EXISTING,
Expand Down

0 comments on commit 689a2b3

Please sign in to comment.