Closed samanhappy closed 2 months ago
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Attention: Patch coverage is 86.56716%
with 9 lines
in your changes missing coverage. Please review.
Project coverage is 89.29%. Comparing base (
eef3a25
) to head (615c2f3
). Report is 65 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
monkey/monkey.go | 86.56% | 7 Missing and 2 partials :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Refined: The SIGBUS error still occurs occasionally, as seen here, and I haven't found a solution yet.
Refined: The SIGBUS error still occurs occasionally, as seen here, and I haven't found a solution yet.
Try to fix it, then you will be the new monkey king!
Bad news: It appears that the SIGBUS error is related to the Gomonkey library, as discussed in this issue.
Good news: I've discovered a new monkey patching library bytedance/mockey. After replacing gomonkey
with it, the test results are looking promising so far.
@proditis Thanks so much for your testing efforts! The random errors are also unacceptable to me. To help us investigate further, could you please provide the following information about your test environment:
My system is Linux x86_64 and go version go1.23.0 linux/amd64.
I will repeat the tests to try to figure out what is causing this failure. Will keep you posted
edit: Please find attached the output from two failed tests test1.log & test2.log
As far as i can see all failed tests are related to the TestOpenLogFail
tests.
I took a closer look at the failed test. Do we need to monkey.patch this call?
I think that with a bit of rework on this test case we may be able to get rid of this error.
Sorry for the delayed response. I reviewed the two error logs and the original TestOpenLogFail
code. Here are some thoughts:
Both failures occur within the lumberjack library's internal functions. We need to determine whether these errors are caused solely by lumberjack or if our patch operations are contributing to the issue.
While the patch call in the image you attached is necessary, the patch call starting at line 188 (shown below) doesn't seem to have any effect on our test:
var lum *lumberjack.Logger
monkey.PatchInstanceMethod(reflect.TypeOf(lum), "Rotate", func(_ *lumberjack.Logger) error {
return fmt.Errorf("error")
})
I couldn't reproduce the error on my MacBook. My suggestion is to remove this patch code and run the tests again on your system to determine whether the issue originates from the library or the patch. Does that sound like a good plan?
Hi thanks for the feedback, although i still dont understand why these calls need to be patched :rofl:
I commented out the following
//var lum *lumberjack.Logger
// monkey.PatchInstanceMethod(reflect.TypeOf(lum), "Rotate", func(_ *lumberjack.Logger) error {
// return fmt.Errorf("error")
// })
Rerun the tests and got the following error test3.log
PS: This is how I run my tests in case it helps, i am getting a failed run every ~20-40 runs
fail=0; runs=1; while [ "$fail" -eq 0 ];do echo "[$runs] Running tests"; make test >test.log || ((fail=fail+1)); ((runs=runs+1)); done
Many thanks to @proditis for helping us resolve the random errors. @suchen-sci, you can now review this PR again.
Sorry for the delayed response... LGTM!
Oops, the SIGBUS: bus error
still exists as show here !
Oops, the
SIGBUS: bus error
still exists as show here !
I dont have a mac to run tests, but i suspect the same errors will come up with OpenBSD as well, so i'll prepare a system to run tests and see what fails. OpenBSD is much more strict with these types of violations, so hopefully we'll be able to catch most of these errors.
Could this failure be logger related also?
PS: Maybe we need to open an issue to keep track of these crashes and close it only after we have run enough tests to ensure we fixed all such failures?
I'm not sure if these errors are related to the logger, but all the SIGBUS: bus error
occurrences seem to be specific to macOS-arm64.
I've opened an issue as per your advice. Let's track the progress there and keep each other updated on any developments.
As mentioned in #519, the
bou.ke/monkey
library has been archived for a long time and fails on themacos-arm64
architecture. Consequently, we need to find an alternative library.After extensive testing, I found that
gomonkey
bytedance/mockey
is the only library that works, although its APIs are not compatible withbou.ke/monkey
. To address this, I have introduced a separate monkey module in EaseProbe that encapsulates thegomonkey
bytedance/mockey
library. This approach minimizes the cost of modifying test code and allows us to easily replace the library in the future without affecting our test code.Key code changes include:
-gcflags=-l
to-gcflags=all=-l
to accommodate changes forgomonkey
bytedance/mockey
.bou.ke/monkey
togithub.com/megaease/easeprobe/monkey
. However, inprobe/ssh/ssh_test.go
, where the original usage was unsupported, I modified the logic accordingly.monkey/monkey.go
, I used async.Map
to store all patches, which supports reset operations. A notable method calledwait
employs busy waiting to prevent test failures onmacos-arm64
. The exact cause of these errors is unclear to me, and this is a workaround. If anyone has a better solution, please let me know, as I am not very familiar with the ARM64 architecture.Resolve #519