-
Notifications
You must be signed in to change notification settings - Fork 19
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: send graphql request to update report with coverage data #176
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,17 +221,16 @@ public static void FindCoverage(String testSet) throws IOException, InterruptedE | |
String dest = "target/" + testSet + ".exec"; | ||
String jacocoCliPath = getJacococliPath(); | ||
List<String> command = Arrays.asList( | ||
"java", | ||
"-jar", | ||
jacocoCliPath, | ||
"dump", | ||
"--address", | ||
"localhost", | ||
"--port", | ||
"36320", | ||
"--destfile", | ||
dest | ||
); | ||
"java", | ||
"-jar", | ||
jacocoCliPath, | ||
"dump", | ||
"--address", | ||
"localhost", | ||
"--port", | ||
"36320", | ||
"--destfile", | ||
dest); | ||
|
||
// Start the command using ProcessBuilder | ||
ProcessBuilder processBuilder = new ProcessBuilder(command); | ||
|
@@ -552,6 +551,11 @@ public static void runTests(String jarPath, RunOptions runOptions) { | |
if (appErr != null) { | ||
throw new AssertionError("error stopping user application: " + appErr); | ||
} | ||
|
||
Boolean updateReportResult = udpateReportWithCoverage(testRunId, testSet); | ||
if (!updateReportResult) { | ||
throw new AssertionError("error updating report with coverage data"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 |
||
} | ||
} | ||
// unload the ebpf hooks from the kernel | ||
// delete jacoco files | ||
|
@@ -566,7 +570,7 @@ public static void startKeploy(String runCmd, int delay, boolean debug, int port | |
Runnable task = () -> runKeploy(runCmd, delay, debug, port); | ||
Thread thread = new Thread(task); | ||
thread.start(); | ||
return ; | ||
return; | ||
} | ||
|
||
public static void runKeploy(String runCmd, int delay, boolean debug, int port) { | ||
|
@@ -805,6 +809,50 @@ public static RunTestSetResult runTestSet(String testRunId, String testSetId, St | |
} | ||
} | ||
|
||
public static Boolean udpateReportWithCoverage(String testRunId, String testSetId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck> reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck> reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck> reported by reviewdog 🐶 |
||
HttpURLConnection conn = setHttpClient(); | ||
if (conn == null) { | ||
logger.error("Could not initialize HTTP connection."); | ||
return false; | ||
} | ||
|
||
String payload = String.format( | ||
"{\"query\": \"mutation updateReportWithCov{ updateReportWithCov(testRunId: \\\"%s\\\", testSetId: \\\"%s\\\", language: \\\"java\\\") }\"}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 |
||
testRunId, testSetId); | ||
|
||
try { | ||
conn.setDoOutput(true); | ||
try (OutputStream os = conn.getOutputStream()) { | ||
os.write(payload.getBytes()); | ||
os.flush(); | ||
} | ||
|
||
int responseCode = conn.getResponseCode(); | ||
logger.debug("Status code received: " + responseCode); | ||
|
||
if (responseCode >= 200 && responseCode < 300) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck> reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck> reported by reviewdog 🐶 |
||
String resBody = getResponseBody(conn); | ||
logger.debug("Response body received: " + resBody); | ||
|
||
// Parse the response body using Gson | ||
Gson gson = new Gson(); | ||
GraphQLResponse response = gson.fromJson(resBody, GraphQLResponse.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 |
||
|
||
if (response.data == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} else { | ||
logger.error("Failed to update report with coverage data. Status code: " + responseCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 |
||
return false; | ||
} | ||
} catch (Exception e) { | ||
logger.error("Error updating report with coverage data: " + e.getMessage(), e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶 |
||
return false; | ||
} | ||
} | ||
|
||
public static class StopHooksResult { | ||
Boolean success; | ||
String error; | ||
|
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.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 90).