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

fix: values in user's profile_default are ignored #1778

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d077072
fix: move yml properties to defaults where possible
jhaeu Mar 27, 2024
fda5482
fix: fix evaluation of 'enabled' in profile_default
jhaeu Mar 27, 2024
277d2c3
feat: adapt conversion to changed application.yml
jhaeu Mar 27, 2024
5755e61
feat: add config tests for profile_default
jhaeu Mar 27, 2024
75c5d2d
fix: do not indent commented lines
jhaeu Mar 27, 2024
4b32624
feat: re-generated ors-config.yml
jhaeu Mar 27, 2024
fa8df6c
fix: remove profile definitions from application.yml
jhaeu Apr 11, 2024
97b91a2
test: add test
jhaeu Apr 11, 2024
9b61465
test: remove no longer required properties
jhaeu Apr 11, 2024
267b406
test: small improvements and fixes on tests
jhaeu Apr 11, 2024
44b7492
test: don't use port 8082
jhaeu Apr 11, 2024
5c40657
test: support for skipping tests
jhaeu Apr 11, 2024
97bc6c2
fix: add profile names to default application.yml
jhaeu Apr 11, 2024
2b2cb4e
feat: adapt workflow
jhaeu Apr 11, 2024
f9c6204
feat: add script to generate ors-config locally
jhaeu Apr 11, 2024
8c4d96e
docs: add changelog entry
jhaeu Apr 12, 2024
c44440e
chore: remove no longer used code
jhaeu Apr 12, 2024
bac2be9
docs: add hint for removed profile properties
jhaeu Apr 12, 2024
213d11a
docs: explain unchangeable profile names, clarify profile name and key
jhaeu Apr 12, 2024
bbe70bb
docs: hints about (overriding) profile defaults in application-profil…
jhaeu Apr 12, 2024
3826413
docs: explain required config changes in CHANGELOG.md
jhaeu Apr 12, 2024
7206148
test: separated yml from json in matrix
jhaeu Apr 12, 2024
9f825c0
chore(config): automatic conversion of application.yml to ors-config.…
jhaeu Apr 12, 2024
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
62 changes: 35 additions & 27 deletions .github/utils/yml_config_to_ors_config_conversion.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "Usage: $0 input.yaml output.yaml"
function checkPropertyEq() {
local file=$1
local path=$2
local expected=$3
echo -n "- checking for ${path} = ${expected}:"
if [ "$(yq ".${path}" < ${file})" = "${expected}" ]; then
echo -e "\e[1;32m ok \e[0m"
else
echo -e "\e[1;31m error \e[0m"
hasError=1
fi
}

if [ "$#" -ne 3 ]; then
echo "Usage: $0 input-1.yaml input-2.yaml output.yaml"
exit 1
fi

input_file=$1
output_file=$2
input_file1=$1
input_file2=$2
output_file=$3

echo ""
echo "Copy $input_file to $output_file"
cp $input_file $output_file
echo "Merge $input_file1 and $input_file2 to $output_file"
cp $input_file1 $output_file
yq eval-all '. as $item ireduce ({}; . *+ $item)' "$input_file1" "$input_file2" > "$output_file"

###########################
### Replace parameters ####
###########################
#echo ""
#echo "Replace parameters:"
#
#echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz"
#yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1

############################
### Validate output file ###
############################
echo ""
echo "Replace parameters:"
echo "Validate output file:"
hasError=0
checkPropertyEq $output_file "ors.engine.source_file" "ors-api/src/test/files/heidelberg.osm.gz"
checkPropertyEq $output_file "ors.engine.profiles.car.enabled" "true"
(($hasError)) && exit 1

echo "- enable ors.engine.profiles.car"
yq -i '.ors.engine.profiles.car.enabled = true' "$output_file" || exit 1

echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz"
yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1

###########################
### Convert input file ####
###########################
echo ""
echo "Converting input file:"
## Add # to the beginning of each line that is not empty or a comment
echo "- Comment everything"
sed -i '/^\s*[^#]/ s/^/#/' "$output_file" || exit 1

echo "- Uncomment ors, engine and source_file"
sed -i -e '/^#ors:/s/^#//' -e '/^#.*engine:/s/^#//' -e '/^#.*source_file:/s/^#//' "$output_file"

echo "- Uncomment subsequent lines for profiles.car.enabled in ors.engine"
sed -i -e '/^# profiles:/,/^# enabled:/ s/^#//' "$output_file"

echo "Parsing complete. Result saved to $output_file"
66 changes: 33 additions & 33 deletions .github/utils/yml_config_to_properties_conversion.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "Usage: $0 input.yaml output.properties"
function checkPropertyEq() {
local file=$1
local path=$2
local expected=$3
echo -n "- checking for ${path}=${expected}:"
return_value=$(grep -xc "${path}=${expected}" $file)
if [ $return_value -eq 1 ]; then
echo -e "\e[1;32m ok \e[0m"
else
echo -e "\e[1;31m error \e[0m"
hasError=1
fi
}

if [ "$#" -ne 3 ]; then
echo "Usage: $0 input-1.yaml input-2.yaml output.yaml"
exit 1
fi

input_file=$1
output_file=$2
input_file1=$1
input_file2=$2
output_file=$3

echo ""
echo "Copy $input_file to $output_file"
cp $input_file $output_file
echo "Merge $input_file1 and $input_file2 to $output_file"
cp $input_file1 $output_file
yq eval-all '. as $item ireduce ({}; . *+ $item)' "$input_file1" "$input_file2" > "$output_file"

###########################
### Replace parameters ####
###########################
echo ""
echo "Replace parameters:"

echo "- enable ors.engine.profiles.car"
yq -i '.ors.engine.profiles.car.enabled = true' "$output_file" || exit 1
#echo ""
#echo "Replace parameters:"

echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz"
yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1
#echo "- enable ors.engine.profiles.car"
#yq -i '.ors.engine.profiles.car.enabled = true' "$output_file" || exit 1

#echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz"
#yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1

###########################
### Convert input file ####
Expand All @@ -33,30 +48,15 @@ echo "Convert .yaml to .env/properties file:"
echo "- unwrap yaml structure to flat properties"
yq -i -o=props --unwrapScalar=false '.. | select(tag != "!!map" and tag != "!!seq") | ( (path | join(".")) + "=" + .)' "$output_file" || exit 1

## Add # to the beginning of each line that is not empty or a comment
echo "- Comment everything"
sed -i '/^\s*[^#]/ s/^/#/' "$output_file" || exit 1

echo "- Uncomment ors.engine.source_file and ors.engine.profiles.car.enabled"
sed -i -e '/^#ors.engine.source_file/s/^#//' -e '/^#ors.engine.profiles.car.enabled/s/^#//' "$output_file" || exit 1

############################
### Validate output file ###
############################
echo ""
echo "Validate output file:"
echo "- checking for ors.engine.source_file=ors-api/src/test/files/heidelberg.osm.gz"
return_value=$(sed -n '/^ors.engine.source_file=ors-api\/src\/test\/files\/heidelberg.osm.gz/p' $output_file)|| exit 1
if [ -z "$return_value" ]; then
echo "ors.engine.source_file=ors-api/src/test/files/heidelberg.osm.gz not found"
exit 1
fi
echo "- checking for ors.engine.profiles.car.enabled=true"
return_value=$(sed -n '/^ors.engine.profiles.car.enabled=true/p' $output_file) || exit 1
if [ -z "$return_value" ]; then
echo "ors.engine.profiles.car.enabled=true not found"
exit 1
fi
hasError=0
checkPropertyEq $output_file "ors.engine.source_file" "ors-api/src/test/files/heidelberg.osm.gz"
checkPropertyEq $output_file "ors.engine.profiles.car.enabled" "true"
(($hasError)) && exit 1

echo ""
echo "Parsing complete. Result saved to $output_file"

27 changes: 17 additions & 10 deletions .github/utils/yml_config_validation.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 input.yaml"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 input-1.yaml input-2.yaml (1 with basic properties, 2 with profiles)"
exit 1
fi

input_file=$1
input_file1=$1
input_file2=$2

