-
Notifications
You must be signed in to change notification settings - Fork 122
[flaky test] race condition happens in unit test #1005
Copy link
Copy link
Open
Description
What happened?
Currently, unit tests are launched with -race -coverpkg=./... -gcflags=all="-l", and test can fail sometime.
After doing some digging work, I realize that this can be related with mockey. Because every race conditions h
appen between cgroup/common/path.go:112 +0x55 common.GetAbsCgroupPath() and policy_advisor_handler_test.go:105 dynamicpolicy.TestDynamicPolicy_checkAndApplyIfCgroupV1.func1().
2025-10-23T04:33:19.9290337Z ==================
2025-10-23T04:33:19.9290767Z WARNING: DATA RACE
2025-10-23T04:33:19.9291174Z Read at 0x00c000cc75d8 by goroutine 108:
2025-10-23T04:33:19.9291732Z internal/abi.(*IntArgRegBitmap).Get()
2025-10-23T04:33:19.9292675Z /opt/hostedtoolcache/go/1.18.10/x64/src/internal/abi/abi.go:101 +0x5a
2025-10-23T04:33:19.9293508Z reflect.moveMakeFuncArgPtrs()
2025-10-23T04:33:19.9294409Z /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/makefunc.go:167 +0xae
2025-10-23T04:33:19.9295150Z reflect.moveMakeFuncArgPtrs()
2025-10-23T04:33:19.9295690Z <autogenerated>:1 +0x44
2025-10-23T04:33:19.9296164Z reflect.makeFuncStub()
2025-10-23T04:33:19.9296986Z /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/asm_amd64.s:37 +0x45
2025-10-23T04:33:19.9298035Z github.com/kubewharf/katalyst-core/pkg/util/cgroup/common.GetAbsCgroupPath()
2025-10-23T04:33:19.9301669Z /runner/_work/katalyst-core/katalyst-core/pkg/util/cgroup/common/path.go:112 +0x55
2025-10-23T04:33:19.9303103Z github.com/kubewharf/katalyst-core/pkg/util/cgroup/common.GetKubernetesAbsCgroupPath()
2025-10-23T04:33:19.9304637Z /runner/_work/katalyst-core/katalyst-core/pkg/util/cgroup/common/path.go:137 +0xa8
2025-10-23T04:33:19.9306288Z github.com/kubewharf/katalyst-core/pkg/util/cgroup/common.GetKubernetesAnyExistAbsCgroupPath()
2025-10-23T04:33:19.9307948Z /runner/_work/katalyst-core/katalyst-core/pkg/util/cgroup/common/path.go:148 +0x337
2025-10-23T04:33:19.9309249Z github.com/kubewharf/katalyst-core/pkg/util/cgroup/common.IsCPUIdleSupported()
2025-10-23T04:33:19.9312501Z /runner/_work/katalyst-core/katalyst-core/pkg/util/cgroup/common/cgroup_linux.go:182 +0x4b
2025-10-23T04:33:19.9313863Z github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy.TestSchedIdle()
2025-10-23T04:33:19.9315465Z /runner/_work/katalyst-core/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go:5677 +0xa7
2025-10-23T04:33:19.9316461Z testing.tRunner()
2025-10-23T04:33:19.9317212Z /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1439 +0x213
2025-10-23T04:33:19.9318020Z testing.(*T).Run.func1()
2025-10-23T04:33:19.9318833Z /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1486 +0x47
2025-10-23T04:33:19.9321078Z
2025-10-23T04:33:19.9321348Z Previous write at 0x00c000cc75d8 by goroutine 21:
2025-10-23T04:33:19.9321885Z reflect.MakeFunc()
2025-10-23T04:33:19.9324498Z /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/makefunc.go:65 +0x21b
2025-10-23T04:33:19.9325287Z github.com/bytedance/mockey.(*Mocker).buildHook()
2025-10-23T04:33:19.9326445Z /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.11/mock.go:268 +0x867
2025-10-23T04:33:19.9327235Z github.com/bytedance/mockey.(*MockBuilder).Build()
2025-10-23T04:33:19.9329989Z /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.11/mock.go:216 +0x114
2025-10-23T04:33:19.9334743Z github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy.TestDynamicPolicy_checkAndApplyIfCgroupV1.func1()
2025-10-23T04:33:19.9344081Z /runner/_work/katalyst-core/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_advisor_handler_test.go:105 +0xfe
2025-10-23T04:33:19.9350381Z runtime.call16()
2025-10-23T04:33:19.9351331Z /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/asm_amd64.s:701 +0x48
2025-10-23T04:33:19.9356135Z reflect.Value.Call()
2025-10-23T04:33:19.9356932Z /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/value.go:339 +0xa9
2025-10-23T04:33:19.9359449Z github.com/bytedance/mockey/internal/tool.ReflectCall()
2025-10-23T04:33:19.9362271Z /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.11/internal/tool/call.go:36 +0x15b
2025-10-23T04:33:19.9363548Z github.com/bytedance/mockey.PatchConvey.func1()
2025-10-23T04:33:19.9366194Z /root/go/pkg/mod/github.com/bytedance/mockey@v1.2.11/convey.go:43 +0x1ce
2025-10-23T04:33:19.9366970Z reflect.callReflect()
2025-10-23T04:33:19.9387388Z /opt/hostedtoolcache/go/1.18.10/x64/src/reflect/value.go:742 +0x762
2025-10-23T04:33:19.9390274Z reflect.callReflect()
2025-10-23T04:33:19.9390873Z <autogenerated>:1 +0x64
I'm not expert of mockey, still need do more reasarch. or maybe add -N to gcflag to disable compiling optomize would be help?
What did you expect to happen?
no race
How can we reproduce it (as minimally and precisely as possible)?
see #1004
Software version
Details
$ <software> version
# paste output hereReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels