core のテストで、カレンダーの共有状態が残って後続のテストが大量に失敗する不具合を直す

Open
#1,687 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
backend, testing

Research direction

Start with the failed run artifact and CalendarServiceTest.java:157, then inspect WorkingCalendar.java and the listed calendar test classes for shared state changes. Reproduce by running those tests and CalendarServiceTest repeatedly in one JVM with Asia/Tokyo and GMT time zones. Done means documenting the cause or reproduction limits, fixing cleanup or shared state, adding a safeguard, and passing the five repeated core test runs and inventory check.

Written by the indexing model from the issue text.

Description

area: build area: core bug priority: medium status: verification

目的・担当・前提

  • 対応するマイルストーン/親 Issue:#1054(索引)
  • 実装担当/レビュー担当:未定/リポジトリの管理者
  • 作業元コミット/依存 Issue:master 08f27c070/なし
  • 現在の状態:不安定なテスト(原因は未特定)
  • 区分:CI/テスト

概要

CI の実行 46440679799(PR #1666、ubuntu-latest、2026-11-30、1 回目の試行)で、:microproject_core:test の 1617 件中 104 件が失敗した。2 回目の試行(クラスの実行順は同じ)と、macOS、Windows は通った。

最初の失敗は CalendarServiceTest.baseCalendarCommitInvalidatesAllOwnersPublishesAfterUnlockAndKeepsUndoWithEditor(modules/microproject_core/src/test/java/com/microproject/model/calendar/CalendarServiceTest.java:157)。

two workdays from Friday end Monday without Saturday work expected: <4096112400000> but was: <4096166400000>

終了日が 2099-10-19 17:00 のはずが、2099-10-20 08:00(稼働日 1 日分あと)になった。その後、スケジュールを使うクラスが続けて失敗した:DependencyServiceTest、ResourceLevelingServiceTest(11)、TeamPlannerServiceTest(5)、IncrementalScheduleEquivalenceTest(9)、NormalTaskDurationTest(9)、RespectLinksServiceTest(6)、TaskLinkAndBarScheduleTransitionsTest(49)ほか。

どこかの共有された静的な状態(標準の基本カレンダー、既定値、キャッシュ、背景のスレッドなど)が、誤った値のまま残ると考えられる。これは推測で、原因は確かめていない。

候補の場所(確認済みの事実のみ):WorkingCalendar.java(modules/microproject_core/src/main/java/com/microproject/model/calendar/)に静的な standardInstance と defaultInstance(:473-474)と、getStandardInstance(:485)、getDefaultInstance(:512)がある。失敗したテストの直前に動いたカレンダーのテストは、CalendarCatalogTest、CalendarDefinitionDegenerateFuzzTest、CalendarDefinitionTest、CalendarEventTest、CalendarExceptionImporterTest、CalendarRecurrenceTest(いずれも modules/microproject_core/src/test/java/com/microproject/model/calendar/)。

行番号は master 08f27c070 時点。証拠の成果物:gradle-test-evidence-46440679799-ubuntu-latest(失敗した試行は ID 15389258055、通った試行は ID 15391486149)。

作業手順

  1. 成果物を、新しい空のディレクトリにダウンロードして読む。失敗した試行のテストの実行順と、最初に失敗したテストの前に動いたクラスを記録する。
  2. 共有された静的な状態を探す:rg -n "static (?!final)" -P modules/microproject_core/src/main/java/com/microproject/model/calendar。ほかに CalendarService、WorkingCalendar が使うキャッシュとスレッドも調べる。手順 1 のクラスが、これらを書き換えているかを確かめる。
  3. 再現を試みる。手順 1 のクラスと CalendarServiceTest を、1 つの JVM で繰り返し実行する(.\gradlew.bat :microproject_core:test --tests "com.microproject.model.calendar.*" --console=plain。JAVA_TOOL_OPTIONS のタイム ゾーンを Asia/Tokyo と GMT に変えて数回)。再現できなければ、試した条件を issue にコメントする。
  4. 原因が分かったら、書き換えたテストが後始末をするか、書き換える側が後始末できる形に直す(@AfterEach で元に戻す、または共有状態を読み取り専用にする)。テストを無効にしたり、期待値を弱めたり、待ち時間を延ばしたりして通さない。
  5. 同じ種類の状態の残りを検出する保護を足す。例:@AfterEach で標準の基本カレンダーの稼働日、稼働時間が既定のままであることを確かめる(modules/microproject_core/src/test 内)。保護は、手順 2 で見つけた状態に合わせて決める。
  6. 原因を、PR の説明と issue のコメントに書く。

検証

.\gradlew.bat :microproject_core:test --tests "com.microproject.model.calendar.*" --console=plain
.\gradlew.bat :microproject_core:test --console=plain
python scripts/test_source_inventory.py --check --output build/audit/test-source-inventory.json
git diff --check

最後に、.\gradlew.bat :microproject_core:test --rerun-tasks --console=plain をローカルで 5 回続けて実行し、毎回通ることを確かめる。

完了条件

  • 共有状態の原因を、issue または PR に記録した(特定できない場合は、調べた範囲と再現できなかった条件を記録した)
  • 原因を直すか、後始末を足した(テストの無効化、期待値の弱体化、待ち時間の延長をしていない)
  • 同じ種類の状態の残りを検出する保護を足した
  • .\gradlew.bat :microproject_core:test --rerun-tasks --console=plain を 5 回続けて実行し、すべて通った
  • python scripts/test_source_inventory.py --check --output build/audit/test-source-inventory.json が通る
  • build と GUI acceptance が通る

範囲外

  • CalendarServiceTest 以外の、不安定でないテストの整理。
  • テストの並列実行の導入。
Dominant language
Java
Stars
2
Forks
1
Avg merge
4h 52m
Merged PRs (30d)
349

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tetsuji16/microProject

All issues in tetsuji16/microProject

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.