-
Notifications
You must be signed in to change notification settings - Fork 110
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
RSDK-9087 Test setup phase #4483
RSDK-9087 Test setup phase #4483
Conversation
4f61647
to
c69e84c
Compare
9241b8d
to
1a456f3
Compare
d9d985c
to
26e8e24
Compare
26e8e24
to
ab997cf
Compare
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! some questions and suggestions
@@ -248,6 +249,7 @@ func (m Module) EvaluateFirstRunPath(packagesDir string) ( | |||
|
|||
firstRunSuccessPath := unpackedModDir + FirstRunSuccessSuffix | |||
if _, err := os.Stat(firstRunSuccessPath); !errors.Is(err, os.ErrNotExist) { | |||
logger.Info("first run already ran") |
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.
will this not be double logged?
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.
it shouldn't - where do you see potential for a double log?
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.
because it returns an error saying the same thing - just wondering, wasn't sure if that would happen
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.
oh yeah, sorry you are right - the error from this function is logged at the debug level, so we get a double log in that scenario. this should get cleared up when we refactor this function. the current contract requires we return an error here to prevent first run logic from firing. we can change the text in the error to prevent a double-log in the meantime.
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.
since it only happens during debug, I think it's better to address during the upcoming refactor PR
module/testmodule/first_run.sh
Outdated
#!/usr/bin/env bash | ||
|
||
if [[ -n "$VIAM_TEST_FAIL_RUN_FIRST" ]]; then | ||
>&2 echo "erroring... 1" |
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.
can you add a comment to that effect?
This reverts commit b59505e.
sorry, which comment/effect are you referring to here? |
two other changes: * clarify docs near logs.TakeAll() * handle unsetting environment variables in between sections
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.
made a function to clarify what's going on: 9f4a614 |
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.
generally looks good, can you use wait groups so that the stdout and stderr workers are properly awaited?
done ee08599. unfortunately we still need to sleep in the script for tests to pass - i was hoping this would remove the need :( |
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.
LGTM!
testutils/file_utils.go
Outdated
// resulting executable binary into a temporary directory. If successful, this function will | ||
// return the path to the executable binary. | ||
func BuildTempModule(tb testing.TB, modDir string) string { | ||
// tb.Helper() |
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.
can you revert these
testutils/file_utils.go
Outdated
// and "first_run.sh" into the same temporary directory. It is assumed that these files are in the | ||
// provided module directory. If successful, this function will return the path to the executable binary. | ||
func BuildTempModuleWithFirstRun(tb testing.TB, modDir string) string { | ||
// tb.Helper() |
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.
plus this
ugh, yes great catch. I was briefly debating whether it's worth removing this permanently so we can see exactly which lines of this helper fail. However, that goes against the idea of a helper function and will probably make tests that use it harder to debug in the future. |
Summary
Add basic tests for for first run, mainly asserting based on expected logs. Test the following scenarios, in order:
In addition, this PR refactors the
BuildTempModule
helper for clarity.Prerequisites
TODO
io.Copy
Fix flakes - likely due to inconsistent stdio/stderr echos from first run scriptFixed sources of flakes - for details see RSDK-9087 Test setup phase #4483 (comment)