From b5a796c8bfd255caa1a75551cc888f54adee171e Mon Sep 17 00:00:00 2001 From: Command1264 Date: Tue, 22 Sep 2026 20:43:18 +0800 Subject: [PATCH 1/3] test: add real server test matrix --- .gitattributes | 3 ++ .gitignore | 1 + README.md | 4 ++ docs/testing/test-servers.md | 74 +++++++++++++++++++++++++++++++ scripts/test-servers/common.ps1 | 69 ++++++++++++++++++++++++++++ scripts/test-servers/doctor.ps1 | 33 ++++++++++++++ scripts/test-servers/prepare.ps1 | 27 +++++++++++ scripts/test-servers/start.ps1 | 16 +++++++ scripts/test-servers/validate.ps1 | 17 +++++++ test-servers/matrix.json | 54 ++++++++++++++++++++++ 10 files changed, 298 insertions(+) create mode 100644 docs/testing/test-servers.md create mode 100644 scripts/test-servers/common.ps1 create mode 100644 scripts/test-servers/doctor.ps1 create mode 100644 scripts/test-servers/prepare.ps1 create mode 100644 scripts/test-servers/start.ps1 create mode 100644 scripts/test-servers/validate.ps1 create mode 100644 test-servers/matrix.json diff --git a/.gitattributes b/.gitattributes index 811cd6b..28eb82a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,5 +5,8 @@ *.yml text eol=lf *.yaml text eol=lf *.properties text eol=lf +*.json text eol=lf +*.ps1 text eol=lf +*.psm1 text eol=lf gradlew text eol=lf gradlew.bat text eol=crlf diff --git a/.gitignore b/.gitignore index c5c9453..1ef9605 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.iml out/ .run/ +.test-server/ *.log *.db *.db-shm diff --git a/README.md b/README.md index 384d054..b280e06 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ Qualification Reward 與 Inviter Milestone Reward 會先以穩定冪等鍵保存 - `develop`:日常整合分支 - task branch:使用獨立 Worktree,目標分支為 `develop` +## 真實伺服器測試 + +專案的真實 Spigot/Paper/Folia 測試矩陣位於 [`test-servers/matrix.json`](./test-servers/matrix.json),並使用專案外的共用 TestLab 建立隔離實例。操作方式與 EULA 邊界請參閱 [`docs/testing/test-servers.md`](./docs/testing/test-servers.md)。 + ## 目前狀態 實作工作記錄於本 repository 的 GitHub Issues。不規劃相容或匯入舊版 InviteCode 的資料與設定。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md new file mode 100644 index 0000000..7617c14 --- /dev/null +++ b/docs/testing/test-servers.md @@ -0,0 +1,74 @@ +# InviteCode 真實測試伺服器 + +InviteCode 使用專案外的 `D:\Code\Java\Plugin\TestLab` 共用伺服器核心快取與工具,但每個 profile、Worktree 與驗收版本都建立獨立實例。World、插件設定、SQLite、log 與其他可變狀態不跨實例共用。 + +## 測試矩陣 + +正式矩陣定義於 `test-servers/matrix.json`: + +| Profile | 用途 | 發行 gate | +| --- | --- | --- | +| `spigot-1.8.8` | 最低支援邊界 | 是 | +| `spigot-1.12.2` | 舊版中間邊界 | 是 | +| `spigot-1.16.5` | Java 8 世代中間版本 | 是 | +| `spigot-latest` | 最新 Spigot | 是 | +| `paper-1.20.6` | 新版 Paper 代表版本 | 是 | +| `paper-1.21.8` | 原生 Dialog 能力邊界 | 是 | +| `paper-latest` | 最新穩定 Paper | 是 | +| `folia-latest` | 實驗性 smoke | 否 | + +Folia 測試失敗會阻止宣稱 Folia 相容,但不會單獨阻止 Spigot/Paper 發行。 + +## 環境檢查 + +```powershell +pwsh -NoProfile -File .\scripts\test-servers\validate.ps1 +pwsh -NoProfile -File .\scripts\test-servers\doctor.ps1 +``` + +若 TestLab foundation 尚未合併,可用 `-TestLabRoot` 指向其 task Worktree。平常也可設定 `PLUGIN_TEST_LAB_HOME`。 + +## 建立測試實例 + +先建置受測 JAR: + +```powershell +mise exec -- .\gradlew.bat clean check shadowJar +``` + +建立實例但不代替使用者接受 Minecraft EULA: + +```powershell +pwsh -NoProfile -File .\scripts\test-servers\prepare.ps1 ` + -Profile paper-latest ` + -Artifact .\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar +``` + +使用者確認接受 EULA 後,以 `-AcceptEula -Replace` 重建同一實例: + +```powershell +pwsh -NoProfile -File .\scripts\test-servers\prepare.ps1 ` + -Profile paper-latest ` + -Artifact .\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar ` + -AcceptEula ` + -Replace +``` + +啟動: + +```powershell +pwsh -NoProfile -File .\scripts\test-servers\start.ps1 -Profile paper-latest +``` + +啟動腳本依 profile 透過 mise 選擇 Java,不依賴系統 `PATH` 的 Java 優先順序。人工測試時應在可見的 PowerShell 7 視窗執行,並在 server console 輸入 `stop` 正常關閉。 + +## 每個 profile 的最低 smoke + +1. 確認 InviteCode 啟用且沒有 linkage error、legacy material warning 或未處理 exception。 +2. 確認第一次啟動自動建立 SQLite 與 anti-abuse key,重新啟動後沿用既有資料。 +3. 玩家與 Console 驗證 `/ic help`、`/ic reload`、Tab completion 與權限拒絕。 +4. 玩家驗證 Invite Code 顯示、Claim、Confirmation、Status 與 Stats。 +5. 驗證 `zh_TW`/`en_US`、UTF-8 與 client locale fallback。 +6. 驗證離線 Reward 補發與 restart recovery;需要外部整合的 profile 再加入 Vault/PlaceholderAPI。 + +各次測試應記錄 `workspace.json`、受測 commit、JAR SHA-256、操作結果與 `logs/latest.log`。實際相容性證據尚未取得前,不得只因實例能建立就宣稱該版本受到支援。 diff --git a/scripts/test-servers/common.ps1 b/scripts/test-servers/common.ps1 new file mode 100644 index 0000000..0d09743 --- /dev/null +++ b/scripts/test-servers/common.ps1 @@ -0,0 +1,69 @@ +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +function Get-InviteCodeRepositoryRoot { + return [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\..")) +} + +function Get-InviteCodeTestMatrix { + $path = Join-Path (Get-InviteCodeRepositoryRoot) "test-servers\matrix.json" + $document = Get-Content -LiteralPath $path -Raw -Encoding UTF8 | ConvertFrom-Json -ErrorAction Stop + if ($document.schemaVersion -ne 1 -or $document.project -cne "InviteCode") { + throw "不支援的 InviteCode test-server matrix。" + } + $profiles = @($document.profiles) + $duplicates = @($profiles | Group-Object id | Where-Object Count -gt 1) + if ($profiles.Count -eq 0 -or $duplicates.Count -gt 0) { + throw "InviteCode test-server matrix 為空或包含重複 profile。" + } + return $document +} + +function Get-InviteCodeTestProfile { + param([Parameter(Mandatory = $true)][string] $Id) + $matches = @((Get-InviteCodeTestMatrix).profiles | Where-Object id -CEQ $Id) + if ($matches.Count -ne 1) { + throw "InviteCode matrix 找不到唯一 profile:$Id" + } + return $matches[0] +} + +function Resolve-PluginTestLabRoot { + param([AllowNull()][string] $ExplicitRoot) + $candidates = [System.Collections.Generic.List[string]]::new() + if (-not [string]::IsNullOrWhiteSpace($ExplicitRoot)) { + $candidates.Add($ExplicitRoot) + } + if (-not [string]::IsNullOrWhiteSpace($env:PLUGIN_TEST_LAB_HOME)) { + $candidates.Add($env:PLUGIN_TEST_LAB_HOME) + } + $cursor = [System.IO.DirectoryInfo]::new((Get-InviteCodeRepositoryRoot)) + while ($null -ne $cursor) { + $candidates.Add((Join-Path $cursor.FullName "TestLab\repo")) + $cursor = $cursor.Parent + } + foreach ($candidate in $candidates) { + $resolved = [System.IO.Path]::GetFullPath($candidate) + if (Test-Path -LiteralPath (Join-Path $resolved "scripts\prepare-instance.ps1") -PathType Leaf) { + return $resolved + } + } + throw "找不到 TestLab。請合併 TestLab foundation、設定 PLUGIN_TEST_LAB_HOME,或傳入 -TestLabRoot。" +} + +function Resolve-InviteCodePluginArtifact { + param([AllowNull()][string] $ExplicitArtifact) + if (-not [string]::IsNullOrWhiteSpace($ExplicitArtifact)) { + $resolved = [System.IO.Path]::GetFullPath($ExplicitArtifact) + if (-not (Test-Path -LiteralPath $resolved -PathType Leaf)) { + throw "找不到 InviteCode JAR:$resolved" + } + return $resolved + } + $directory = Join-Path (Get-InviteCodeRepositoryRoot) "invitecode-plugin\build\libs" + $matches = @(Get-ChildItem -LiteralPath $directory -File -Filter "InviteCode-*.jar" -ErrorAction SilentlyContinue) + if ($matches.Count -ne 1) { + throw "無法唯一判定 InviteCode JAR;請先建置或傳入 -Artifact。" + } + return $matches[0].FullName +} diff --git a/scripts/test-servers/doctor.ps1 b/scripts/test-servers/doctor.ps1 new file mode 100644 index 0000000..1617da3 --- /dev/null +++ b/scripts/test-servers/doctor.ps1 @@ -0,0 +1,33 @@ +[CmdletBinding()] +param([AllowNull()][string] $TestLabRoot) + +. (Join-Path $PSScriptRoot "common.ps1") +$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$matrix = Get-InviteCodeTestMatrix +Import-Module (Join-Path $lab "scripts\TestLab.psm1") -Force +$labProfiles = @(Get-TestLabProfiles) + +$rows = foreach ($profile in $matrix.profiles) { + $labProfile = @($labProfiles | Where-Object id -CEQ $profile.id) + $javaAvailable = $false + $javaDetail = "profile missing" + if ($labProfile.Count -eq 1) { + $output = (& mise exec "java@$($labProfile[0].javaAlias)" -- java -version 2>&1 | Out-String).Trim() + $javaAvailable = $LASTEXITCODE -eq 0 + $javaDetail = ($output -split "`r?`n" | Select-Object -First 1) + } + [pscustomobject]@{ + Profile = $profile.id + Purpose = $profile.purpose + Required = $profile.requiredForRelease + TestLab = $labProfile.Count -eq 1 + Java = $javaAvailable + Runtime = $javaDetail + } +} + +Write-Host "TestLab:$lab" +$rows | Format-Table -AutoSize +if (@($rows | Where-Object { -not $_.TestLab -or -not $_.Java }).Count -gt 0) { + throw "InviteCode 測試矩陣仍有缺少的 TestLab profile 或 Java runtime。" +} diff --git a/scripts/test-servers/prepare.ps1 b/scripts/test-servers/prepare.ps1 new file mode 100644 index 0000000..0c73812 --- /dev/null +++ b/scripts/test-servers/prepare.ps1 @@ -0,0 +1,27 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)][string] $Profile, + [AllowNull()][string] $Artifact, + [AllowNull()][string] $TestLabRoot, + [AllowNull()][string] $Instance, + [switch] $AcceptEula, + [switch] $Replace +) + +. (Join-Path $PSScriptRoot "common.ps1") +$matrixProfile = Get-InviteCodeTestProfile -Id $Profile +$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$jar = Resolve-InviteCodePluginArtifact -ExplicitArtifact $Artifact +$instanceName = if ([string]::IsNullOrWhiteSpace($Instance)) { "invitecode-$Profile" } else { $Instance } + +& (Join-Path $lab "scripts\prepare-instance.ps1") ` + -Project "InviteCode" ` + -Instance $instanceName ` + -Profile $Profile ` + -PluginJar $jar ` + -Port $matrixProfile.port ` + -AcceptEula:$AcceptEula ` + -Replace:$Replace +if ($LASTEXITCODE -ne 0) { + throw "TestLab prepare-instance 失敗,結束碼為 $LASTEXITCODE。" +} diff --git a/scripts/test-servers/start.ps1 b/scripts/test-servers/start.ps1 new file mode 100644 index 0000000..a2cf8ff --- /dev/null +++ b/scripts/test-servers/start.ps1 @@ -0,0 +1,16 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)][string] $Profile, + [AllowNull()][string] $TestLabRoot, + [AllowNull()][string] $Instance +) + +. (Join-Path $PSScriptRoot "common.ps1") +[void] (Get-InviteCodeTestProfile -Id $Profile) +$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$instanceName = if ([string]::IsNullOrWhiteSpace($Instance)) { "invitecode-$Profile" } else { $Instance } + +& (Join-Path $lab "scripts\start-instance.ps1") -Project "InviteCode" -Instance $instanceName +if ($LASTEXITCODE -ne 0) { + throw "TestLab start-instance 失敗,結束碼為 $LASTEXITCODE。" +} diff --git a/scripts/test-servers/validate.ps1 b/scripts/test-servers/validate.ps1 new file mode 100644 index 0000000..c115b36 --- /dev/null +++ b/scripts/test-servers/validate.ps1 @@ -0,0 +1,17 @@ +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" +. (Join-Path $PSScriptRoot "common.ps1") + +$matrix = Get-InviteCodeTestMatrix +if (@($matrix.profiles).Count -ne 8) { + throw "InviteCode test matrix 預期為 8 個 profile。" +} +$ports = @($matrix.profiles | ForEach-Object { [int] $_.port }) +if (@($ports | Group-Object | Where-Object Count -gt 1).Count -gt 0) { + throw "InviteCode test matrix 包含重複 port。" +} +if (@($matrix.profiles | Where-Object { $_.id -ceq "folia-latest" -and $_.requiredForRelease }).Count -ne 0) { + throw "Folia 應維持實驗性,不得標記為必要發行 gate。" +} + +Write-Host "InviteCode test-server matrix 驗證通過:8 profiles,port 無衝突。" diff --git a/test-servers/matrix.json b/test-servers/matrix.json new file mode 100644 index 0000000..f560961 --- /dev/null +++ b/test-servers/matrix.json @@ -0,0 +1,54 @@ +{ + "schemaVersion": 1, + "project": "InviteCode", + "profiles": [ + { + "id": "spigot-1.8.8", + "port": 51888, + "purpose": "最低支援邊界", + "requiredForRelease": true + }, + { + "id": "spigot-1.12.2", + "port": 51222, + "purpose": "舊版 Bukkit API 中間邊界", + "requiredForRelease": true + }, + { + "id": "spigot-1.16.5", + "port": 51650, + "purpose": "Java 8 世代中間版本", + "requiredForRelease": true + }, + { + "id": "spigot-latest", + "port": 52620, + "purpose": "最新 Spigot 邊界", + "requiredForRelease": true + }, + { + "id": "paper-1.20.6", + "port": 62060, + "purpose": "新版 Paper 舊映射邊界", + "requiredForRelease": true + }, + { + "id": "paper-1.21.8", + "port": 62180, + "purpose": "原生 Dialog 能力邊界", + "requiredForRelease": true + }, + { + "id": "paper-latest", + "port": 62620, + "purpose": "最新穩定 Paper", + "requiredForRelease": true + }, + { + "id": "folia-latest", + "port": 63620, + "purpose": "實驗性 Folia smoke", + "requiredForRelease": false + } + ] +} From d58ea8bef4705d28f94395fe4d07fabde7806692 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Tue, 22 Sep 2026 22:21:27 +0800 Subject: [PATCH 2/3] docs: record automated server smoke evidence --- .../2026-09-22-da2a1c8-automated-smoke.md | 34 +++++++++++++++++++ docs/testing/test-servers.md | 6 ++++ 2 files changed, 40 insertions(+) create mode 100644 docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md diff --git a/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md b/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md new file mode 100644 index 0000000..0856c43 --- /dev/null +++ b/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md @@ -0,0 +1,34 @@ +# `da2a1c8` 自動化伺服器 Smoke 證據 + +- 受測 InviteCode commit:`da2a1c8` +- JAR SHA-256:`F1C61E0B32F7EF3188DD0EEC0CFA149377B6A012EA86E666A89DC657D6439AE3` +- TestLab commit:`78fd831` +- 測試日期:2026-09-22 +- 範圍:不需要真人或玩家互動的啟動、儲存與停機 smoke + +## 結果 + +| Profile | Minecraft | Java | 結果 | +| --- | --- | --- | --- | +| `spigot-1.8.8` | 1.8.8 | `local-8` | 通過 | +| `spigot-1.12.2` | 1.12.2 | `local-8` | 通過 | +| `spigot-1.16.5` | 1.16.5 | `local-8` | 通過 | +| `spigot-latest` | 26.2 | `local-25` | 通過 | +| `paper-1.20.6` | 1.20.6 | `local-21` | 通過 | +| `paper-1.21.8` | 1.21.8 | `local-21` | 通過 | +| `paper-latest` | 26.2 | `local-25` | 通過 | +| `folia-latest` | 26.2 | `local-25` | 未執行:PaperMC 沒有 stable build | + +七個可用 profile 均符合下列結果: + +- 伺服器到達 `Done`,InviteCode 回報啟用。 +- `logs/latest.log` 通過嚴格 UTF-8 解碼。 +- 沒有 InviteCode linkage error、未處理例外、SQLite migration 失敗、legacy plugin 警告或 `No key layers`。 +- 首次啟動建立 `188416` bytes 的 SQLite DB 與 `32` bytes 的防濫用密鑰。 +- 伺服器接受 `stop` 或等價的正常 console 中止,所有矩陣 port 在測試後均已釋放。 + +另以相同 JAR 在 `spigot-1.8.8` 與 `paper-latest` 完成一次停止後重啟。兩個 profile 的 DB 與防濫用密鑰 SHA-256 在重啟前後保持不變,且第二次啟動沒有再次執行首次初始化。 + +## 尚未涵蓋 + +本次沒有把下列項目標記為通過,統一留待接近完成時的最終真人驗收:玩家與 Console 指令、Tab completion、聊天/Dialog 輸入、客戶端顏色與語系顯示、完整 Claim 流程及實際獎勵體驗。Folia 也尚未取得可用的 stable 測試核心。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 7617c14..50f270a 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -72,3 +72,9 @@ pwsh -NoProfile -File .\scripts\test-servers\start.ps1 -Profile paper-latest 6. 驗證離線 Reward 補發與 restart recovery;需要外部整合的 profile 再加入 Vault/PlaceholderAPI。 各次測試應記錄 `workspace.json`、受測 commit、JAR SHA-256、操作結果與 `logs/latest.log`。實際相容性證據尚未取得前,不得只因實例能建立就宣稱該版本受到支援。 + +## 自動檢查與最終真人驗收 + +日常開發與各功能階段先由 Agent 執行不需要玩家判斷的檢查,包括 Gradle 測試、JAR 結構與 Java 8 bytecode、伺服器啟動與正常停機、log 錯誤掃描、UTF-8 解碼、SQLite/防濫用密鑰初始化,以及適用時的重啟持久化。這些結果須綁定受測 commit 與 JAR SHA-256。 + +需要真人觀察或實際玩家操作的項目集中到插件功能接近完成、準備發行候選版本時執行一次完整驗收,包括指令與 Tab completion、聊天及 Dialog 輸入、顏色與語系顯示、Claim/Confirmation/Status/Stats,以及實際獎勵體驗。延後的真人項目維持「待最終真人驗收」,不得因自動 smoke 通過而標記為已通過,也不阻擋仍在開發中的本機 checkpoint。 From 729214bf87f439f2fff199f1eae747a256dd88bf Mon Sep 17 00:00:00 2001 From: Command1264 Date: Tue, 22 Sep 2026 22:27:05 +0800 Subject: [PATCH 3/3] docs: add console command smoke evidence --- docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md b/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md index 0856c43..a458938 100644 --- a/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md +++ b/docs/testing/evidence/2026-09-22-da2a1c8-automated-smoke.md @@ -29,6 +29,8 @@ 另以相同 JAR 在 `spigot-1.8.8` 與 `paper-latest` 完成一次停止後重啟。兩個 profile 的 DB 與防濫用密鑰 SHA-256 在重啟前後保持不變,且第二次啟動沒有再次執行首次初始化。 +同一組最低/最新邊界也由 server console 自動執行 `/ic help`、`/ic reload`、`/ic admin doctor` 與 `/ic status`。Help 與 reload 正常回覆;doctor 回報 `Runtime=ACTIVE`、SQLite schema 8、Reward backlog 全為 0,且沒有 Vault/PlaceholderAPI;玩家專屬的 status 從 Console 明確回覆「此指令只能由玩家執行」。兩個 profile 均未產生 command exception 或缺少語系訊息。 + ## 尚未涵蓋 本次沒有把下列項目標記為通過,統一留待接近完成時的最終真人驗收:玩家與 Console 指令、Tab completion、聊天/Dialog 輸入、客戶端顏色與語系顯示、完整 Claim 流程及實際獎勵體驗。Folia 也尚未取得可用的 stable 測試核心。