Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:async-search:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:autoscaling:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:downgrade-to-basic-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:multi-cluster");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:non-compliant-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:restart");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security");
Expand Down
68 changes: 45 additions & 23 deletions x-pack/plugin/ccr/build.gradle
Original file line number Diff line number Diff line change
@@ -1,46 +1,68 @@
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'

esplugin {
name = 'x-pack-ccr'
description = 'Elasticsearch Expanded Pack Plugin - CCR'
classname ='org.elasticsearch.xpack.ccr.Ccr'
hasNativeController =false
requiresKeystore =true
classname = 'org.elasticsearch.xpack.ccr.Ccr'
hasNativeController = false
requiresKeystore = true
extendedPlugins = ['x-pack-core']
}

base {
archivesName = 'x-pack-ccr'
}

// Integration Test classes that cannot run with the security manager
String[] noSecurityManagerITClasses = ["**/CloseFollowerIndexIT.class"]
dependencies {
compileOnly project(":server")

tasks.register('internalClusterTestNoSecurityManager', Test) {
testClassesDirs = sourceSets.internalClusterTest.output.classesDirs
classpath = sourceSets.internalClusterTest.runtimeClasspath
include noSecurityManagerITClasses
systemProperty 'tests.security.manager', 'false'
compileOnly project(path: xpackModule('core'))
testImplementation(testArtifact(project(xpackModule('core'))))
testImplementation(testArtifact(project(xpackModule('monitoring'))))
testImplementation(project(":modules:analysis-common"))
testImplementation(project(":modules:data-streams"))
javaRestTestImplementation(testImplementation(testArtifact(project(xpackModule('core')))))

clusterModules project(":modules:analysis-common")
clusterModules project(":modules:mapper-extras")
clusterModules project(":modules:data-streams")
clusterModules project(":modules:ingest-common")
clusterModules project(xpackModule("monitoring"))
clusterModules project(xpackModule("ilm"))
clusterModules project(xpackModule("wildcard"))
clusterModules project(xpackModule("stack"))
clusterModules project(xpackModule("mapper-constant-keyword"))
clusterModules project(xpackModule("searchable-snapshots"))
}
tasks.named("check").configure { dependsOn 'internalClusterTestNoSecurityManager' }

tasks.named('internalClusterTest').configure {
exclude noSecurityManagerITClasses
restResources {
restApi {
include '_common', 'cluster', 'nodes', 'indices', 'index', 'info', 'ccr'
}
}

tasks.named('internalClusterTestTestingConventions').configure {
tasks.named('internalClusterTest') {
systemProperty 'tests.security.manager', 'false'
}

tasks.named('internalClusterTestTestingConventions') {
baseClass 'org.elasticsearch.xpack.CcrIntegTestCase'
baseClass 'org.elasticsearch.xpack.CcrSingleNodeTestCase'
baseClass 'org.elasticsearch.test.ESIntegTestCase'
}

addQaCheckDependencies(project)

dependencies {
compileOnly project(":server")
tasks.named("yamlRestTest") {
usesDefaultDistribution("uses _xpack info api")
}

compileOnly project(path: xpackModule('core'))
testImplementation(testArtifact(project(xpackModule('core'))))
testImplementation(testArtifact(project(xpackModule('monitoring'))))
testImplementation(project(":modules:analysis-common"))
testImplementation(project(":modules:data-streams"))
tasks.withType(StandaloneRestIntegTestTask).configureEach {
// These fail in CI but only when run as part of checkPart2 and not individually.
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
buildParams.withFipsEnabledOnly(it)
}
7 changes: 6 additions & 1 deletion x-pack/plugin/ccr/qa/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import org.elasticsearch.gradle.internal.info.BuildParams
/*
* 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.
*/

apply plugin: 'elasticsearch.java'

Expand Down
78 changes: 0 additions & 78 deletions x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle

This file was deleted.

121 changes: 15 additions & 106 deletions x-pack/plugin/ccr/qa/multi-cluster/build.gradle
Original file line number Diff line number Diff line change
@@ -1,111 +1,20 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.TestClusterValueSource
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.elasticsearch.gradle.testclusters.TestClustersRegistry
import org.elasticsearch.gradle.util.GradleUtils

import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
/*
* 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.
*/
apply plugin: 'elasticsearch.internal-java-rest-test'

dependencies {
testImplementation(testArtifact(project(xpackModule('core'))))
testImplementation project(xpackModule('ccr'))
testImplementation project(':x-pack:plugin:ccr:qa')
}

def clusterPath = getPath()
def leaderCluster = testClusters.register('leader-cluster') {
testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'path.repo', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
}

def middleCluster = testClusters.register('middle-cluster') {
testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'

Provider<TestClustersRegistry> serviceProvider = GradleUtils.getBuildService(
project.gradle.sharedServices,
TestClustersPlugin.REGISTRY_SERVICE_NAME
)
def leaderInfo = project.getProviders().of(TestClusterValueSource.class) {
it.parameters.path.set(clusterPath)
it.parameters.clusterName.set("leader-cluster")
it.parameters.service = serviceProvider
}
def leaderUris = leaderInfo.map { it.getAllTransportPortURI() }
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderUris.get().join(",")}\"" }, IGNORE_VALUE
}

tasks.register("leader-cluster", RestIntegTestTask) {
mustRunAfter("precommit")
systemProperty 'tests.target_cluster', 'leader'
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
}

tasks.register("middle-cluster", RestIntegTestTask) {
dependsOn "leader-cluster"
useCluster testClusters.named("leader-cluster")
systemProperty 'tests.target_cluster', 'middle'
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"

def leaderUri = getClusterInfo('leader-cluster').map { it.allHttpSocketURI.get(0) }
nonInputProperties.systemProperty 'tests.leader_host', leaderUri
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
javaRestTestImplementation(testArtifact(project(xpackModule('ccr')), 'javaRestTest'))
javaRestTestImplementation project(xpackModule('ccr'))
}

tasks.register('follow-cluster', RestIntegTestTask) {
dependsOn "leader-cluster", "middle-cluster"
useCluster leaderCluster
useCluster middleCluster
systemProperty 'tests.target_cluster', 'follow'
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"

def leaderUri = getClusterInfo('leader-cluster').map { it.allHttpSocketURI.get(0) }
def middleUri = getClusterInfo('middle-cluster').map { it.allHttpSocketURI.get(0) }
nonInputProperties.systemProperty 'tests.leader_host', leaderUri
nonInputProperties.systemProperty 'tests.middle_host', middleUri
tasks.named("javaRestTest") {
usesDefaultDistribution("uses _xpack usage api")
// These fail in CI but only when run as part of checkPart2 and not individually.
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
buildParams.withFipsEnabledOnly(it)
}

testClusters.matching { it.name == "follow-cluster" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.monitoring.collection.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'

Provider<TestClustersRegistry> serviceProvider = GradleUtils.getBuildService(
project.gradle.sharedServices,
TestClustersPlugin.REGISTRY_SERVICE_NAME
)
def leaderUris = project.getProviders().of(TestClusterValueSource.class) {
it.parameters.path.set(clusterPath)
it.parameters.clusterName.set("leader-cluster")
it.parameters.service = serviceProvider
}.map { it.getAllTransportPortURI() }

def middleUris = project.getProviders().of(TestClusterValueSource.class) {
it.parameters.path.set(clusterPath)
it.parameters.clusterName.set("middle-cluster")
it.parameters.service = serviceProvider
}.map { it.getAllTransportPortURI() }

setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderUris.get().join(",")}\"" }, IGNORE_VALUE
setting 'cluster.remote.middle_cluster.seeds',
{ "\"${middleUris.get().join(",")}\"" }, IGNORE_VALUE
}


testClusters.configureEach {
requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0")
}

tasks.named("check").configure { dependsOn "follow-cluster" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
*/
package org.elasticsearch.xpack.ccr;

import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.xcontent.ObjectPath;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;

import java.io.IOException;
import java.util.Map;
Expand All @@ -20,10 +28,45 @@
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.nullValue;

public class XPackUsageIT extends ESCCRRestTestCase {
public class XPackUsageIT extends AbstractCCRRestTestCase {

public static LocalClusterConfigProvider commonConfig = c -> c.distribution(DistributionType.DEFAULT)
.setting("xpack.security.enabled", "true")
.setting("xpack.license.self_generated.type", "trial")
.user("admin", "admin-password", "superuser", false);

public static ElasticsearchCluster leaderCluster = ElasticsearchCluster.local().name("leader-cluster").apply(commonConfig).build();

public static ElasticsearchCluster followerCluster = ElasticsearchCluster.local()
.name("follow-cluster")
.apply(commonConfig)
.setting("cluster.remote.leader_cluster.seeds", () -> "\"" + leaderCluster.getTransportEndpoints() + "\"")
.build();

@ClassRule
public static RuleChain ruleChain = RuleChain.outerRule(leaderCluster).around(followerCluster);

public XPackUsageIT(@Name("targetCluster") TargetCluster targetCluster) {
super(targetCluster);
}

@ParametersFactory
public static Iterable<Object[]> parameters() throws Exception {
return leaderFollower();
}

@Override
protected ElasticsearchCluster getLeaderCluster() {
return leaderCluster;
}

@Override
protected ElasticsearchCluster getFollowerCluster() {
return followerCluster;
}

public void testXPackCcrUsage() throws Exception {
if ("follow".equals(targetCluster) == false) {
if (targetCluster != TargetCluster.FOLLOWER) {
logger.info("skipping test, waiting for target cluster [follow]");
return;
}
Expand Down
Loading