Skip to content
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

validate file based arguments point to existing files / directories #483

Merged
merged 3 commits into from
Mar 3, 2023

Conversation

jtnord
Copy link
Member

@jtnord jtnord commented Mar 3, 2023

if a File based paramter is set (excluding workingDir which we create) then parsing the arg will fail early rather than continuing and then erroring (or silently swallowing it) later in the run

fixes #449

tested with various arg combintions with option args present and valid, not present, and present and invalid

java -jar target\plugins-compat-tester-cli.jar --working-dir=work --war=LICENSE.txt --mvn=LICENSE.txt --external-hooks-jars=LICENSE.txt,pom.xml --maven-settings=sdf
Invalid value for option '--maven-settings': Specified file sdf does not exist
Usage: pct [-hV] [--[no-]fail-fast]
...
  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@jtnord jtnord changed the title simple validation for file based parameters validation file based arguments point to existing files / directories Mar 3, 2023
if a File based paramter is set (excluding workingDir which we create)
then parsing the arg will fail early rather than continuing and then
erroring (or silently swallowing it) later in the run

fixes #449
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

/**
* Converter that converts to a File that must exist (either as a directory or a file)
*/
public class ExistingFileTypeConverter implements ITypeConverter<File> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a more "rich" solution would have been to use JSR-380 based validation - this would pull in more code and still requires us to write a customer validator.

@@ -57,7 +58,8 @@ public class PluginCompatTesterCli implements Callable<Integer> {
@CommandLine.Option(
names = {"-w", "--war"},
required = true,
description = "Path to the WAR file to be used by the PCT.")
description = "Path to the WAR file to be used by the PCT.",
converter = ExistingFileTypeConverter.class)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whilst we could have set the default, workingDir would need to be default and we can not reference the default converters so would need yet another class.

@CommandLine.Option(
names = "--mvn",
description = "The path to the Maven executable.",
converter = ExistingFileTypeConverter.class)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguably this is incorrect but we already call getAbosultePath so we can not pass in something that we expect to be on the path.

@jtnord jtnord changed the title validation file based arguments point to existing files / directories validate file based arguments point to existing files / directories Mar 3, 2023
@jtnord
Copy link
Member Author

jtnord commented Mar 3, 2023

java17 build seems to be failing in the smoke test with /tmp/junit7880214900056192275/text-finder failed with exit status 143

This smells like a used to much memory and I killed you issue. given we are using multiple JVMs (maven, surefire, running the pct which runs maven and builds....) I expect we have an unconstrained JVM or 2 in the loop.

@@ -0,0 +1 @@
-Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+TieredCompilation -XX:TieredStopAtLevel=1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constrain the maven jvm memory. and don't attempt to to expensive JITing for a short lived process.

no profiling has been done - tested with 64m with mvn clean install and the build ran, doubled it for good measure

PluginCompatTesterTest runs the PCT which will run various maven. if the JVM is not configured (its not for the text-finder)
then we run a JVM that seems the host/container memory and assumes it is the only thing running leading to it being OOMKilled
-->
<MAVEN_OPTS>-Xmx256m -XX:+TieredCompilation -XX:TieredStopAtLevel=1</MAVEN_OPTS>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64m caused OOMexceptions, 128 was ok, doubled that number.

@@ -296,9 +297,18 @@
<artifactId>maven-surefire-plugin</artifactId>
<!-- Version specified in parent POM -->
<configuration>
<argLine>@{argLine} -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+TieredCompilation -XX:TieredStopAtLevel=1</argLine>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surefire is runnning the PCT code - no profiling has been performed.

-->
<MAVEN_OPTS>-Xmx256m -XX:+TieredCompilation -XX:TieredStopAtLevel=1</MAVEN_OPTS>
</environmentVariables>
<reuseForks>false</reuseForks>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PluginCompatTesterTest runs first which consumes the most amount of memory.
adds a little onto the build time - but for the sake of stable builds this is eaten up into the time for the smoke test.

@jtnord
Copy link
Member Author

jtnord commented Mar 3, 2023

test run timing

master (one less test) this pr
Java 11 2m 07s 2m 34s
Java 17 3m 27s 2m 29s

@jtnord jtnord requested a review from basil March 3, 2023 16:43
@jtnord jtnord marked this pull request as ready for review March 3, 2023 16:43
@jtnord jtnord requested a review from a team as a code owner March 3, 2023 16:43
@jtnord jtnord merged commit e2258a1 into master Mar 3, 2023
@jtnord jtnord deleted the check-file-params branch March 3, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

do not ignore incorrect localCheckoutDir
2 participants