Skip to content

Commit

Permalink
Migrate some ESQL QA modules to new test framework (elastic#103744)
Browse files Browse the repository at this point in the history
This PR migrates some ESQL QA modules to the new test framework.
  • Loading branch information
dnhatn authored Jan 2, 2024
1 parent 0570b0b commit a6155f8
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:correctness");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:mixed-node");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:heap-attack");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:multi-node");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:single-node");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:identity-provider:qa:idp-rest-tests");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:multi-cluster");
Expand Down
47 changes: 0 additions & 47 deletions x-pack/plugin/esql/qa/server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,3 @@ dependencies {
api project(xpackModule('ql:test-fixtures'))
api project(xpackModule('esql:qa:testFixtures'))
}

subprojects {
if (subprojects.isEmpty()) {
// leaf project
} else {
apply plugin: 'elasticsearch.java'
apply plugin: 'elasticsearch.standalone-rest-test'
}


if (project.name != 'security' && project.name != 'mixed-cluster' && project.name != 'multi-clusters') {
// The security project just configures its subprojects
apply plugin: 'elasticsearch.legacy-java-rest-test'

testClusters.matching { it.name == "javaRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
}


dependencies {
configurations.javaRestTestRuntimeClasspath {
resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25"
}
configurations.javaRestTestRuntimeOnly {
// This is also required to make resolveAllDependencies work
resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25"
}

/* Since we're a standalone rest test we actually get transitive
* dependencies but we don't really want them because they cause
* all kinds of trouble with the jar hell checks. So we suppress
* them explicitly for non-es projects. */
javaRestTestImplementation(project(':x-pack:plugin:esql:qa:server')) {
transitive = false
}
javaRestTestImplementation project(":test:framework")
javaRestTestRuntimeOnly project(xpackModule('ql:test-fixtures'))

javaRestTestRuntimeOnly "org.slf4j:slf4j-api:1.7.25"
javaRestTestRuntimeOnly "net.sf.supercsv:super-csv:${versions.supercsv}"

javaRestTestImplementation project(path: xpackModule('ql:test-fixtures'))
}
}
}
18 changes: 4 additions & 14 deletions x-pack/plugin/esql/qa/server/heap-attack/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'

dependencies {
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
javaRestTestImplementation project(xpackModule('esql:qa:server'))
}

restResources {
restApi {
include '_common', 'bulk', 'indices', 'esql', 'xpack', 'enrich'
}
}

testClusters.configureEach {
numberOfNodes = 1
testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.monitoring.collection.enabled', 'true'
setting 'xpack.security.enabled', 'false'
tasks.named('javaRestTest') {
usesDefaultDistribution()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.ListMatcher;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -50,6 +53,20 @@
*/
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103527")
public class HeapAttackIT extends ESRestTestCase {

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.nodes(1)
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

/**
* This used to fail, but we've since compacted top n so it actually succeeds now.
*/
Expand Down
16 changes: 4 additions & 12 deletions x-pack/plugin/esql/qa/server/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'

dependencies {
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
javaRestTestImplementation project(xpackModule('esql:qa:server'))
}

restResources {
restApi {
include '_common', 'bulk', 'indices', 'esql', 'xpack'
}
}

testClusters.configureEach {
numberOfNodes = 2
testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.monitoring.collection.enabled', 'true'
setting 'xpack.security.enabled', 'false'
tasks.named('javaRestTest') {
usesDefaultDistribution()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@

package org.elasticsearch.xpack.esql.qa.multi_node;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.ql.CsvSpecReader.CsvTestCase;
import org.junit.ClassRule;

public class EsqlSpecIT extends EsqlSpecTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.nodes(2)
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public EsqlSpecIT(String fileName, String groupName, String testName, Integer lineNumber, CsvTestCase testCase) {
super(fileName, groupName, testName, lineNumber, testCase);
}
Expand Down
17 changes: 11 additions & 6 deletions x-pack/plugin/esql/qa/server/single-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

dependencies {
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
javaRestTestImplementation project(xpackModule('esql:qa:server'))
yamlRestTestImplementation project(xpackModule('esql:qa:server'))
}

Expand All @@ -14,9 +16,12 @@ restResources {
}
}

testClusters.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.monitoring.collection.enabled', 'true'
setting 'xpack.security.enabled', 'false'
tasks.named('javaRestTest') {
usesDefaultDistribution()
maxParallelForks = 1
}

tasks.named('yamlRestTest') {
usesDefaultDistribution()
maxParallelForks = 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.esql.qa.single_node;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;

public class Clusters {
public static ElasticsearchCluster testCluster() {
return ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.nodes(1)
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.shared(true)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@

package org.elasticsearch.xpack.esql.qa.single_node;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;

import org.elasticsearch.test.TestClustersThreadFilter;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.ql.CsvSpecReader.CsvTestCase;
import org.junit.ClassRule;

@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
public class EsqlSpecIT extends EsqlSpecTestCase {
@ClassRule
public static ElasticsearchCluster cluster = Clusters.testCluster();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public EsqlSpecIT(String fileName, String groupName, String testName, Integer lineNumber, CsvTestCase testCase) {
super(fileName, groupName, testName, lineNumber, testCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@

package org.elasticsearch.xpack.esql.qa.single_node;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;

import org.apache.lucene.tests.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.test.TestClustersThreadFilter;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.qa.rest.generative.GenerativeRestTest;
import org.junit.ClassRule;

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/102084")
public class GenerativeIT extends GenerativeRestTest {}
@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
public class GenerativeIT extends GenerativeRestTest {
@ClassRule
public static ElasticsearchCluster cluster = Clusters.testCluster();

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

package org.elasticsearch.xpack.esql.qa.single_node;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;

import org.elasticsearch.test.TestClustersThreadFilter;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.qa.rest.RestEnrichTestCase;
import org.junit.ClassRule;

@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
public class RestEnrichIT extends RestEnrichTestCase {
@ClassRule
public static ElasticsearchCluster cluster = Clusters.testCluster();

public class RestEnrichIT extends RestEnrichTestCase {}
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
*/
package org.elasticsearch.xpack.esql.qa.single_node;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;

import org.apache.http.util.EntityUtils;
import org.elasticsearch.Build;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.TestClustersThreadFilter;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
import org.junit.Assert;
import org.junit.ClassRule;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -23,7 +28,15 @@

import static org.hamcrest.Matchers.containsString;

@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
public class RestEsqlIT extends RestEsqlTestCase {
@ClassRule
public static ElasticsearchCluster cluster = Clusters.testCluster();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public void testBasicEsql() throws IOException {
StringBuilder b = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,30 @@

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;

public class EsqlClientYamlIT extends ESClientYamlSuiteTestCase {

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.nodes(1)
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public EsqlClientYamlIT(final ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
Expand Down

0 comments on commit a6155f8

Please sign in to comment.