알림 worker 둘(NotificationSchedulerWorker·NotificationBackgroundWorkers)에는 주석이 「예전 결함」이라 적은 고침 넷이 있는데, 이 클래스를 new로 만들어 동작을 보는 시험이 없다. 유일한 시험 NotificationWorkerLifecycleTest는 bean 이름과 조건만 본다. 그래서 고침 줄을 되돌려도 :composition:notification-platform:test가 통과한다(아래 「변이 확인」). main 코드는 바꾸지 않고 worker 단위 시험 두 파일을 더한다.
REV-BE-0028
NotificationSchedulerWorkerTest
aBatchLargerThanTheFreePermitsClaimsOnlyWhatCanStartNow — 동시 실행 허가 2·batch 10이면 claim 한도가 2다(:84Math.min).
theQueueDepthGaugeReportsTheBacklogRatherThanTheBatch — 큐 깊이 gauge 값이 backlog 조회 결과(12345)다(:95-98).
closeReturnsOnlyAfterTheClaimInFlightHasEnded — polling 스레드가 claim 중일 때 close()를 부르면, close()는 그 claim이 끝난 뒤에야 돌아온다(:183-192poller.join).
NotificationBackgroundWorkersTest
aRecoveryPassThatThrowsRunsAgainOnItsSchedule — recovery pass가 첫 차례에 던져도 두 번째 차례가 불린다(NotificationBackgroundWorkers.java:111 catch).
고른 방법과 버린 대안
대역: 항목은 「application-notification testFixtures의 fake(없으면 그 포트의 fake)」를 적었다. 그런데 worker가 받는 유스케이스 여섯은 final 서비스(NotificationDispatchService·LeaseRecoveryService·ProviderEventProjectionService)를 받는 concrete 클래스다. testFixtures에는 그 서비스들이나 지표·서빙 상태 포트의 fake가 없고, testFixtures를 쓰려면 이 leaf의 build.gradle을 바꿔야 해 범위(시험 파일만) 밖이다. 그래서 같은 계층 OutboxRelayShutdownOrderTest가 PublishPendingOutboxEventsUseCase를 그렇게 하듯 유스케이스와 지표 포트를 Mockito로 대신한다. worker 시험은 유스케이스 안의 동작에 기대지 않는다. pass 실패는 Mockito의 장애 주입(thenThrow)이다.
close 시험이 단언하는 것: 항목은 「close()가 돌아온 뒤 claim이 더 불리지 않음」이라 적었다. 그런데 loop는 shuttingDown을 먼저 보므로 join이 없어도 새 claim은 시작되지 않는다. join이 없을 때 남는 결함은 close()가 돌아온 뒤에도 돌고 있는 claim이다(lease를 쥔 채 「닫힌」 프로세스). 그래서 claim 대역은 JDBC 호출처럼 interrupt에 멈추지 않고, close()가 먼저 돌아오는지 2초 동안 본다. join이 있으면 close()는 그 claim을 기다리므로 그 안에 돌아올 수 없다. 정상 경로가 시간에 기대지 않는다(shutdownGrace 30초 ≫ 2초).
기다리기: sleep 없음. latch는 상한 있는 await이고 시간이 다 되면 실패한다. pass 시험은 Mockito verify(timeout(10_000).atLeast(2)).
버린 안: 실 DB 통합 시험으로만 보기. lane이 무겁고 이 규칙들은 DB와 무관하다.
위험과 영향
main 코드는 바꾸지 않았다. 운영 영향이 없다.
close 시험은 정상 경로에서 2초가 든다(claim 대역의 대기 상한).
Mockito 대역은 유스케이스의 실제 동작과 갈라질 수 있다. 이 시험이 보는 것은 worker의 claim 한도·gauge 인자·종료 순서·일정 유지뿐이라 유스케이스 안의 동작은 단언하지 않는다.
검증
RED: desktop에서 이 PR의 트리(f2c42922)에 변이를 하나씩 넣고 :composition:notification-platform:test --tests NotificationSchedulerWorkerTest --tests NotificationBackgroundWorkersTest(트리마다 Gradle 한 번, 공유 잠금 아래)를 돌렸다. 로그 desktop ~/be-lane-n3-red2-logs/(리뷰 반영 전 트리 a40d3ae8에서 처음 돌린 ~/be-lane-n3-red-logs/도 결과가 같다).
(b) 변이 꼴: backlog 필드가 안 읽혀 Error Prone UnusedVariable(-Werror)로 컴파일이 깨지지 않게 Objects.requireNonNull(backlog, "backlog")를 넣었다. (c)는 join만 지우면 InterruptedException을 던지지 않는 try가 되어 컴파일이 깨지므로 try/catch째 지웠다.
변이 확인(시험을 더하기 전 트리 3bfefe69, :composition:notification-platform:test 전체): (a) 트리 407c98e2 rc=0, (c) 트리 d2399fb3 rc=0 — 둘 다 기존 20 시험 통과. 항목 「고치기 전에는 (a)(c)가 통과」 그대로다.
게이트(깨끗한 detached worktree, 첫 줄 「트리 f2c429229fb1(HEAD 트리와 같음)」):
closeReturnsOnlyAfterTheClaimInFlightHasEnded: join이 있는 정상 경로에서 흔들릴 길이 없는가(claim 대역의 2초 대기 vs shutdownGrace 30초, awaitIgnoringInterrupts가 interrupt를 돌려주는 것).
Mockito 대역의 이유(위 「대역」).
리뷰 반영: 새 눈 리뷰 1회(Sonnet 5.5, 렌즈 be-testing) — High·Medium 0, Low 3. 셋 다 push 전에 amend로 고쳤고 트리가 바뀌어 RED·verify를 새 트리로 다시 돌렸다(위 표·게이트가 새 트리 결과다). 확인 리뷰 없음.
Low: close 시험의 // when에 close()와 신호 countDown() 둘 → try { close() } finally { countDown() }로 신호가 close의 반환임을 드러냄.
Low: (c) 변이는 2초 상한으로 가르므로 부하가 크면 그 변이가 한 번 통과할 수 있다(정상 경로는 흔들리지 않음) → 시험 Javadoc에 그 한계를 적음.
Low: pass 실패 시험이 recovery pass 하나만 본다 → 이름을 aRecoveryPassThatThrowsRunsAgainOnItsSchedule로, Javadoc에 셋이 같은 schedule 감싸개를 쓴다고 적음.
관련
리뷰 항목 REV-BE-0028
## 무엇을, 왜
알림 worker 둘(`NotificationSchedulerWorker`·`NotificationBackgroundWorkers`)에는 주석이 「예전 결함」이라 적은 고침 넷이 있는데, 이 클래스를 `new`로 만들어 동작을 보는 시험이 없다. 유일한 시험 `NotificationWorkerLifecycleTest`는 bean 이름과 조건만 본다. 그래서 고침 줄을 되돌려도 `:composition:notification-platform:test`가 통과한다(아래 「변이 확인」). main 코드는 바꾸지 않고 worker 단위 시험 두 파일을 더한다.
**REV-BE-0028**
- `NotificationSchedulerWorkerTest`
- `aBatchLargerThanTheFreePermitsClaimsOnlyWhatCanStartNow` — 동시 실행 허가 2·batch 10이면 claim 한도가 2다(`:84` `Math.min`).
- `theQueueDepthGaugeReportsTheBacklogRatherThanTheBatch` — 큐 깊이 gauge 값이 backlog 조회 결과(12345)다(`:95-98`).
- `closeReturnsOnlyAfterTheClaimInFlightHasEnded` — polling 스레드가 claim 중일 때 `close()`를 부르면, `close()`는 그 claim이 끝난 뒤에야 돌아온다(`:183-192` `poller.join`).
- `NotificationBackgroundWorkersTest`
- `aRecoveryPassThatThrowsRunsAgainOnItsSchedule` — recovery pass가 첫 차례에 던져도 두 번째 차례가 불린다(`NotificationBackgroundWorkers.java:111` catch).
## 고른 방법과 버린 대안
- **대역:** 항목은 「application-notification testFixtures의 fake(없으면 그 포트의 fake)」를 적었다. 그런데 worker가 받는 유스케이스 여섯은 final 서비스(`NotificationDispatchService`·`LeaseRecoveryService`·`ProviderEventProjectionService`)를 받는 concrete 클래스다. testFixtures에는 그 서비스들이나 지표·서빙 상태 포트의 fake가 없고, testFixtures를 쓰려면 이 leaf의 `build.gradle`을 바꿔야 해 범위(시험 파일만) 밖이다. 그래서 같은 계층 `OutboxRelayShutdownOrderTest`가 `PublishPendingOutboxEventsUseCase`를 그렇게 하듯 유스케이스와 지표 포트를 Mockito로 대신한다. worker 시험은 유스케이스 안의 동작에 기대지 않는다. pass 실패는 Mockito의 장애 주입(`thenThrow`)이다.
- **close 시험이 단언하는 것:** 항목은 「`close()`가 돌아온 뒤 claim이 더 불리지 않음」이라 적었다. 그런데 loop는 `shuttingDown`을 먼저 보므로 join이 없어도 새 claim은 시작되지 않는다. join이 없을 때 남는 결함은 `close()`가 돌아온 뒤에도 돌고 있는 claim이다(lease를 쥔 채 「닫힌」 프로세스). 그래서 claim 대역은 JDBC 호출처럼 interrupt에 멈추지 않고, `close()`가 먼저 돌아오는지 2초 동안 본다. join이 있으면 `close()`는 그 claim을 기다리므로 그 안에 돌아올 수 없다. 정상 경로가 시간에 기대지 않는다(shutdownGrace 30초 ≫ 2초).
- **기다리기:** sleep 없음. latch는 상한 있는 `await`이고 시간이 다 되면 실패한다. pass 시험은 Mockito `verify(timeout(10_000).atLeast(2))`.
- 버린 안: 실 DB 통합 시험으로만 보기. lane이 무겁고 이 규칙들은 DB와 무관하다.
## 위험과 영향
- main 코드는 바꾸지 않았다. 운영 영향이 없다.
- close 시험은 정상 경로에서 2초가 든다(claim 대역의 대기 상한).
- Mockito 대역은 유스케이스의 실제 동작과 갈라질 수 있다. 이 시험이 보는 것은 worker의 claim 한도·gauge 인자·종료 순서·일정 유지뿐이라 유스케이스 안의 동작은 단언하지 않는다.
## 검증
RED: desktop에서 이 PR의 트리(f2c42922)에 변이를 하나씩 넣고 `:composition:notification-platform:test --tests NotificationSchedulerWorkerTest --tests NotificationBackgroundWorkersTest`(트리마다 Gradle 한 번, 공유 잠금 아래)를 돌렸다. 로그 desktop `~/be-lane-n3-red2-logs/`(리뷰 반영 전 트리 a40d3ae8에서 처음 돌린 `~/be-lane-n3-red-logs/`도 결과가 같다).
| 변이 | 트리 | rc | 실패한 새 시험 — 메시지 |
|---|---|---|---|
| 없음(GREEN) | f2c42922 | 0 | 없음(4 시험, skip 0) |
| (a) `NotificationSchedulerWorker:84` → `int executable = properties.claimBatchSize();` | e8f93975 | 1 | `aBatchLargerThanTheFreePermitsClaimsOnlyWhatCanStartNow` — `Argument(s) are different! Wanted: …ClaimDueDeliveriesCommand[workerId=worker-1, limit=2, leaseDuration=PT30S]` |
| (b) `:98` gauge 값 → `(double) claimed.size()` (+ `Objects.requireNonNull(backlog, "backlog")`) | 6e14b178 | 1 | `theQueueDepthGaugeReportsTheBacklogRatherThanTheBatch` — `Argument(s) are different! Wanted: notificationMetricsPort.gauge("notification.queue.depth", {}, 12345.0d)` |
| (c) `:185-189` `poller.join(...)`과 그 try/catch 삭제 | c28ae518 | 1 | `closeReturnsOnlyAfterTheClaimInFlightHasEnded` — `Expecting AtomicReference[true] to have value: false but did not.` |
| (d) `NotificationBackgroundWorkers:106-120` try/catch 삭제(pass 예외가 일정 밖으로 나감) | 71a2639a | 1 | `aRecoveryPassThatThrowsRunsAgainOnItsSchedule` — `TooFewActualInvocations: recoverAbandonedDeliveriesUseCase.handle(RecoverAbandonedDeliveriesCommand[])` |
- 변이마다 실패는 그 변이를 겨냥한 시험 하나뿐이다(나머지 셋 통과).
- (b) 변이 꼴: `backlog` 필드가 안 읽혀 Error Prone `UnusedVariable`(-Werror)로 컴파일이 깨지지 않게 `Objects.requireNonNull(backlog, "backlog")`를 넣었다. (c)는 join만 지우면 `InterruptedException`을 던지지 않는 try가 되어 컴파일이 깨지므로 try/catch째 지웠다.
변이 확인(시험을 더하기 전 트리 3bfefe69, `:composition:notification-platform:test` 전체): (a) 트리 407c98e2 rc=0, (c) 트리 d2399fb3 rc=0 — 둘 다 기존 20 시험 통과. 항목 「고치기 전에는 (a)(c)가 통과」 그대로다.
게이트(깨끗한 detached worktree, 첫 줄 「트리 f2c429229fb1(HEAD 트리와 같음)」):
- desktop `scripts/verify.sh leaf :composition:notification-platform` — rc=0, tests=24 failures=0 errors=0 skipped=0
- desktop `scripts/verify.sh pr --no-cache` — rc=0, tests=7343 failures=0 errors=0 skipped=35
- 노트북 `scripts/verify.sh docs` — rc=0
- PR run `pr / done` — run 501(head 0caf59e5) success
## 리뷰어가 볼 곳
- `closeReturnsOnlyAfterTheClaimInFlightHasEnded`: join이 있는 정상 경로에서 흔들릴 길이 없는가(claim 대역의 2초 대기 vs shutdownGrace 30초, `awaitIgnoringInterrupts`가 interrupt를 돌려주는 것).
- Mockito 대역의 이유(위 「대역」).
리뷰 반영: 새 눈 리뷰 1회(Sonnet 5.5, 렌즈 be-testing) — High·Medium 0, Low 3. 셋 다 push 전에 amend로 고쳤고 트리가 바뀌어 RED·verify를 새 트리로 다시 돌렸다(위 표·게이트가 새 트리 결과다). 확인 리뷰 없음.
- Low: close 시험의 `// when`에 `close()`와 신호 `countDown()` 둘 → `try { close() } finally { countDown() }`로 신호가 close의 반환임을 드러냄.
- Low: (c) 변이는 2초 상한으로 가르므로 부하가 크면 그 변이가 한 번 통과할 수 있다(정상 경로는 흔들리지 않음) → 시험 Javadoc에 그 한계를 적음.
- Low: pass 실패 시험이 recovery pass 하나만 본다 → 이름을 `aRecoveryPassThatThrowsRunsAgainOnItsSchedule`로, Javadoc에 셋이 같은 `schedule` 감싸개를 쓴다고 적음.
## 관련
- 리뷰 항목 REV-BE-0028
NotificationSchedulerWorker와 NotificationBackgroundWorkers에는 주석이
「예전 결함」이라 적은 고침 넷이 있다. batch를 동시 실행 허가보다 많이
claim하지 않기, 큐 깊이 gauge를 batch 크기가 아니라 backlog로 보고하기,
close()가 polling 스레드를 join하기, pass 실패를 삼켜 일정이 이어지게
하기다. 이 클래스를 new로 만들어 동작을 보는 시험이 없어, 넷 중 어느
줄을 되돌려도 :composition:notification-platform test가 통과한다.
worker 단위 시험 두 파일을 더한다. NotificationSchedulerWorkerTest는
허가 2·batch 10이면 claim 한도가 2인지, gauge 값이 backlog 조회 결과인지,
close()가 진행 중인 claim이 끝난 뒤에야 돌아오는지 본다. 마지막 시험의
claim은 JDBC 호출처럼 interrupt에 멈추지 않고 close()가 먼저 돌아오는지
2초 동안 본다. join이 있으면 close()는 그 claim을 기다리므로 그 안에
돌아올 수 없다. NotificationBackgroundWorkersTest는 recovery pass가
첫 차례에 던져도 두 번째 차례가 불리는지 Mockito의 상한 있는 verify로
본다. sleep으로 기다리지 않는다.
유스케이스 여섯은 final 서비스를 받는 concrete 클래스라 같은 계층의
outbox relay 시험처럼 Mockito로 대신한다. application-notification
testFixtures에는 이 유스케이스들이나 지표 포트의 fake가 없고, 그것을
쓰려면 이 leaf의 build.gradle을 바꿔야 해 항목 범위(시험 파일만) 밖이다.
버린 안: 실 DB 통합 시험으로만 보기. lane이 무겁고 이 규칙은 DB와
무관하다.
위험·한계: main 코드는 바꾸지 않았다. close 시험은 정상 경로에서
2초가 든다. 항목은 「close() 뒤 claim이 더 불리지 않음」이라 적었지만
loop가 shuttingDown을 먼저 보므로 join이 없어도 새 claim은 시작되지
않는다. join이 없을 때 남는 것은 close() 뒤에도 돌고 있는 claim이라
그것을 단언한다.
검증: desktop RED·GREEN은 PR 본문에 둔다.
Refs: REV-BE-0028
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
무엇을, 왜
알림 worker 둘(
NotificationSchedulerWorker·NotificationBackgroundWorkers)에는 주석이 「예전 결함」이라 적은 고침 넷이 있는데, 이 클래스를new로 만들어 동작을 보는 시험이 없다. 유일한 시험NotificationWorkerLifecycleTest는 bean 이름과 조건만 본다. 그래서 고침 줄을 되돌려도:composition:notification-platform:test가 통과한다(아래 「변이 확인」). main 코드는 바꾸지 않고 worker 단위 시험 두 파일을 더한다.REV-BE-0028
NotificationSchedulerWorkerTestaBatchLargerThanTheFreePermitsClaimsOnlyWhatCanStartNow— 동시 실행 허가 2·batch 10이면 claim 한도가 2다(:84Math.min).theQueueDepthGaugeReportsTheBacklogRatherThanTheBatch— 큐 깊이 gauge 값이 backlog 조회 결과(12345)다(:95-98).closeReturnsOnlyAfterTheClaimInFlightHasEnded— polling 스레드가 claim 중일 때close()를 부르면,close()는 그 claim이 끝난 뒤에야 돌아온다(:183-192poller.join).NotificationBackgroundWorkersTestaRecoveryPassThatThrowsRunsAgainOnItsSchedule— recovery pass가 첫 차례에 던져도 두 번째 차례가 불린다(NotificationBackgroundWorkers.java:111catch).고른 방법과 버린 대안
NotificationDispatchService·LeaseRecoveryService·ProviderEventProjectionService)를 받는 concrete 클래스다. testFixtures에는 그 서비스들이나 지표·서빙 상태 포트의 fake가 없고, testFixtures를 쓰려면 이 leaf의build.gradle을 바꿔야 해 범위(시험 파일만) 밖이다. 그래서 같은 계층OutboxRelayShutdownOrderTest가PublishPendingOutboxEventsUseCase를 그렇게 하듯 유스케이스와 지표 포트를 Mockito로 대신한다. worker 시험은 유스케이스 안의 동작에 기대지 않는다. pass 실패는 Mockito의 장애 주입(thenThrow)이다.close()가 돌아온 뒤 claim이 더 불리지 않음」이라 적었다. 그런데 loop는shuttingDown을 먼저 보므로 join이 없어도 새 claim은 시작되지 않는다. join이 없을 때 남는 결함은close()가 돌아온 뒤에도 돌고 있는 claim이다(lease를 쥔 채 「닫힌」 프로세스). 그래서 claim 대역은 JDBC 호출처럼 interrupt에 멈추지 않고,close()가 먼저 돌아오는지 2초 동안 본다. join이 있으면close()는 그 claim을 기다리므로 그 안에 돌아올 수 없다. 정상 경로가 시간에 기대지 않는다(shutdownGrace 30초 ≫ 2초).await이고 시간이 다 되면 실패한다. pass 시험은 Mockitoverify(timeout(10_000).atLeast(2)).위험과 영향
검증
RED: desktop에서 이 PR의 트리(
f2c42922)에 변이를 하나씩 넣고:composition:notification-platform:test --tests NotificationSchedulerWorkerTest --tests NotificationBackgroundWorkersTest(트리마다 Gradle 한 번, 공유 잠금 아래)를 돌렸다. 로그 desktop~/be-lane-n3-red2-logs/(리뷰 반영 전 트리 a40d3ae8에서 처음 돌린~/be-lane-n3-red-logs/도 결과가 같다).f2c42922NotificationSchedulerWorker:84→int executable = properties.claimBatchSize();aBatchLargerThanTheFreePermitsClaimsOnlyWhatCanStartNow—Argument(s) are different! Wanted: …ClaimDueDeliveriesCommand[workerId=worker-1, limit=2, leaseDuration=PT30S]:98gauge 값 →(double) claimed.size()(+Objects.requireNonNull(backlog, "backlog"))theQueueDepthGaugeReportsTheBacklogRatherThanTheBatch—Argument(s) are different! Wanted: notificationMetricsPort.gauge("notification.queue.depth", {}, 12345.0d):185-189poller.join(...)과 그 try/catch 삭제closeReturnsOnlyAfterTheClaimInFlightHasEnded—Expecting AtomicReference[true] to have value: false but did not.NotificationBackgroundWorkers:106-120try/catch 삭제(pass 예외가 일정 밖으로 나감)aRecoveryPassThatThrowsRunsAgainOnItsSchedule—TooFewActualInvocations: recoverAbandonedDeliveriesUseCase.handle(RecoverAbandonedDeliveriesCommand[])backlog필드가 안 읽혀 Error ProneUnusedVariable(-Werror)로 컴파일이 깨지지 않게Objects.requireNonNull(backlog, "backlog")를 넣었다. (c)는 join만 지우면InterruptedException을 던지지 않는 try가 되어 컴파일이 깨지므로 try/catch째 지웠다.변이 확인(시험을 더하기 전 트리
3bfefe69,:composition:notification-platform:test전체): (a) 트리 407c98e2 rc=0, (c) 트리 d2399fb3 rc=0 — 둘 다 기존 20 시험 통과. 항목 「고치기 전에는 (a)(c)가 통과」 그대로다.게이트(깨끗한 detached worktree, 첫 줄 「트리 f2c429229fb1(HEAD 트리와 같음)」):
scripts/verify.sh leaf :composition:notification-platform— rc=0, tests=24 failures=0 errors=0 skipped=0scripts/verify.sh pr --no-cache— rc=0, tests=7343 failures=0 errors=0 skipped=35scripts/verify.sh docs— rc=0pr / done— run 501(head0caf59e5) success리뷰어가 볼 곳
closeReturnsOnlyAfterTheClaimInFlightHasEnded: join이 있는 정상 경로에서 흔들릴 길이 없는가(claim 대역의 2초 대기 vs shutdownGrace 30초,awaitIgnoringInterrupts가 interrupt를 돌려주는 것).리뷰 반영: 새 눈 리뷰 1회(Sonnet 5.5, 렌즈 be-testing) — High·Medium 0, Low 3. 셋 다 push 전에 amend로 고쳤고 트리가 바뀌어 RED·verify를 새 트리로 다시 돌렸다(위 표·게이트가 새 트리 결과다). 확인 리뷰 없음.
// when에close()와 신호countDown()둘 →try { close() } finally { countDown() }로 신호가 close의 반환임을 드러냄.aRecoveryPassThatThrowsRunsAgainOnItsSchedule로, Javadoc에 셋이 같은schedule감싸개를 쓴다고 적음.관련