###########################
### Validate input file ###
### Validate input files ###
###########################
echo "Validate input file:"
echo "Validate input file1:"
echo "- checking if the input file is a valid yaml file"
yq 'true' $input_file /dev/null || exit 1
yq 'true' $input_file1 /dev/null || exit 1
# Fail if ors.engine.profiles.car.enabled='false' can't be found access with schema .result | select(.property_history != null) | .property_history | map(select(.event_name == "Sold"))[0].date'
echo "- checking if ors.engine.source_file exists and has 'source_file' property"
yq --exit-status '.ors.engine | has("source_file")' $input_file > /dev/null || exit 1
echo "- checking if ors.engine.source_file exists in $input_file1 and has 'source_file' property"
yq --exit-status '.ors.engine | has("source_file")' $input_file1 > /dev/null || exit 1



echo "Validate input file2:"
echo "- checking if the input file is a valid yaml file"
yq 'true' $input_file2 /dev/null || exit 1
# For profiles section for car with enabled using yq and contains
echo "- checking if ors.engine.profiles.car exists and has 'enabled' property"
yq --exit-status '.ors.engine.profiles.car | has("enabled")' $input_file > /dev/null || exit 1
echo "- checking if ors.engine.profiles.car exists in $input_file2 and has 'enabled' property"
yq --exit-status '.ors.engine.profiles.car | has("enabled")' $input_file2 > /dev/null || exit 1
6 changes: 3 additions & 3 deletions .github/workflows/config-conversion-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- name: yq - portable yaml processor
uses: mikefarah/[email protected]
- name: validate application.yml
run: .github/utils/yml_config_validation.sh ors-api/src/main/resources/application.yml
run: .github/utils/yml_config_validation.sh ors-api/src/main/resources/application.yml ors-api/src/main/resources/application-profiles.yml
- name: Convert application.yml to ors-config.yml and ors-config.env
run: |
# Print yq version
yq --version
.github/utils/yml_config_to_ors_config_conversion.sh ors-api/src/main/resources/application.yml ors-config.yml
.github/utils/yml_config_to_properties_conversion.sh ors-api/src/main/resources/application.yml ors-config.env
.github/utils/yml_config_to_ors_config_conversion.sh ors-api/src/main/resources/application.yml ors-api/src/main/resources/application-profiles.yml ors-config.yml
.github/utils/yml_config_to_properties_conversion.sh ors-api/src/main/resources/application.yml ors-api/src/main/resources/application-profiles.yml ors-config.env
- uses: MichaelsJP/git-auto-commit-action@v5
with:
commit_message: 'chore(config): automatic conversion of application.yml to ors-config.yml and ors-config.env'
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
matrix:
runtype: [ '-m' , '-j' ]
testgroup: [ build-all-graphs*, arg-overrides*, check*, config*, lookup*, missing*, specify* ]
testgroup: [ build-all-graphs*, arg-overrides*, check*, config-json*, config-yml*, lookup*, missing*, ors-config*, specify-json*, specify-yml*, profile-default* ]
steps:
- uses: actions/checkout@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ prepareTest $callingScript $runType $image
orsConfig=$(makeTempFile $callingScript "\
ors:
engine:
source_file: ors-api/src/test/files/heidelberg.osm.gz
profiles:
${enabledProfile}:
enabled: true")
Expand Down
45 changes: 40 additions & 5 deletions .integration-scenarios/debian-12-jar-mvn/files/testfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,46 @@ function expectOrsStartupFails() {
fi
}

function assertSortedWordsEquals() {
expected=$1
received=$2
sorted_expected=$(echo "$expected" | tr ' ' '\n' | sort | tr '\n' ' ')
sorted_received=$(echo "$received" | tr ' ' '\n' | sort | tr '\n' ' ')
assertEquals "$sorted_expected" "$sorted_received"
}

function assertEquals() {
expected=$1
received=$2
check=$3
if [ -n "$check" ]; then checkMsg="Checking '$check': "; fi
if [ "$expected" != "$received" ]; then
echo -e "${FG_RED}ASSERTION ERROR:${N}"
echo -e "${FG_RED}ASSERTION ERROR:${N} ${checkMsg}"
echo -e "expected: '${FG_GRN}${expected}${N}'"
echo -e "received: '${FG_RED}${received}${N}'"
exit 1
else
echo -e "${FG_GRN}received '$received' as expected${N}"
exit 0
echo -e "${FG_GRN}${checkMsg}Received '${received}' as expected${N}"
fi
}

function assertContains() {
expected=$1
received=$2
num=$(echo "${received}" | grep -c "${expected}")
if [[ $num -eq 0 ]]; then
echo -e "${FG_RED}ASSERTION ERROR:${N}: '${expected}' not contained as expected${N} $num"
exit 1
else
echo -e "${FG_GRN}'${expected}' is contained as expected${N}"
fi
}

function requestStatusString() {
port=$1
echo $(curl --silent $(getOrsUrl $port)/status | jq . )
}

function requestEnabledProfiles() {
port=$1
echo $(curl --silent $(getOrsUrl $port)/status | jq -r '.profiles[].profiles')
Expand Down Expand Up @@ -153,7 +179,7 @@ function prepareTest() {
if [ -z "$IMAGE" ]; then printError "missing param 2: docker image"; exit 1; fi

CONTAINER=${runType}-$(removeExtension "$(basename $script)")
HOST_PORT=$(findFreePort 8082)
HOST_PORT=$(findFreePort 8083)

mkdir -p ~/.m2
M2_FOLDER="$(realpath ~/.m2)"
Expand Down Expand Up @@ -181,7 +207,16 @@ function makeTempFile() {
echo "$tempFile"
}

function makeTempCopy() {
script=$1
sourceFile=$2
mkdir -p "$TESTROOT/tmp"
tempFile=$(mktemp "${TESTROOT}/tmp/${script}-$(basename $sourceFile).XXXXXXXXX")
cat "$sourceFile" >> $tempFile
echo "$tempFile"
}

function deleteTempFiles() {
script=$1
rm "${TESTROOT}/tmp/${script}".*
rm "${TESTROOT}/tmp/${script}"*
}
15 changes: 10 additions & 5 deletions .integration-scenarios/debian-12-jar-mvn/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mvn=0
verbose=0
pattern=""

function printCliHelp() { # TODO adapt
function printCliHelp() {
echo -e "\
${B}$SCRIPT${N} - run ors tests in containers

Expand Down Expand Up @@ -69,12 +69,15 @@ function runTest() {
else
$testscript "${runType}" "${imageName}" 1>/dev/null 2>&1
fi

if (($?)); then
testStatus=$?
if [ $testStatus -eq 1 ]; then
hasErrors=1
((failed++))
echo -e "${FG_RED}${B}failed${N}"
(($failFast)) && exit 1
elif [ $testStatus -eq 2 ]; then
((skipped++))
echo -e "${FG_ORA}${B}skipped${N}"
else
((passed++))
echo -e "${FG_GRN}passed${N}"
Expand Down Expand Up @@ -142,6 +145,7 @@ mkdir -p "${TESTROOT}/graphs_volume"

hasErrors=0
passed=0
skipped=0
failed=0

for word in $pattern; do
Expand All @@ -152,8 +156,9 @@ for word in $pattern; do
done

(($passed)) && passedText=", ${FG_GRN}${B}${passed} passed${N}"
(($skipped)) && skippedText=", ${FG_ORA}${B}${skipped} skipped${N}"
(($failed)) && failedText=", ${FG_RED}${B}${failed} failed${N}"

total=$(($passed + $failed))
echo -e "${FG_BLU}$(date +%Y-%m-%dT%H:%M:%S)${N} ${B}done, ${total} test$( (($total-1)) && echo "s") executed${passedText}${failedText}"
total=$(($passed + $skipped + $failed))
echo -e "${FG_BLU}$(date +%Y-%m-%dT%H:%M:%S)${N} ${B}done, ${total} test$( (($total-1)) && echo "s") executed${passedText}${skippedText}${failedText}"
exit $hasErrors
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ awaitOrsReady 60 "${HOST_PORT}"
profiles=$(requestEnabledProfiles ${HOST_PORT})
cleanupTest

assertEquals 'driving-hgv driving-car' "${profiles}"
assertSortedWordsEquals 'driving-hgv driving-car' "${profiles}"
Loading
Loading