Skip to content

Commit

Permalink
Merge pull request #708 from geonetwork/fix-e2e-flaky-tests
Browse files Browse the repository at this point in the history
Attempt to fix E2E flaky tests
  • Loading branch information
jahow authored Dec 1, 2023
2 parents cdc9735 + 9a5e6dd commit c1e561c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ curl -s -X PUT "elasticsearch:9200/_cluster/settings" -H 'Content-Type: applicat
}
}'

echo ""
echo "Removed disk space watermark in ElasticSearch."
23 changes: 22 additions & 1 deletion support-services/docker-entrypoint.d/10-index-records.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ password=admin
xsrf_token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
host=geonetwork:8080

echo "Logging in to GeoNetwork..."

# first login to get an authenticated admin session
jsessionid=$(
curl -s "http://$host/geonetwork/signin" \
Expand All @@ -14,6 +16,8 @@ jsessionid=$(
-c - | grep JSESSIONID | awk '{ print $7 }'
)

echo "Triggering full records indexation in GeoNetwork..."

# then trigger an indexing
result=$(
curl -s "http://$host/geonetwork/srv/api/site/index" \
Expand All @@ -39,8 +43,25 @@ do
-H "Cookie: JSESSIONID=$jsessionid; XSRF-TOKEN=$xsrf_token" \
-H "X-XSRF-TOKEN: $xsrf_token"
)
echo "Indexing? $indexing"
echo "Currently indexing: $indexing"
sleep 1
done

# finally check that the index has records in it
recordsCount=0
while [ "$recordsCount" = '0' ];
do
response=$(
curl -s "http://$host/geonetwork/srv/api/search/records/_search" \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json;charset=UTF-8' \
-H "Cookie: JSESSIONID=$jsessionid; XSRF-TOKEN=$xsrf_token" \
-H "X-XSRF-TOKEN: $xsrf_token" \
--data-raw '{"size":0}'
)
recordsCount=$(echo $response | sed 's/.*"hits":{"total":{"value":\([0-9]\+\).*/\1/g')
echo "Records found: $recordsCount"
sleep 2
done

echo "Indexing job in GeoNetwork successful."

0 comments on commit c1e561c

Please sign in to comment.