-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Test] Allow configuring configDir for the Java test cluster #125094
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
[Test] Allow configuring configDir for the Java test cluster #125094
Conversation
For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster.
Pinging @elastic/es-delivery (Team:Delivery) |
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 won't allow for the more nuanced setup of file-settings (which normally happen through a symlinked directory that is swapped atomically). Why not expose the config directory directly and let the test do with it as it wants?
👍 I'd prefer something like this rather than adding additional methods to FWIW, if you need to update the contents of an existing file on the fly, this is already possible via |
As a general principle we want to keep the |
Would that point all nodes to the same directory? I don't think we need per-node config right now, but it's a legitimate scenario to test, and I assume someone will want it eventually (and we'll keep extending |
Depends if it's configured at the "cluster" or "node" level. Anything on |
I was looking into this bit as well. IIUC, for node level we will use something like |
Right, it wouldn't work to use it at the cluster level unless the nodes were also all configured the same (or there was just a single node). |
What would this be necessary for? We can already override the data dir and repo dir via corresponding settings. We'd basically just be adding a convenient way to do the same for the config dir. I can't think of any reason we should be mucking with other stuff in the distribution in normal tests. |
I'm also just remembering that we try when at all possible to symlink most of the ES distribution files to avoid excess copies. Therefore exposing those directories such that their contents could be modified in tests could cause all sorts of issues. |
The intetion for my suggestion of |
Or we can throw in |
I'd allow it for convenience. Single node clusters, or cluster where all nodes are configured identically, still make up the majority of our tests. Also, as mentioned above, this footgun already exists for other things. You can configure |
I updated the PR based on the suggestion of a
This is now ready for another look. Thank you! |
I don't think it's necessary to use a
The solution here is to use
Conditioning on the node name seems like a pretty specific use case. I'm not sure this is that compelling vs just doing |
…n-java-test-cluster
@mark-vieira I updated the PR to have a I made it work for my test. But I could not simply use a |
We do something similar in the temp dir rule for entitlements, see EntitlementsTestRule. We must make sure to be lazy in evaluation of config for the cluster since the rule will not have been run yet when the cluster object is being built. |
I think adding a supplier variant here makes sense. We have this elsewhere for many configuration methods as there are some things we don't want to evaluate until the cluster starts. |
T jvmArg(String arg); | ||
|
||
/** | ||
* Register a function to compute config directory based on the node name. The default config 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.
I think we need to update this javadoc now.
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.
Yep. updated in d8bb5cd
for (Path file : configFiles.toList()) { | ||
Path relativePath = distributionDir.resolve("config").relativize(file); | ||
Path dest = configDir.resolve(relativePath); | ||
Path dest = configDir.resolve(relativePath.toFile().getPath()); |
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.
Why do we need to do this path -> file -> path conversion?
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 last conversion gives a String. The reason is that temporary directory created by Lucene temporariy directory, e.g. LuceneTestCase#createTempDir
returns a Lucene FilterDirectory
which always works for resolve(String)
but throws for resolve(Path)
if the given Path
argument is not also a FilterDirectory
. Since I changed the other PR to use Junit's TemporaryDirectory, this is no longer an issue for now. But I think it might be worthwhile to keep the change so that it does not just break if someone decides to use Lucene temporary in future?
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 don't have super strong feelings about working around idiosyncrasies with lucene types. Can this be simplified to relativePath.toString()
?
Thanks for the reviews! I updated the PR to have a |
private final List<SystemPropertyProvider> systemPropertyProviders; | ||
private final Map<String, String> systemProperties; | ||
private final List<String> jvmArgs; | ||
private final Supplier<Path> configDirSupplier; |
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.
FWIW, I don't think we need to plumb laziness all the way through to the spec here. We only build the spec once we attempt to start the server, at which point everything we depend on needs to be initialized anyway. Let's just make this a Path
to make downstream usages simpler.
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.
Makes sense. Pushed 0651da0
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.
On minor comment, otherwise LGTM.
@elasticmachine update branch |
…#125094) For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory.
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
#125708) For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory. (cherry picked from commit a1b0ed1) Co-authored-by: Yang Wang <[email protected]>
#125707) For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory. (cherry picked from commit a1b0ed1) Co-authored-by: Yang Wang <[email protected]>
#125706) For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory. (cherry picked from commit a1b0ed1) Co-authored-by: Yang Wang <[email protected]>
…#125094) For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory.
For creating and deleting projects in multi-project tests, we need create and delete settings and secrets files on the fly. This PR adds such feature to the Java test cluster with an option to specify the config directory.