Skip to content

Commit

Permalink
Update some integration test scripts
Browse files Browse the repository at this point in the history
Fix the image-check script domain handling for 'localhost'.
Pipe output to jq for pretty printing diagnosic output.
Remove obsolete Parsoid check.

This work  was performed for NASA GRC-ATF by WikiWorks per NASA Contract  NNC15BA02B.
  • Loading branch information
freephile committed Mar 15, 2024
1 parent 957a0ef commit cd5ad23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
14 changes: 12 additions & 2 deletions tests/integration/image-check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh
#
# Test if an image exists on a wiki
# This script expects two arguments:
# 1. The wiki ID
# 2. The title of the image to check
# e.g. if you have an image at https://localhost/demo/File:Logo-mc.png
# you would run this script with "demo" and "Logo-mc.png" as arguments


# -e: kill script if anything fails
Expand All @@ -19,9 +24,14 @@ api_url_base="$origin/$wiki_id/api.php"
api_url_image="$api_url_base?action=query&titles=File:$image_title&prop=imageinfo&iiprop=sha1|url&format=json"
curl --insecure -L "$api_url_image" | jq '.query.pages[].title'

# Get image url, get sha1 according to database (via API)
img_url=$( curl --insecure -L "$api_url_image" | jq --raw-output '.query.pages[].imageinfo[0].url' -e )
# Get image url according to database (via API)
# We could also get the sha1 hash and check the file system
img_url=$( curl --insecure -L "$api_url_image" | jq --raw-output '.query.pages[].imageinfo[0].url' --exit-status )
# remove protocol, numeric domain and trailing slash
img_url=$( echo $img_url | sed 's/https:\/\/[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\///' )
# remove protocol, 'localhost' domain and trailing slash
img_url=$( echo $img_url | sed 's/https:\/\/localhost\///' )
# set URL to the internal URL
img_url="http://127.0.0.1:8080/$img_url"

# Retrieve image
Expand Down
9 changes: 2 additions & 7 deletions tests/integration/server-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@ ${curl_args[@]} http://127.0.0.1:8080 \
|| (echo 'Apache 200 test: fail' && exit 1)

# Parsoid check
${curl_args[@]} http://127.0.0.1:8000

${curl_args[@]} http://127.0.0.1:8000 \
| grep -q '200' \
&& (echo 'Parsoid 200 test: pass' && exit 0) \
|| (echo 'Parsoid 200 test: fail' && exit 1)

# @todo: add me
# new parsoid has a slew of built-in checks we could do
14 changes: 7 additions & 7 deletions tests/integration/wiki-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ api_url_ve="$api_url_base?action=visualeditor&format=json&paction=parse&page=Mai
# "mainpage": "Main Page",
# "base": "https://en.wikipedia.org/wiki/Main_Page",
# "sitename": "Wikipedia",
curl -L "$api_url_siteinfo"
curl -L "$api_url_siteinfo" | jq ".query.general.sitename == \"$wiki_name\"" -e \
curl -L "$api_url_siteinfo" | jq
curl -L "$api_url_siteinfo" | jq ".query.general.sitename == \"$wiki_name\"" --exit-status \
&& (echo "$wiki_name API test: pass" && exit 0) \
|| (echo "$wiki_name API test: fail" && exit 1)

# Verify Parsoid is working
curl -L "$api_url_ve"
curl -L "$api_url_ve" | jq ".visualeditor.result == \"success\"" -e \
curl -L "$api_url_ve" | jq
curl -L "$api_url_ve" | jq ".visualeditor.result == \"success\"" --exit-status \
&& (echo 'VisualEditor PASS' && exit 0) || (echo 'VisualEditor FAIL' && exit 1)

# Verify an indices exist for this wiki
curl "http://127.0.0.1:9200/_stats/store"
curl "http://127.0.0.1:9200/_stats/store" | jq ".indices | has(\"wiki_${wiki_id}_content_first\")" -e \
curl "http://127.0.0.1:9200/_stats/store" | jq
curl "http://127.0.0.1:9200/_stats/store" | jq ".indices | has(\"wiki_${wiki_id}_content_first\")" --exit-status \
&& (echo 'Elasticsearch PASS' && exit 0) || (echo 'Elasticsearch FAIL' && exit 1)
curl "http://127.0.0.1:9200/_stats/store" | jq ".indices | has(\"wiki_${wiki_id}_general_first\")" -e \
curl "http://127.0.0.1:9200/_stats/store" | jq ".indices | has(\"wiki_${wiki_id}_general_first\")" --exit-status \
&& (echo 'Elasticsearch PASS' && exit 0) || (echo 'Elasticsearch FAIL' && exit 1)

0 comments on commit cd5ad23

Please sign in to comment.