Refactor how skipped tests are defined
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先阅读 issue 中描述的 runtime.SkipIf 实现以及现有的 mscXXXX_test.go 组织方式。跟踪 build tags 如何选择测试,以及 runtime 如何检测 homeserver,然后将该行为与提议的用户配置和基于 t.Skipf 的执行方式进行比较。完成的标准是:设计支持易于发现的测试组、用户的显式选择、确定性的跳过,以及移除由 runtime 驱动的 blacklist 行为。
由索引模型根据 Issue 内容生成。
描述
Complement was designed to test the Matrix Specification. However, the spec isn't static and MSCs need tests too. We introduced the build tag system a long time ago to allow tests to opt-in to certain tests. They are defined like this:
//go:build msc3391
// +build msc3391
package tests
// ... rest of code
and used like this:
go test -tags "msc3083 msc3787 msc3874" ./...
The set of tests run is controlled by the user, which can be frustrating when they get out-of-sync: https://github.com/matrix-org/complement/issues/185
This wasn't the end of it though. We also have unique APIs specific to a homeserver, or sometimes some servers don't implement core features which are enabled by default. To fix this, we (ab)use the same build tag system. To opt-out of a test, they are defined like this:
//go:build !dendrite_blacklist
// +build !dendrite_blacklist
package tests
// ... rest of code
and used like this:
go test -tags "dendrite_blacklist" ./...
This was the status quo for a long time, until there was a need to blacklist some tests in the same file but not others. This introduced the runtime package, where you could skip a test in code, rather than conditional compilation. They are defined like this:
func TestRoomImageRoundtrip(t *testing.T) {
runtime.SkipIf(t, runtime.Dendrite)
// .. rest of test
}
A runtime knows what it is by the virtue of the blacklist tag. E.g running -tags "dendrite_blacklist" would skip this test, even if the homeservers were synapse! The code for this is:
//go:build dendrite_blacklist
// +build dendrite_blacklist
package runtime
import (
"context"
"time"
"github.com/docker/docker/client"
)
func init() {
Homeserver = Dendrite
}
This is clearly at odds with testing between heterogeneous homeservers. It's also been questioned if it is the test's job to say what can and cannot run with it. Surely it would be better if it were more tag-like, and the user can opt-in to these tests?
We also have some other ideas for conditional execution of tests based on /versions output: https://github.com/matrix-org/complement/issues/549 . Our forebear, sytest, would automatically skip some tests based on if an earlier test which has a special can_ property did not pass. This is problematic if the can_ test is flakey!
From these use cases, there are some properties we want the test execution API to have:
- granular but not too granular: MSC level is about right. Skipping entire files isn't great as the files are mostly arbitrary collections of tests.
- The user should specify which tests to execute. It's a bit of a smell that Complement dictates this currently via
runtime.SkipIf, and it means that this repository gets touched way too much just to remove these lines as servers get updated. - We don't want the set of tests executed to be nondeterminstic (dependent on a server response or a passing/failing previous test) as that is way too unstable and flakey.
A high-level approach here could be:
- One file per group of tests. Similar to
mscXXXX_test.gofiles. - Make test names part of the public testing API.
- Allow users to specify a set of groups / tests to run / not run.
This would allow us to remove runtime.SkipIf from the codebase, and runtime detection which is flakey and doesn't work with multi-HS support. It also removes the smell of having tests dictate what can/cannot run.
Proposal
- Define a configuration format for specifying the list of groups / test names to run. The list of valid groups/tests must be easily discoverable (autogen from code, like we do with env vars?)
- Read the configuration format and skip appropriately. Always use
t.Skipfinstead of conditional compilation? This would be beneficial as it is not uncommon for conditionally compiled code to break API wise from core (e.g alter a function signature in core, then patch up tests which whine, the mscXXXX files won't whine due to no build tags set by default in the IDE). - This implies some kind of test helper/executor that runs before every test, which isn't ideal as it starts to obfuscate what code runs when you hit test. Could just add it as boilerplate though?
- 主要语言
- Go
- 星标
- 101
- 派生
- 73
- 平均合并
- 4 天 21 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
matrix-org/complement 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
matrix-org/complement#900 · 1 条评论 ·
维护者通常 3 天内回复
-
难度 5/5 一周以上 新手友好度 45/100
matrix-org/complement#938 ·
维护者通常 3 天内回复
-
New tests for MSC4354 Sticky Events可能重新可做 @reivilibre 于 34 天前认领,目前没有进行中的 PR。 未关闭
matrix-org/complement#925 · 已指派 1 人 ·
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 52/100
matrix-org/complement#901 · 1 条评论 ·
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
matrix-org/complement#899 ·
维护者通常 3 天内回复
查看 matrix-org/complement 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
agent-butler-finding bug
难度 2/5 1-3 小时 新手友好度 78/100
jordansmall/spindrift#6161 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
open-telemetry/opentelemetry-go-compile-instrumentation#1635 ·
维护者通常 2 天内回复
-
C-bug O-community X-blathers-untriaged
难度 1/5 1 小时以内 新手友好度 84/100
cockroachdb/cockroach#176210 · 1 条评论 ·
-
VLAgent `spec.k8sCollector.includePodLabels: false` has no effect可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
VictoriaMetrics/operator#2772 ·
维护者通常 1 天内回复