mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-21 22:00:36 -04:00
[Test] Separate testAcceptsMismatchedServerlessBuildHash (#122570)
This PR moves TransportServiceHandshakeTests.testAcceptsMismatchedServerlessBuildHash to its own test job to ensure the expected system property is always set correctly. Resolves: #122565
This commit is contained in:
parent
2f4abbf870
commit
2eb0d00b8f
2 changed files with 38 additions and 35 deletions
|
@ -144,18 +144,30 @@ if (buildParams.isSnapshotBuild() == false) {
|
|||
|
||||
tasks.named("test").configure {
|
||||
systemProperty 'es.insecure_network_trace_enabled', 'true'
|
||||
filter {
|
||||
excludeTestsMatching("*.TransportServiceHandshakeTests.testAcceptsMismatchedServerlessBuildHash")
|
||||
}
|
||||
excludes << '**/IndexSettingsOverrideTests.class'
|
||||
}
|
||||
|
||||
TaskProvider<Test> indexSettingsOverrideTest = tasks.register("indexSettingsOverrideTest", Test) {
|
||||
// There are tests rely on system properties to be configured differently. They must run in a separate test job
|
||||
// since the default does not work for them and configuring the system properties inside the test class/method
|
||||
// is too late because fields based on the system properties are often initialized statically.
|
||||
TaskProvider<Test> systemPropertiesOverrideTest = tasks.register("systemPropertiesOverrideTest", Test) {
|
||||
include '**/IndexSettingsOverrideTests.class'
|
||||
include '**/TransportServiceHandshakeTests.class'
|
||||
filter {
|
||||
includeTestsMatching("*.TransportServiceHandshakeTests.testAcceptsMismatchedServerlessBuildHash")
|
||||
includeTestsMatching("*.IndexSettingsOverrideTests.*")
|
||||
}
|
||||
systemProperty 'es.stateless.allow.index.refresh_interval.override', 'true'
|
||||
systemProperty 'es.serverless_transport', 'true'
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
testClassesDirs = sourceSets.test.output.classesDirs
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn(indexSettingsOverrideTest)
|
||||
dependsOn(systemPropertiesOverrideTest)
|
||||
}
|
||||
|
||||
tasks.named("thirdPartyAudit").configure {
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.elasticsearch.common.network.NetworkService;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.PageCacheRecycler;
|
||||
import org.elasticsearch.core.Releasable;
|
||||
import org.elasticsearch.core.SuppressForbidden;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.index.IndexVersion;
|
||||
import org.elasticsearch.index.IndexVersions;
|
||||
|
@ -373,40 +372,32 @@ public class TransportServiceHandshakeTests extends ESTestCase {
|
|||
assertFalse(transportServiceA.nodeConnected(discoveryNode));
|
||||
}
|
||||
|
||||
@SuppressForbidden(reason = "Sets property for testing")
|
||||
public void testAcceptsMismatchedServerlessBuildHash() {
|
||||
assumeTrue("Current build needs to be a snapshot", Build.current().isSnapshot());
|
||||
assumeTrue("Security manager needs to be disabled", System.getSecurityManager() == null);
|
||||
System.setProperty(TransportService.SERVERLESS_TRANSPORT_SYSTEM_PROPERTY, Boolean.TRUE.toString()); // security manager blocks
|
||||
// this
|
||||
try {
|
||||
final DisruptingTransportInterceptor transportInterceptorA = new DisruptingTransportInterceptor();
|
||||
final DisruptingTransportInterceptor transportInterceptorB = new DisruptingTransportInterceptor();
|
||||
transportInterceptorA.setModifyBuildHash(true);
|
||||
transportInterceptorB.setModifyBuildHash(true);
|
||||
final Settings settings = Settings.builder()
|
||||
.put("cluster.name", "a")
|
||||
.put(IGNORE_DESERIALIZATION_ERRORS_SETTING.getKey(), true) // suppress assertions to test production error-handling
|
||||
.build();
|
||||
final TransportService transportServiceA = startServices(
|
||||
"TS_A",
|
||||
settings,
|
||||
TransportVersion.current(),
|
||||
VersionInformation.CURRENT,
|
||||
transportInterceptorA
|
||||
);
|
||||
final TransportService transportServiceB = startServices(
|
||||
"TS_B",
|
||||
settings,
|
||||
TransportVersion.current(),
|
||||
VersionInformation.CURRENT,
|
||||
transportInterceptorB
|
||||
);
|
||||
AbstractSimpleTransportTestCase.connectToNode(transportServiceA, transportServiceB.getLocalNode(), TestProfiles.LIGHT_PROFILE);
|
||||
assertTrue(transportServiceA.nodeConnected(transportServiceB.getLocalNode()));
|
||||
} finally {
|
||||
System.clearProperty(TransportService.SERVERLESS_TRANSPORT_SYSTEM_PROPERTY);
|
||||
}
|
||||
final DisruptingTransportInterceptor transportInterceptorA = new DisruptingTransportInterceptor();
|
||||
final DisruptingTransportInterceptor transportInterceptorB = new DisruptingTransportInterceptor();
|
||||
transportInterceptorA.setModifyBuildHash(true);
|
||||
transportInterceptorB.setModifyBuildHash(true);
|
||||
final Settings settings = Settings.builder()
|
||||
.put("cluster.name", "a")
|
||||
.put(IGNORE_DESERIALIZATION_ERRORS_SETTING.getKey(), true) // suppress assertions to test production error-handling
|
||||
.build();
|
||||
final TransportService transportServiceA = startServices(
|
||||
"TS_A",
|
||||
settings,
|
||||
TransportVersion.current(),
|
||||
VersionInformation.CURRENT,
|
||||
transportInterceptorA
|
||||
);
|
||||
final TransportService transportServiceB = startServices(
|
||||
"TS_B",
|
||||
settings,
|
||||
TransportVersion.current(),
|
||||
VersionInformation.CURRENT,
|
||||
transportInterceptorB
|
||||
);
|
||||
AbstractSimpleTransportTestCase.connectToNode(transportServiceA, transportServiceB.getLocalNode(), TestProfiles.LIGHT_PROFILE);
|
||||
assertTrue(transportServiceA.nodeConnected(transportServiceB.getLocalNode()));
|
||||
}
|
||||
|
||||
public void testAcceptsMismatchedBuildHashFromDifferentVersion() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue