diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b264c526 --- /dev/null +++ b/.gitignore @@ -0,0 +1,97 @@ +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +.idea/**/aws.xml + +.idea/**/contentModel.xml + +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +.idea/**/gradle.xml +.idea/**/libraries + + +cmake-build-*/ + +.idea/**/mongoSettings.xml + +*.iws + +out/ + +.idea_modules/ + +atlassian-ide-plugin.xml + +.idea/replstate.xml + +.idea/sonarlint/ + +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +.idea/httpRequests + +.idea/caches/build_file_checksums.ser + + + +.idea/**/sonarlint/ + +.idea/**/sonarIssues.xml + +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +.idea/$CACHE_FILE$ + +.idea/codestream.xml + +.idea/**/azureSettings.xml + +*~ + +.fuse_hidden* + +.directory + +.Trash-* + +.nfs* + +.DS_Store +.AppleDouble +.LSOverride + +Icon + + +._* + +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +*.icloud \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/kai-ci.iml b/.idea/kai-ci.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/.idea/kai-ci.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 00000000..c5722639 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..ae24a4c8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/populate-konveyor.sh b/populate-konveyor.sh new file mode 100644 index 00000000..1326d4ca --- /dev/null +++ b/populate-konveyor.sh @@ -0,0 +1,290 @@ +#!/bin/bash + +baseName="Test" +count=10 + +declare -A app1=( + [name]="Tackle-testapp public" + [url]="https://github.com/abrugaro/tackle-testapp-public" + [oldBranch]="main" + [newBranch]="hardcode-ip-fix" + [target]="cloud-readiness" +) + +declare -A app2=( + [name]="Day Trader" + [url]="https://github.com/abrugaro/sample.daytrader7.git" + [oldBranch]="master" + [newBranch]="fixes" + [target]="cloud-readiness" +) + +declare -A app3=( + [name]="Ticket Monster" + [url]="https://github.com/jmle/monolith.git" + [oldBranch]="master" + [newBranch]="quarkus" + [target]="quarkus" +) + +declare -A app4=( + [name]="Hello world" + [url]="https://github.com/savitharaghunathan/helloworld-mdb.git" + [oldBranch]="main" + [newBranch]="quarkus" + [target]="quarkus" +) + +apps=("app1" "app2" "app3" "app4") +declare -A createdApps + +pid=$$ +self=$(basename $0) +tmp=/tmp/${self}-${pid} + +usage() { + echo "Usage: ${self} " + echo "Auth has to be disabled in order to execute this script" + echo "-h help" + echo "Required:" + echo " -u /hub" + echo "Options:" + echo " -b base name (Test)" + echo " -n count (10)" + echo " -o output" +} + +while getopts "u:b:n:o:h" arg; do + case $arg in + u) + host=$OPTARG + ;; + b) + baseName=$OPTARG + ;; + n) + count=$OPTARG + ;; + o) + output=$OPTARG + ;; + h) + usage + exit 1 + ;; + *) + usage + exit 1 + ;; + esac +done + +if [ -z "${host}" ]; then + echo "-u required." + usage + exit 0 +fi + +print() { + if [ -n "$output" ]; then + echo -e "$@" >>"$output" + else + echo -e "$@" + fi +} + +echo +echo "Host: ${host}" +echo "Name: ${baseName}" +echo "Count: ${count}" +echo +answer="y" +read -rp "Continue[Y,n]: " answer +if [ "$answer" != "y" ]; then + exit 0 +fi + +createAnalysis() { + appId=$1 + appName=$2 + appTarget=$3 + d=" +{ + \"name\": \"taskgroup.analyzer\", + \"kind\": \"analyzer\", + \"state\": \"Created\", + \"priority\": 10, + \"data\": { + \"tagger\": { + \"enabled\": true + }, + \"mode\": { + \"binary\": false, + \"withDeps\": true + }, + \"rules\": { + \"labels\": { + \"included\": [ + \"konveyor.io/target=${appTarget}\" + ] + } + } + }, + \"tasks\": [ + { + \"name\": \"${appName}.${appId}.windup\", + \"application\": { + \"id\": ${appId}, + \"name\": \"${appName}\" + } + } + ] +}" + + # Create TaskGroup + code=$(curl -kSs -o "$tmp" -w "%{http_code}" -X POST "${host}/taskgroups" -H 'Content-Type:application/json' -H 'Accept: application/json' -d "$d") + ret=$? + if [ ! $ret -eq 0 ]; then + exit $ret + fi + case ${code} in + 201) + taskGroupId=$(jq .id "$tmp") + print "TaskGroup $taskGroupId CREATED Taskgroup for application: $appName id=${appId}" + ;; + *) + print "Create task for: appId=${appId} - FAILED: $code." + cat "$tmp" + exit 1 + ;; + esac + + # Start analysis + code=$(curl -kSs -o "$tmp" -w "%{http_code}" -X PUT "${host}/taskgroups/${taskGroupId}/submit" -H 'Content-Type:application/json' -d "$d") + ret=$? + if [ ! $ret -eq 0 ]; then + exit $ret + fi + case ${code} in + 204) + id=$(jq .id "$tmp") + print "Analysis $id STARTED for application: $appName id=${appId}" + ;; + *) + print "Start analysis for: appId=${appId} - FAILED: $code." + cat "$tmp" + exit 1 + ;; + esac +} + +updateBranch() { + appId=$1 + appName=$2 + repositoryUrl=$3 + newBranch=$4 + d=" +--- +name: $appName +description: $appName Test application. +repository: + kind: git + branch: $newBranch + url: $repositoryUrl +tags: +" + code=$(curl -kSs -o "$tmp" -w "%{http_code}" -X PUT "${host}/applications/${appId}" -H 'Content-Type:application/x-yaml' -d "$d") + ret=$? + if [ ! $ret -eq 0 ]; then + exit $ret + fi + case $code in + 204) + print "Application $appName id=${appId} - UPDATED" + ;; + *) + print "Update application $appName - FAILED: $code." + cat "$tmp" + exit 1 + ;; + esac +} + +waitForAnalyses() { + while true; do + code=$(curl -kSs -o "$tmp" -w "%{http_code}" "${host}/tasks/report/queue") + total=$(jq .total "$tmp") + + if [ "$total" -eq 0 ]; then + echo "All analyses are finished" + break + fi + + echo "Some analyses are still running, waiting 30 secs..." + sleep 30 + done +} + +createApplications() { + for i in $(seq 1 "$count"); do + + randomApp=${apps[$RANDOM % ${#apps[@]}]} + + appName="$(eval echo \${"${randomApp}"[name]})-$i" + appUrl=$(eval echo \${"${randomApp}"[url]}) + appBranch=$(eval echo \${"${randomApp}"[oldBranch]}) + appTarget=$(eval echo \${"${randomApp}"[target]}) + + d=" +--- +name: $appName +description: $appName Test application. +repository: + kind: git + branch: $appBranch + url: $appUrl +tags: +- id: 16 +" + code=$(curl -kSs -o "$tmp" -w "%{http_code}" -X POST "${host}"/applications -H 'Content-Type:application/x-yaml' -d "$d") + ret=$? + if [ ! $ret -eq 0 ]; then + exit $ret + fi + case $code in + 201) + id=$(jq .id "$tmp") + print "Application $appName id=${id} - CREATED" + + createdApps["${id}"]="${randomApp}" + + createAnalysis "$id" "$appName" "$appTarget" + ;; + *) + print "Create application $appName - FAILED: $code." + cat "$tmp" + exit 1 + ;; + esac + done + + waitForAnalyses + + for appId in "${!createdApps[@]}"; do + appKey="${createdApps[$appId]}" + + appName=$(eval echo \${"${appKey}"[name]}) + appUrl=$(eval echo \${"${appKey}"[url]}) + appTarget=$(eval echo \${"${appKey}"[target]}) + appNewBranch=$(eval echo \${"${appKey}"[newBranch]}) + + updateBranch "$appId" "${appName}-${appId}" "$appUrl" "$appNewBranch" + + createAnalysis "$appId" "${appName}-${appId}" "$appTarget" + done + + waitForAnalyses + +} + +createApplications