Skip to content

Commit 51009b7

Browse files
enabled mockTelemetryPlugin for IT and fixed OOM (opensearch-project#13054)
* Disable stackTrace in MockSpanData by default Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * enabled MockTelemetryPlugin for ITs Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * Added the flag as system property Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * Applied java spotless check Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * Added details in changelog Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * Added details in TESTING.md Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> * Update TESTING.md Signed-off-by: Atharva Sharma <60044988+atharvasharma61@users.noreply.github.com> --------- Signed-off-by: Atharva Sharma <atharvasharma61@gmail.com> Signed-off-by: Atharva Sharma <60044988+atharvasharma61@users.noreply.github.com>
1 parent 9c35a84 commit 51009b7

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5555
- Fix issue with feature flags where default value may not be honored ([#12849](https://github.com/opensearch-project/OpenSearch/pull/12849))
5656
- Fix UOE While building Exists query for nested search_as_you_type field ([#12048](https://github.com/opensearch-project/OpenSearch/pull/12048))
5757
- Client with Java 8 runtime and Apache HttpClient 5 Transport fails with java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer ([#13100](https://github.com/opensearch-project/opensearch-java/pull/13100))
58+
- Enabled mockTelemetryPlugin for IT and fixed OOM issues ([#13054](https://github.com/opensearch-project/OpenSearch/pull/13054))
5859
- Fix implement mark() and markSupported() in class FilterStreamInput ([#13098](https://github.com/opensearch-project/OpenSearch/pull/13098))
5960
- Fix snapshot _status API to return correct status for partial snapshots ([#12812](https://github.com/opensearch-project/OpenSearch/pull/12812))
6061

TESTING.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ This will instruct all JVMs (including any that run cli tools such as creating t
8484
- In order to remotely attach a debugger to the process: `--debug-jvm`
8585
- In order to set a different keystore password: `--keystore-password yourpassword`
8686
- In order to set an OpenSearch setting, provide a setting with the following prefix: `-Dtests.opensearch.`
87+
- In order to enable stack trace of the MockSpanData during testing, add: `-Dtests.telemetry.span.stack_traces=true` (Storing stack traces alongside span data can be useful for comprehensive debugging and performance optimization during testing, as it provides insights into the exact code paths and execution sequences, facilitating efficient issue identification and resolution. Note: Enabling this might lead to OOM issues while running ITs)
8788

8889
## Test case filtering
8990

@@ -412,8 +413,8 @@ Say you need to make a change to `main` and have a BWC layer in `5.x`. You will
412413
You may want to run BWC tests for a secure OpenSearch cluster. In order to do this, you will need to follow a few additional steps:
413414

414415
1. Clone the OpenSearch Security repository from https://github.com/opensearch-project/security.
415-
2. Get both the old version of the Security plugin (the version you wish to come from) and the new version of the Security plugin (the version you wish to go to). This can be done either by fetching the maven artifact with a command like `wget https://repo1.maven.org/maven2/org/opensearch/plugin/opensearch-security/<TARGET_VERSION>.0/opensearch-security-<TARGET_VERSION>.0.zip` or by running `./gradlew assemble` from the base of the Security repository.
416-
3. Move both of the Security artifacts into new directories at the path `/security/bwc-test/src/test/resources/<TARGET_VERSION>.0`. You should end up with two different directories in `/security/bwc-test/src/test/resources/`, one named the old version and one the new version.
416+
2. Get both the old version of the Security plugin (the version you wish to come from) and the new version of the Security plugin (the version you wish to go to). This can be done either by fetching the maven artifact with a command like `wget https://repo1.maven.org/maven2/org/opensearch/plugin/opensearch-security/<TARGET_VERSION>.0/opensearch-security-<TARGET_VERSION>.0.zip` or by running `./gradlew assemble` from the base of the Security repository.
417+
3. Move both of the Security artifacts into new directories at the path `/security/bwc-test/src/test/resources/<TARGET_VERSION>.0`. You should end up with two different directories in `/security/bwc-test/src/test/resources/`, one named the old version and one the new version.
417418
4. Run the following command from the base of the Security repository:
418419

419420
```
@@ -428,7 +429,7 @@ You may want to run BWC tests for a secure OpenSearch cluster. In order to do th
428429

429430
`-Dtests.security.manager=false` handles access issues when attempting to read the certificates from the file system.
430431
`-Dtests.opensearch.http.protocol=https` tells the wait for cluster startup task to do the right thing.
431-
`-PcustomDistributionUrl=...` uses a custom build of the distribution of OpenSearch. This is unnecessary when running against standard/unmodified OpenSearch core distributions.
432+
`-PcustomDistributionUrl=...` uses a custom build of the distribution of OpenSearch. This is unnecessary when running against standard/unmodified OpenSearch core distributions.
432433

433434
### Skip fetching latest
434435

test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2096,8 +2096,7 @@ protected boolean addMockGeoShapeFieldMapper() {
20962096
* @return boolean.
20972097
*/
20982098
protected boolean addMockTelemetryPlugin() {
2099-
// setting to false until https://github.com/opensearch-project/OpenSearch/issues/12615 is resolved
2100-
return false;
2099+
return true;
21012100
}
21022101

21032102
/**

test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/StrictCheckSpanProcessor.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package org.opensearch.test.telemetry.tracing;
1010

11+
import org.opensearch.common.Booleans;
1112
import org.opensearch.telemetry.tracing.Span;
1213
import org.opensearch.test.telemetry.tracing.validators.AllSpansAreEndedProperly;
1314
import org.opensearch.test.telemetry.tracing.validators.AllSpansHaveUniqueId;
@@ -29,6 +30,14 @@ public StrictCheckSpanProcessor() {}
2930

3031
private static Map<String, MockSpanData> spanMap = new ConcurrentHashMap<>();
3132

33+
// If you want to see the stack trace for each spanData, then
34+
// update the flag to true or set the corresponding system property to true
35+
// This is helpful in debugging the tests. Default value is false.
36+
// Note: Enabling this might lead to OOM issues while running ITs.
37+
private static final boolean isStackTraceForSpanEnabled = Booleans.parseBoolean(
38+
System.getProperty("tests.telemetry.span.stack_traces", "false")
39+
);
40+
3241
@Override
3342
public void onStart(Span span) {
3443
spanMap.put(span.getSpanId(), toMockSpanData(span));
@@ -53,14 +62,15 @@ public List<MockSpanData> getFinishedSpanItems() {
5362

5463
private MockSpanData toMockSpanData(Span span) {
5564
String parentSpanId = (span.getParentSpan() != null) ? span.getParentSpan().getSpanId() : "";
65+
StackTraceElement[] stackTrace = isStackTraceForSpanEnabled ? Thread.currentThread().getStackTrace() : null;
5666
MockSpanData spanData = new MockSpanData(
5767
span.getSpanId(),
5868
parentSpanId,
5969
span.getTraceId(),
6070
System.nanoTime(),
6171
false,
6272
span.getSpanName(),
63-
Thread.currentThread().getStackTrace(),
73+
stackTrace,
6474
(span instanceof MockSpan) ? ((MockSpan) span).getAttributes() : Map.of()
6575
);
6676
return spanData;

0 commit comments

Comments
 (0)