-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tester
Service bug fixes (mostly around panicked test handling)
#359
Conversation
…ion, filter then not filtered call bug fix
…#357) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.16.1 to 0.17.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.16.1...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
) Bumps goa.design/goa/v3 from 3.14.4 to 3.14.5. --- updated-dependencies: - dependency-name: goa.design/goa/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
`tester` : Make synch panic handling work, get name of panicked test via reflection, filter then not filtered call bug fix
simplify how `TestAll` works
…th (the name retreived from reflection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, the TL;DR is that It would be good to come up with a solution that does not involve reflection.
log.Infof(ctx, "RUNNING TEST [%v]", testName) | ||
f(ctx, testCollection) | ||
}(test, n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous version was much better :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raphael not sure I follow, I took the testName out because I am using getTestName and didn't need to pass in testName anymore to the goroutine. If I figure out how to get testName without reflection this may go back though.
} | ||
defer recoverFromTestPanic(ctx, testNameFunc, testCollection) | ||
for _, test := range testsToRun { | ||
testName = getTestName(test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the need for getTestName
. In general using reflection for a service at runtime isn't great (it's slow) and a bit of a code smell. At the very least if we were to use getTestName
we could get rid of lines 218-221. But it would be much better to find a solution that does not require it. Is testsToRun
not indexed by test name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raphael It is, but I was having trouble getting the true test name in the case of wildcard filters. I'll take some time to see if I can't rework this. If I fail to do that I may need to keep it though so that the true test name is returned, especially when there is a panic so that the exact test that is panicking can be identified
io.Copy(&buf, f) // nolint: errcheck | ||
outC <- buf.String() | ||
_, err := io.Copy(&buf, f) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure the if
is required. If the error is nil then outErr <- err
works fine and if there's an error then buf.String()
should return ""
(buffer is empty).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK cool. I was being overly cautious. :) Will change
return out | ||
if err := <-outErr; err != nil { | ||
return "", err | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else
is not needed.
if err != nil { | ||
err = fmt.Errorf("error getting stack trace for panicked test: %v", err) | ||
resultMsg := err.Error() | ||
testCollection.AppendTestResult(&gentester.TestResult{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be taken out of the if
(since the else
does the same thing).
@raphael I figured it out using a regex instead of a glob. This eliminates the need for reflection. Take a look and let me know what you think. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #359 +/- ##
=======================================
Coverage 93.24% 93.24%
=======================================
Files 32 32
Lines 1822 1822
=======================================
Hits 1699 1699
Misses 100 100
Partials 23 23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
defer wg.Done() | ||
defer recoverFromTestPanic(ctx, testName, testCollection) | ||
log.Infof(ctx, "RUNNING TEST [%v]", testName) | ||
testName := "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified to:
testNameFunc := func() string {
return testNameRunning
}
No need for the testName
variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raphael fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left a small comment
run_tests.go
defer w.Close()
that was making it hang + it needed to check for error fromio.Copy
test_methods.go
TestAll
works. Instead of calling the other goa gRPC funcs (TestLocator, TestForecaster) call runTests directly and define the collections in TestAll. This makes it so I don't have a global filtering payload var, which was causing a bug when you make a filtered TestAll call then try to make an unfiltered call (filtering not available except for TestAll) to another func like TestSmoke.