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

[8.x] [Test] Separate testAcceptsMismatchedServerlessBuildHash (#122570) #123485

Merged
merged 1 commit into from
Feb 26, 2025
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
16 changes: 14 additions & 2 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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;
Expand Down Expand Up @@ -373,40 +372,32 @@ public void testRejectsMismatchedBuildHash() {
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() {
Expand Down