Skip to content

Commit 50af5cc

Browse files
committed
enable logging for testing
1 parent d745321 commit 50af5cc

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ jobs:
5757
java-version: ${{ matrix.java }}
5858
cache: maven
5959

60-
- name: Build and test
61-
run: mvn -B install --file pom.xml
60+
- name: Build
61+
run: mvn -B install --file pom.xml -DskipTests
62+
- name: Test
63+
run: mvn -B test --file pom.xml -X -Dtest=DurableContextTest -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG

sdk/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
<artifactId>mockito-core</artifactId>
5757
<scope>test</scope>
5858
</dependency>
59+
<dependency>
60+
<groupId>org.slf4j</groupId>
61+
<artifactId>slf4j-simple</artifactId>
62+
<version>${slf4j.version}</version>
63+
<scope>test</scope>
64+
</dependency>
5965
</dependencies>
6066

6167
<build>

sdk/src/main/java/com/amazonaws/lambda/durable/operation/BaseDurableOperation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private void validateCurrentThreadType() {
135135
protected Operation waitForOperationCompletion() {
136136

137137
validateCurrentThreadType();
138+
logger.info("Start waiting for operation to finish {} (Phaser: {})", getOperationId(), phaser);
138139

139140
// register to prevent the state from advancing
140141
phaser.register();
@@ -147,14 +148,14 @@ protected Operation waitForOperationCompletion() {
147148
// Operation not done yet
148149
var context = executionManager.getCurrentContext();
149150
// Deregister current context - allows suspension
150-
logger.debug(
151+
logger.info(
151152
"get() on {} attempting to deregister context: {}",
152153
getType(),
153154
executionManager.getCurrentContext().contextId());
154155
deregisterActiveThreadAndUnsetCurrentContext(context.contextId());
155156

156157
// Block until operation completes
157-
logger.trace("Waiting for operation to finish {} (Phaser: {})", getOperationId(), phaser);
158+
logger.info("Waiting for operation to finish {} (Phaser: {})", getOperationId(), phaser);
158159
phaser.arriveAndAwaitAdvance();
159160

160161
// Reactivate current context

sdk/src/test/java/com/amazonaws/lambda/durable/DurableContextTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
import java.time.Duration;
1111
import java.util.List;
1212
import org.junit.jupiter.api.Test;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
1315
import software.amazon.awssdk.services.lambda.model.*;
1416

1517
class DurableContextTest {
18+
private static final Logger logger = LoggerFactory.getLogger(DurableContextTest.class);
1619

1720
private DurableContext createTestContext() {
1821
var executionOp = Operation.builder()
@@ -39,6 +42,7 @@ private DurableContext createTestContext(List<Operation> initialOperations) {
3942

4043
@Test
4144
void testContextCreation() {
45+
logger.info("testContextCreation");
4246
var context = createTestContext();
4347

4448
assertNotNull(context);
@@ -47,6 +51,7 @@ void testContextCreation() {
4751

4852
@Test
4953
void testGetExecutionContext() {
54+
logger.info("testGetExecutionContext");
5055
var context = createTestContext();
5156

5257
var executionContext = context.getExecutionContext();
@@ -61,6 +66,7 @@ void testGetExecutionContext() {
6166

6267
@Test
6368
void testStepExecution() {
69+
logger.info("testStepExecution");
6470
var context = createTestContext();
6571

6672
var result = context.step("test", String.class, () -> "Hello World");
@@ -70,6 +76,7 @@ void testStepExecution() {
7076

7177
@Test
7278
void testStepReplay() {
79+
logger.info("testStepReplay");
7380
// Create context with existing operation
7481
var existingOp = Operation.builder()
7582
.id("1")
@@ -86,6 +93,7 @@ void testStepReplay() {
8693

8794
@Test
8895
void testStepAsync() throws Exception {
96+
logger.info("testStepAsync");
8997
var context = createTestContext();
9098

9199
var future = context.stepAsync("async-test", String.class, () -> "Async Result");
@@ -96,6 +104,7 @@ void testStepAsync() throws Exception {
96104

97105
@Test
98106
void testStepAsyncReplay() throws Exception {
107+
logger.info("testStepAsyncReplay");
99108
// Create context with existing operation
100109
var existingOp = Operation.builder()
101110
.id("1")
@@ -112,6 +121,7 @@ void testStepAsyncReplay() throws Exception {
112121

113122
@Test
114123
void testWait() {
124+
logger.info("testWait");
115125
var context = createTestContext();
116126

117127
// Wait should throw SuspendExecutionException
@@ -122,6 +132,7 @@ void testWait() {
122132

123133
@Test
124134
void testWaitReplay() {
135+
logger.info("testWaitReplay");
125136
// Create context with completed wait operation
126137
var existingOp =
127138
Operation.builder().id("1").status(OperationStatus.SUCCEEDED).build();
@@ -135,24 +146,29 @@ void testWaitReplay() {
135146

136147
@Test
137148
void testCombinedSyncAsyncWait() throws Exception {
149+
logger.info("testCombinedSyncAsyncWait");
138150
var context = createTestContext();
139151

140152
// Execute sync step
141153
var syncResult = context.step("sync-step", String.class, () -> "Sync Done");
142154
assertEquals("Sync Done", syncResult);
155+
logger.info("testCombinedSyncAsyncWait - Sync Done");
143156

144157
// Execute async step
145158
var asyncFuture = context.stepAsync("async-step", Integer.class, () -> 42);
146159
assertEquals(42, asyncFuture.get());
160+
logger.info("testCombinedSyncAsyncWait - Async Done");
147161

148162
// Wait should suspend (throw exception)
149163
assertThrows(SuspendExecutionException.class, () -> {
150164
context.wait(Duration.ofSeconds(30));
165+
logger.info("testCombinedSyncAsyncWait - Wait Done");
151166
});
152167
}
153168

154169
@Test
155170
void testCombinedReplay() throws Exception {
171+
logger.info("testCombinedReplay");
156172
// Create context with all operations completed
157173
var syncOp = Operation.builder()
158174
.id("1")
@@ -183,6 +199,7 @@ void testCombinedReplay() throws Exception {
183199

184200
@Test
185201
void testNamedWait() {
202+
logger.info("testNamedWait");
186203
var ctx = createTestContext();
187204

188205
// Named wait should throw SuspendExecutionException
@@ -203,6 +220,7 @@ void testNamedWait() {
203220

204221
@Test
205222
void testStepWithTypeToken() {
223+
logger.info("testStepWithTypeToken");
206224
var context = createTestContext();
207225

208226
List<String> result = context.step("test-list", new TypeToken<List<String>>() {}, () -> List.of("a", "b", "c"));
@@ -214,6 +232,7 @@ void testStepWithTypeToken() {
214232

215233
@Test
216234
void testStepWithTypeTokenReplay() {
235+
logger.info("testStepWithTypeTokenReplay");
217236
// Create context with existing operation
218237
var existingOp = Operation.builder()
219238
.id("1")
@@ -235,6 +254,7 @@ void testStepWithTypeTokenReplay() {
235254

236255
@Test
237256
void testStepWithTypeTokenAndConfig() {
257+
logger.info("testStepWithTypeTokenAndConfig");
238258
var context = createTestContext();
239259

240260
List<Integer> result = context.step(
@@ -252,6 +272,7 @@ void testStepWithTypeTokenAndConfig() {
252272

253273
@Test
254274
void testStepAsyncWithTypeToken() throws Exception {
275+
logger.info("testStepAsyncWithTypeToken");
255276
var context = createTestContext();
256277

257278
DurableFuture<List<String>> future =
@@ -265,6 +286,7 @@ void testStepAsyncWithTypeToken() throws Exception {
265286

266287
@Test
267288
void testStepAsyncWithTypeTokenReplay() throws Exception {
289+
logger.info("testStepAsyncWithTypeTokenReplay");
268290
// Create context with existing operation
269291
var existingOp = Operation.builder()
270292
.id("1")
@@ -287,6 +309,7 @@ void testStepAsyncWithTypeTokenReplay() throws Exception {
287309

288310
@Test
289311
void testStepAsyncWithTypeTokenAndConfig() throws Exception {
312+
logger.info("testStepAsyncWithTypeTokenAndConfig");
290313
var context = createTestContext();
291314

292315
DurableFuture<List<Integer>> future = context.stepAsync(

0 commit comments

Comments
 (0)