forked from konveyor/kantra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update application analysis CI tests
Updating structure of test-data and adding kantra anlyze tests also for java binary and java with maven settings file. Related to konveyor#233 Signed-off-by: Marek Aufart <[email protected]>
- Loading branch information
Showing
19 changed files
with
391 additions
and
2,722 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
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,50 @@ | ||
#!/bin/sh | ||
# | ||
# Usage: run_analysis_test <test-data-directory> | ||
# | ||
set -e | ||
|
||
if [ ! -d $1 ]; then | ||
echo "ERROR: Missing or invalid test-data directory." | ||
exit 1 | ||
fi | ||
test_dir=$1 | ||
cd ${test_dir} | ||
|
||
# Setup variables | ||
RUNNER_IMG="${RUNNER_IMG:-quay.io/konveyor/kantra:latest}" | ||
KANTRA_CMD="${KANTRA_CMD:-../../kantra}" | ||
TEST_APPS_ROOT="${TEST_APPS_ROOT:-../../hack/tmp}" | ||
|
||
# Run the analysis calling kantra | ||
. ./cmd | ||
kantra_exit=$? | ||
if [ "$kantra_exit" != 0 ]; then | ||
echo "ERROR: kantra command execution failed." | ||
exit $kantra_exit | ||
fi | ||
|
||
# Check analysis result | ||
expected_file=output.yaml | ||
actual_file=output/output.yaml | ||
function filter_and_sort() { | ||
yq e 'del(.[].skipped) | del(.[].unmatched)' $1 \ | ||
| yq e '.[]?.violations |= (. | to_entries | sort_by(.key) | from_entries)' \ | ||
| yq e '.[]?.violations[]?.incidents |= sort_by(.uri)' \ | ||
| yq e '.[] | (.tags // []) |= sort' | ||
} | ||
filter_and_sort $expected_file > $expected_file | ||
filter_and_sort $actual_file > $actual_file | ||
diff $expected_file $actual_file | ||
|
||
|
||
# Check dependencies | ||
if [ -f dependencies.yaml ]; then | ||
expected_file=dependencies.yaml | ||
actual_file=output/dependencies.yaml | ||
sed 's/^[ \t-]*//' $expected_file | sort -s > /tmp/expected_file | ||
sed 's/^[ \t-]*//' $actual_file | sort -s > /tmp/actual_file | ||
diff /tmp/expected_file /tmp/actual_file || diff $expected_file $actual_file | ||
fi | ||
|
||
exit 0 |
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,21 @@ | ||
# Analysis test data | ||
|
||
Subdirectories contain kantra analysis testcases files. The following structure is expected: | ||
|
||
``` | ||
cmd (kantra analyze command with options specific for given test case) | ||
output.yaml (expected analysis output yaml file) | ||
dependencies.yaml (optional, expected dependencies files created by analysis) | ||
``` | ||
|
||
A script `hack/run_analysis_test.sh` runs the kantra command and checks outputs. Exit code 0 is success, other failure. The script changes directory to the provided test-dir, so all paths there should be relative. | ||
|
||
## Tests execution | ||
|
||
Example usage from kantra project directory: | ||
|
||
``` | ||
$ ./hack/run_analysis_test.sh test-data/analysis/<test-dir> | ||
``` |
Oops, something went wrong.