-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Move systemPropertiesOverrideTest to separate source set
#137492
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
Merged
DaveCTurner
merged 3 commits into
elastic:main
from
DaveCTurner:2025/11/02/system-properties-override-tests-source-set
Nov 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import org.apache.tools.ant.filters.ReplaceTokens | ||
|
|
||
| apply plugin: 'elasticsearch.build' | ||
|
|
||
| dependencies { | ||
| testImplementation project(':test:framework') | ||
| testImplementation project(':server') | ||
| } | ||
|
|
||
| tasks.named("test").configure { | ||
| systemProperty 'es.stateless.allow.index.refresh_interval.override', 'true' | ||
| // systemProperty 'es.serverless_transport', 'true' | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...operties/src/test/java/org/elasticsearch/transport/ServerlessTransportHandshakeTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.transport; | ||
|
|
||
| import org.elasticsearch.Build; | ||
| import org.elasticsearch.TransportVersion; | ||
| import org.elasticsearch.cluster.node.DiscoveryNodeUtils; | ||
| import org.elasticsearch.cluster.node.VersionInformation; | ||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.network.NetworkService; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.util.PageCacheRecycler; | ||
| import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; | ||
| import org.elasticsearch.test.ESTestCase; | ||
| import org.elasticsearch.test.transport.MockTransportService; | ||
| import org.elasticsearch.threadpool.TestThreadPool; | ||
| import org.elasticsearch.threadpool.ThreadPool; | ||
| import org.elasticsearch.transport.netty4.Netty4Transport; | ||
| import org.elasticsearch.transport.netty4.SharedGroupFactory; | ||
| import org.junit.After; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import static java.util.Collections.emptySet; | ||
| import static org.elasticsearch.transport.AbstractSimpleTransportTestCase.IGNORE_DESERIALIZATION_ERRORS_SETTING; | ||
|
|
||
| public class ServerlessTransportHandshakeTests extends ESTestCase { | ||
|
|
||
| private static ThreadPool threadPool; | ||
|
|
||
| @BeforeClass | ||
| public static void startThreadPool() { | ||
| threadPool = new TestThreadPool(ServerlessTransportHandshakeTests.class.getSimpleName()); | ||
| } | ||
|
|
||
| private final List<TransportService> transportServices = new ArrayList<>(); | ||
|
|
||
| private TransportService startServices(String nodeNameAndId, Settings settings, TransportInterceptor transportInterceptor) { | ||
| TcpTransport transport = new Netty4Transport( | ||
| settings, | ||
| TransportVersion.current(), | ||
| threadPool, | ||
| new NetworkService(Collections.emptyList()), | ||
| PageCacheRecycler.NON_RECYCLING_INSTANCE, | ||
| new NamedWriteableRegistry(Collections.emptyList()), | ||
| new NoneCircuitBreakerService(), | ||
| new SharedGroupFactory(settings) | ||
| ); | ||
| TransportService transportService = new MockTransportService( | ||
| settings, | ||
| transport, | ||
| threadPool, | ||
| transportInterceptor, | ||
| (boundAddress) -> DiscoveryNodeUtils.builder(nodeNameAndId) | ||
| .name(nodeNameAndId) | ||
| .address(boundAddress.publishAddress()) | ||
| .roles(emptySet()) | ||
| .version(VersionInformation.CURRENT) | ||
| .build(), | ||
| null, | ||
| Collections.emptySet(), | ||
| nodeNameAndId | ||
| ); | ||
| transportService.start(); | ||
| transportService.acceptIncomingRequests(); | ||
| transportServices.add(transportService); | ||
| return transportService; | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() throws Exception { | ||
| for (TransportService transportService : transportServices) { | ||
| transportService.close(); | ||
| } | ||
| super.tearDown(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void terminateThreadPool() { | ||
| ThreadPool.terminate(threadPool, 30, TimeUnit.SECONDS); | ||
| // since static must set to null to be eligible for collection | ||
| threadPool = null; | ||
| } | ||
|
|
||
| public void testAcceptsMismatchedServerlessBuildHash() { | ||
| assumeTrue("Current build needs to be a snapshot", Build.current().isSnapshot()); | ||
| final var transportInterceptorA = new BuildHashModifyingTransportInterceptor(); | ||
| final var transportInterceptorB = new BuildHashModifyingTransportInterceptor(); | ||
| 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, transportInterceptorA); | ||
| final TransportService transportServiceB = startServices("TS_B", settings, transportInterceptorB); | ||
| AbstractSimpleTransportTestCase.connectToNode(transportServiceA, transportServiceB.getLocalNode(), TestProfiles.LIGHT_PROFILE); | ||
| assertTrue(transportServiceA.nodeConnected(transportServiceB.getLocalNode())); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ork/src/main/java/org/elasticsearch/transport/BuildHashModifyingTransportInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.transport; | ||
|
|
||
| import org.elasticsearch.test.ESTestCase; | ||
|
|
||
| import java.util.concurrent.Executor; | ||
|
|
||
| import static org.hamcrest.Matchers.instanceOf; | ||
|
|
||
| class BuildHashModifyingTransportInterceptor implements TransportInterceptor { | ||
|
|
||
| @Override | ||
| public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler( | ||
| String action, | ||
| Executor executor, | ||
| boolean forceExecution, | ||
| TransportRequestHandler<T> actualHandler | ||
| ) { | ||
|
|
||
| if (TransportService.HANDSHAKE_ACTION_NAME.equals(action)) { | ||
| return (request, channel, task) -> actualHandler.messageReceived(request, new TransportChannel() { | ||
| @Override | ||
| public String getProfileName() { | ||
| return channel.getProfileName(); | ||
| } | ||
|
|
||
| @Override | ||
| public void sendResponse(TransportResponse response) { | ||
| ESTestCase.assertThat(response, instanceOf(TransportService.HandshakeResponse.class)); | ||
| final TransportService.HandshakeResponse handshakeResponse = (TransportService.HandshakeResponse) response; | ||
| channel.sendResponse( | ||
| new TransportService.HandshakeResponse( | ||
| handshakeResponse.getVersion(), | ||
| handshakeResponse.getBuildHash() + "-modified", | ||
| handshakeResponse.getDiscoveryNode(), | ||
| handshakeResponse.getClusterName() | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void sendResponse(Exception exception) { | ||
| channel.sendResponse(exception); | ||
|
|
||
| } | ||
| }, task); | ||
| } else { | ||
| return actualHandler; | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need this, right? I wonder why the CI didn't fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm that's a good point - I commented that out for a test but then forgot I'd done so. CI passes because we weakened this to a warning in #128589 but did not adjust the
es.serverless_transporttest to assert the lack of a warning. Fixed in 7c9ffc2.