-
Notifications
You must be signed in to change notification settings - Fork 44
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
NCL-6053: pig - .bacon dir in a temp loc #459
base: main
Are you sure you want to change the base?
NCL-6053: pig - .bacon dir in a temp loc #459
Conversation
Codecov Report
@@ Coverage Diff @@
## master #459 +/- ##
========================================
Coverage 5.48% 5.48%
Complexity 103 103
========================================
Files 133 133
Lines 4994 4994
Branches 463 463
========================================
Hits 274 274
Misses 4701 4701
Partials 19 19
Continue to review full report at Codecov.
|
log.debug("stderr:{}{}", System.lineSeparator(), result.getError()); | ||
assertThat(result.getRetval()).isZero(); | ||
return result.fromYAML(clazz); | ||
} | ||
|
||
protected ExecutionResult executeAndGetResult(String... args) { | ||
return executor.runCommand(args); | ||
return executor.runCommand(null, args); |
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.
So this sets the dir
argument of Runtime.exec()
to null
which means $CWD
, but I still don't really like that it will create this dir anywhere I run it. I think picking a single location would be better.
The other issue is because it's not a unique location, it would be possible to run the run
with one project and release
with another project using the same .bacon/
directory, and what would happen then?
I kind of like $HOME/.bacon/<project_id>/
or something similar.
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.
Great points - I think we need to understand its purpose before choosing a solution.
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.
By default the .bacon directory it's created where the program is executed. The location can be overriden with an environment varialbe and a system property.
Current directory was chosen as a default to allow running the tool for multiple projects separately.
If the config yaml or any other file in the config dir would change, the context will be dropped (the previous one won't be read and will be overwritten at the end of the execution). It's checked by storing a hash sum of all files in the directory (and their locations, moving a file is also considered a change).
executeAndGetResult
is also used for non-pig tests, for it I haven't changed the working directory (hence the null here)
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 think it would be better to use a Junit tmp dir here and pass that through?
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.
Ah, I've just seen down below you are passing a TempDir in :-) What about changing for all tests so they consistently run from a tempDirectory - or do some require a certain context pwd?
What is the bacon dir used for? Is it needed by users after a run? |
I believe it stores the state for a particular But, that makes it specific to a particular |
pig context stores data between executions of pig. |
What data specifically can be shared between runs? In any case, a change in project should cause the configuration to be invalidated. It seems easier to me to just store the configuration under some unique key derived from the project name or something else. I noticed also having to set the pnc configuration file via an environment variable. This is a bit odd and not usually how other programs work. I'd expect to set it via a program flag, if anything, as the defaults should also be reasonable to begin with. |
@michalszynkiewicz Interesting, thanks. How does it know whether to invalidate it or not? I wonder if it would be better to have this as an option flag - it could default to , as @dwalluck suggested $Home/.bacon but can be overridden to use a current directory. This would solve the problem with these hidden directories being left lying around, would still allow the same flexibility and the tests could use it with a temp dir. Also... is this documented?! |
there's a Re using env variable for the location, I think it's better than system property or parameter because you can set it in your |
Regarding how does it know, I calculate a hash of the pig configuration directory. |
@@ -29,13 +30,15 @@ static String init(Path configDir, boolean clean, Optional<String> releaseStorag | |||
String suffix = prepareSuffix(); | |||
// todo release storage url mocking | |||
if (configDir == null) { | |||
throw new FatalException("You need to specify the configuration directory!"); | |||
throw new RuntimeException("You need to specify the configuration directory!"); |
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.
FatalException extends runtimeexception - why the change here?
} | ||
System.setProperty(PIG_CONTEXT_DIR, targetDirectory.toString()); |
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 think tests that set system properties should use https://github.com/stefanbirkner/system-lambda (https://github.com/stefanbirkner/system-rules for JUnit4)
@@ -196,7 +196,7 @@ private static PigContext readContext(boolean clean, Path configDir) { | |||
String sha = hashDirectory(configDir); | |||
|
|||
PigContext result; | |||
String ctxLocationEnv = System.getenv(PIG_CONTEXT_DIR); | |||
String ctxLocationEnv = System.getProperty(PIG_CONTEXT_DIR, System.getenv(PIG_CONTEXT_DIR)); |
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.
For reference, for perhaps a future consideration, picocli supports default values of e.g. environment variables ( https://picocli.info/#_variable_interpolation ) so it could be a parameter as well.
Could you create a separate JIRA then please? As mention in one of my comments, picocli supports parameters with environment variables I think - that also could be a separate ticket perhaps? |
Checklist: