Repository navigation
test(host): SIGUSR1 重新读取的测试按任意顺序等待 reloaded 与行状态 - #578
Merged
Merged
Conversation
… order
The state lines are printed every 200 ms by their own task, apart from
what a reload prints, so a removed row's 'removed' can come before
'rutis-host: reloaded'. sigusr1_reloads_and_the_host_runs_on read lines
in order, consumed 'node-row: removed' while waiting for the reload and
then waited for it until the guard. The rejected '{' write was the
test's own broken step, not a half-written file.
The Node row's cleanup now takes 1 s, which makes that order certain:
the test failed every time before the change. The watched-config test
had the same wait.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修 `sigusr1::sigusr1_reloads_and_the_host_runs_on` 的偶发失败(#553、#561 的 CI)。
原因
不是读到写了一半的文件。日志里的 `reload rejected: …EOF while parsing an object at line 1 column 1` 是测试自己第一步写入的 `{`,本来就该被拒绝。真正卡住的是第二步:
```
"plugin node-row cleanup started",
"node-row: removed",
"rutis-host: reloaded …/rutis.json (1 row changed)",
```
状态行由 `status::follow` 在自己的任务里每 200 ms 打印一次,与 `reload` 打印的 `rutis-host: reloaded` 没有先后约定(指南只说“行的状态变化照常由状态行打印”)。测试按顺序读行:等 `reloaded` 时把先到的 `node-row: removed` 读掉了,之后再等 `node-row: removed` 直到超时。
产品侧:SIGUSR1 是用户写完后主动发的,`--watch-config` 已经在内容连续 500 ms 不变后才读(`reload::SETTLE`,指南有写),截断后再写的编辑器不会被读到中间状态。所以不改产品。
改动
测试:`cargo test -p rutis-host --test reload`,`cargo clippy -p rutis-host --tests`。