allthingssecurity commented on code in PR #30313:
URL: https://github.com/apache/camel/pull/30313#discussion_r4612021336


##########
core/camel-management/src/test/java/org/apache/camel/management/BacklogDebuggerStepIntoSuspendedNodeTest.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.management;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.BacklogDebugger;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * An exchange that is single-stepped into a node where another exchange is 
suspended by a node breakpoint does not
+ * replace that exchange: it suspends at the node once the other exchange 
continues.
+ */
+@DisabledOnOs(OS.AIX)
+public class BacklogDebuggerStepIntoSuspendedNodeTest extends 
ManagementTestSupport {
+
+    private BacklogDebugger debugger;
+
+    @Override
+    @BeforeEach
+    public void setUp() throws Exception {
+        super.setUp();
+        debugger = context.hasService(BacklogDebugger.class);
+        debugger.enableDebugger();
+        // the exchanges of a failed test continue after this, not after the 
default 300 seconds
+        debugger.setFallbackTimeout(20);
+    }
+
+    @AfterEach
+    void resumeAll() {
+        if (debugger != null) {
+            debugger.resumeAll();
+        }
+    }
+
+    @Test
+    public void testStepIntoNodeWithSuspendedExchange() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Second", "First");
+
+        // the second exchange is suspended at bar by its node breakpoint
+        debugger.addBreakpoint("bar");
+        template.sendBody("seda:start", "Second");
+        await().atMost(5, TimeUnit.SECONDS)
+                .untilAsserted(() -> assertEquals(Set.of("bar"), 
debugger.getSuspendedBreakpointNodeIds()));
+        String second = debugger.getSuspendedExchangeIds().iterator().next();
+
+        // the first exchange is suspended at foo, and is single-stepped from 
there into bar
+        debugger.addBreakpoint("foo");
+        template.sendBody("seda:start", "First");
+        await().atMost(5, TimeUnit.SECONDS)
+                .untilAsserted(() -> assertEquals(Set.of("foo", "bar"), 
debugger.getSuspendedBreakpointNodeIds()));
+        String first = debugger.getSuspendedExchangeIds().stream().filter(id 
-> !id.equals(second)).findFirst()
+                .orElseThrow();
+        long counter = debugger.getDebugCounter();
+        debugger.stepBreakpoint("foo");
+
+        // the step of the first exchange reaches bar (it counts a message 
there)
+        await().atMost(5, TimeUnit.SECONDS).until(() -> 
debugger.getDebugCounter() > counter);
+
+        // the debugger still shows the second exchange suspended at bar
+        await().during(500, TimeUnit.MILLISECONDS).atMost(2, 
TimeUnit.SECONDS).untilAsserted(() -> {
+            assertEquals(Set.of(second), debugger.getSuspendedExchangeIds());
+            String dump = debugger.dumpTracedMessagesAsXml("bar");
+            assertTrue(dump.contains(second), dump);
+            assertTrue(dump.contains("Second"), dump);
+        });
+

Review Comment:
   Done in a1968e0: the check that the first exchange is suspended at bar now 
also asserts that the dump contains `First`, here and in the `stepBreakpoint()` 
test. The debugger and backlog tests of camel-management pass (52 run, 0 
failures).
   
   _Claude Code on behalf of allthingssecurity_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to