This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an assessment workflow which is based on the Migration Analysis infra workflow. The main differne is that the checker of that workflow downloads the html report and tries to extract a table of scores of issues found by the analysis. The ProcessAnalysisTask has a predicate passed in the constructor to test against the scores of the analysis and based on that the task returns the passOption or the defaultOption. The passOption is the next flow to invoke, that should be the move2kube. The flow is roughly: Start - Infra flow start - submit analysis report - End Start - Checker flow start - check report is ready - switch (is ready?) yes -> go to parse no -> go to check report is ready - parse - switch (match incidents on predicate) true - return pass option (move2kube) false - return default option - End Signed-off-by: Roy Golan <rgolan@redhat.com>
- Loading branch information
Showing
19 changed files
with
470 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...dos-model-api/src/main/java/com/redhat/parodos/workflow/task/infrastructure/Notifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.redhat.parodos.workflow.task.infrastructure; | ||
|
||
import com.redhat.parodos.notification.sdk.model.NotificationMessageCreateRequestDTO; | ||
|
||
public interface Notifier { | ||
|
||
void send(NotificationMessageCreateRequestDTO message); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...rc/main/java/com/redhat/parodos/examples/prebuilt/migrationtoolkit/MTAAnalysisReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.redhat.parodos.examples.prebuilt.migrationtoolkit; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Element; | ||
|
||
public class MTAAnalysisReport { | ||
|
||
/** | ||
* migrationIssuesReport is assumed to be valid html. MTA 6.1 should supply a CSV as | ||
* well. Throw and exception when the parsing fails or if it can't extract data | ||
*/ | ||
public record AnalysisIncidents(int mandatory, int optional, int potential, int cloudMandatory, int cloudOptional, | ||
int information) { | ||
} | ||
|
||
/** | ||
* Extract an AnalysisIncident from the report index html page | ||
* @rpeortIndex is the content the page | ||
* /report/reports/report_index_{name_of_project}.html | ||
*/ | ||
public static AnalysisIncidents extractIncidents(String reportIndex) throws Exception { | ||
var doc = Jsoup.parse(reportIndex); | ||
|
||
var tables = doc.select("tbody#incidentsByTypeTBody"); | ||
if (tables.size() == 1) { | ||
var t = tables.get(0); | ||
int mandatory = countOf(t, "mandatory"); | ||
int optional = countOf(t, "optional"); | ||
int potential = countOf(t, "potential"); | ||
int cloudMandatory = countOf(t, "cloud-mandatory"); | ||
int cloudOptional = countOf(t, "cloud-optional"); | ||
int information = countOf(t, "information"); | ||
|
||
return new AnalysisIncidents(mandatory, optional, potential, cloudMandatory, cloudOptional, information); | ||
} | ||
throw new Exception("Didn't find a table to parse and extract incidents from"); | ||
} | ||
|
||
private static int countOf(Element t, String column) throws Exception { | ||
var element = t.select("td:matches(^%s)".formatted(column)); | ||
if (element != null && !element.isEmpty()) { | ||
try { | ||
String count = element.next().select("td.numeric-column").text(); | ||
return Integer.parseInt(count); | ||
} | ||
catch (NumberFormatException | NullPointerException e) { | ||
throw new Exception("Failed to extracts columns information from the table", e); | ||
} | ||
} | ||
throw new Exception("Failed to find or parse a table cell with text " + column); | ||
} | ||
|
||
} |
Oops, something went wrong.