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

feat: add closeDelay to support async calls coverage #177

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions v2/src/main/java/io/keploy/Keploy.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
private int port;
private String path;
private String appCmd;
private int closeDelay;

Check failure on line 33 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:33:9: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck)

public RunOptions() {
this(10, false, 6789, ".");
this(10, false, 6789, ".", 0);

Check failure on line 36 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 '10' is a magic number. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:36:18: error: '10' is a magic number. (com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck)

Check failure on line 36 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 '6789' is a magic number. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:36:29: error: '6789' is a magic number. (com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck)
}

public RunOptions(int delay, boolean debug, int port, String path) {
public RunOptions(int delay, boolean debug, int port, String path,int closeDelay) {

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 Line is longer than 80 characters (found 91). Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:0: error: Line is longer than 80 characters (found 91). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:9: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 Parameter delay should be final. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:27: error: Parameter delay should be final. (com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck)

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 'delay' hides a field. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:31: error: 'delay' hides a field. (com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck)

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 Parameter debug should be final. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:38: error: Parameter debug should be final. (com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck)

Check failure on line 39 in v2/src/main/java/io/keploy/Keploy.java

View workflow job for this annotation

GitHub Actions / checkstyle linting

[checkstyle] reported by reviewdog 🐶 'debug' hides a field. Raw Output: /github/workspace/./v2/src/main/java/io/keploy/Keploy.java:39:46: error: 'debug' hides a field. (com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck)
if (delay < 0) {
throw new IllegalArgumentException("Delay must be a positive integer.");
}
Expand All @@ -52,6 +53,11 @@
throw new IllegalArgumentException("Port must be a positive integer.");
}
this.port = port;

if (closeDelay < 0) {
throw new IllegalArgumentException("CloseDelay must be a positive integer.");
}
this.closeDelay = closeDelay;
}

// Getters and setters
Expand All @@ -66,6 +72,17 @@
this.delay = delay;
}

public int getCloseDelay() {
return closeDelay;
}

public void setCloseDelay(int closeDelay) {
if (closeDelay < 0) {
throw new IllegalArgumentException("CloseDelay must be a positive integer.");
}
this.closeDelay = closeDelay;
}

public boolean isDebug() {
return debug;
}
Expand Down Expand Up @@ -539,6 +556,12 @@
waitForTestRunCompletion(testRunId, testSet, appId);

try {
if (runOptions.getCloseDelay() > 0){
logger.info("waiting for {} seconds before closing the application in order to get coverage of async calls", runOptions.getCloseDelay());
//wait for closeDelay in order to get coverage of async calls as well
Thread.sleep(runOptions.getCloseDelay() * 1000);
}

Keploy.FindCoverage(testSet);

Thread.sleep(5000);
Expand Down
Loading