Skip to content

Commit 7573a5f

Browse files
Fix race condition for Failed Test Replay (#10679)
fix: flakiness in junit console FTR test chore: update comment Merge branch 'master' into daniel.mohedano/junit-console-flaky-fix fix: also update flush interval fix: update approach to requeue feat: reduce catch scope to assertionerror Co-authored-by: daniel.mohedano <daniel.mohedano@datadoghq.com>
1 parent 6c468be commit 7573a5f

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/DebuggerSink.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public void start() {
9292
}
9393

9494
public void stop() {
95-
lowRateFlush(this);
96-
snapshotSink.highRateFlush(null);
9795
cancelSchedule(this.flushIntervalScheduled);
9896
cancelSchedule(this.lowRateScheduled);
97+
lowRateFlush(this);
98+
snapshotSink.highRateFlush(null);
9999
probeStatusSink.stop();
100100
symbolSink.stop();
101101
snapshotSink.stop();

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/SnapshotSink.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ private List<String> getSerializedSnapshots(BlockingQueue<Snapshot> queue, int l
186186
if (!largeBatch) {
187187
LOGGER.debug("Sending snapshot for probe: {}", snapshot.getProbe().getId());
188188
}
189+
} catch (AssertionError e) {
190+
// Re-queue on AssertionError from Moshi when thread is interrupted so the shutdown hook
191+
// flush can retry with a non-interrupted thread
192+
ExceptionHelper.logException(LOGGER, e, "Error during snapshot serialization:");
193+
queue.offer(snapshot);
189194
} catch (Exception e) {
190195
ExceptionHelper.logException(LOGGER, e, "Error during snapshot serialization:");
191196
}

dd-smoke-tests/backend-mock/src/main/groovy/datadog/smoketest/MockBackend.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class MockBackend implements AutoCloseable {
433433
}
434434

435435
List<Map<String, Object>> waitForLogs(int expectedCount) {
436-
def traceReceiveConditions = new PollingConditions(timeout: 15, initialDelay: 1, delay: 0.5, factor: 1)
436+
def traceReceiveConditions = new PollingConditions(timeout: 30, initialDelay: 1, delay: 0.5, factor: 1)
437437
traceReceiveConditions.eventually {
438438
assert receivedLogs.size() == expectedCount
439439
}

dd-smoke-tests/junit-console/src/test/groovy/datadog/smoketest/JUnitConsoleSmokeTest.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package datadog.smoketest
22

33

44
import datadog.trace.api.config.CiVisibilityConfig
5+
import datadog.trace.api.config.DebuggerConfig
56
import datadog.trace.api.config.GeneralConfig
67
import datadog.trace.civisibility.CiVisibilitySmokeTest
78
import java.nio.file.FileVisitResult
@@ -52,7 +53,8 @@ class JUnitConsoleSmokeTest extends CiVisibilitySmokeTest {
5253

5354
def exitCode = whenRunningJUnitConsole([
5455
(CiVisibilityConfig.CIVISIBILITY_FLAKY_RETRY_COUNT): "3",
55-
(GeneralConfig.AGENTLESS_LOG_SUBMISSION_URL): mockBackend.intakeUrl
56+
(GeneralConfig.AGENTLESS_LOG_SUBMISSION_URL): mockBackend.intakeUrl,
57+
(DebuggerConfig.DYNAMIC_INSTRUMENTATION_UPLOAD_FLUSH_INTERVAL): "999999" // avoid possible race conditions on shutdown
5658
],
5759
[:])
5860
assert exitCode == 1

0 commit comments

Comments
 (0)