Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/server-web-api-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
run: |
cd scripts/src/main/bash
./coords-integration-test.sh
- name: Run Stats and Redirects Tests
run: |
cd scripts/src/main/bash
./stats-redirects-test.sh
- name: Stop DBpedia Server
run: |
if [ -f server.pid ]; then
Expand Down
59 changes: 59 additions & 0 deletions scripts/src/main/bash/stats-redirects-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Tests that stats and redirects endpoints return 200 for all @mappings languages

BASE_URL="http://localhost:9999/server"
FAILED=0
FAILED_TESTS=()

echo "=========================================="
echo "Fetching languages with @mappings..."

MAPPINGS_PAGE=$(curl -s "${BASE_URL}/mappings/")
[ -z "$MAPPINGS_PAGE" ] && { echo "❌ ERROR: Could not fetch mappings page"; exit 1; }

LANGUAGES=($(echo "$MAPPINGS_PAGE" | grep -oP 'href="\K[^/"]+(?=/">)' | sort -u))
[ ${#LANGUAGES[@]} -eq 0 ] && { echo "❌ ERROR: No languages found"; exit 1; }

echo "Found ${#LANGUAGES[@]} languages: ${LANGUAGES[@]}"
echo ""

# Test endpoint function
test_endpoint() {
local lang="$1"
local type="$2"
local url="$3"

http_code=$(curl -s -o /dev/null -w "%{http_code}" "$url")

if [ "$http_code" = "200" ]; then
echo "✅ $lang $type: HTTP $http_code"
else
echo "❌ $lang $type: HTTP $http_code"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$lang $type (HTTP $http_code)")
fi
}

# Test both endpoints for each language
echo "Testing Statistics and Redirects..."
echo "=========================================="
for lang in "${LANGUAGES[@]}"; do
test_endpoint "$lang" "Stats " "${BASE_URL}/statistics/${lang}/"
test_endpoint "$lang" "Redirects" "${BASE_URL}/mappings/${lang}/redirects/"
done

# Summary
echo ""
echo "=========================================="
echo "SUMMARY: $((${#LANGUAGES[@]} * 2)) tests, $((${#LANGUAGES[@]} * 2 - FAILED)) passed, $FAILED failed"

if [ $FAILED -gt 0 ]; then
echo ""
echo "❌ Failed:"
printf ' %s\n' "${FAILED_TESTS[@]}"
exit 1
fi

echo "✅ All tests passed!"
exit 0
2 changes: 1 addition & 1 deletion server/server.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ontology=../ontology.xml
mappings=../mappings

# List of languages, e.g. 'en,de,fr' or '@mappings'
languages=de,en
languages=en,de



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Server(
managers.map(manager => (manager._1, Server.buildTemplateRedirects(manager._2.wikiStats.redirects, manager._1)))
}

val extractor: ExtractionManager = new DynamicExtractionManager(managers(_).updateStats(_), languages, paths, redirects, mappingTestExtractors, customTestExtractors)

extractor.updateAll

// Cache key for single extractor managers
private case class ExtractorCacheKey(language: Language, extractorClass: Class[_ <: Extractor[_]])

Expand Down Expand Up @@ -74,10 +78,6 @@ class Server(
})
}

// Main extraction manager with ALL extractors
val extractor: ExtractionManager = {
new DynamicExtractionManager(managers(_).updateStats(_), languages, paths, redirects, mappingTestExtractors, customTestExtractors)
}

def adminRights(pass: String): Boolean = password == pass

Expand Down
Loading