|
#!/bin/bash |
|
|
|
echo "π Gathering built aojea/nft tags..." |
|
# Get all tags for the nft-tester image and sort them cleanly by version |
|
TAGS=$(docker images --format '{{.Tag}}' aojea/nft | sort -V | tr '\n' ' ') |
|
|
|
if [ -z "$TAGS" ]; then |
|
echo "β Error: No nft-tester images found. Run ./build-matrix.sh first!" |
|
exit 1 |
|
fi |
|
|
|
# Convert tags list into an array for easy indexing |
|
read -r -a TAG_ARRAY <<< "$TAGS" |
|
|
|
# Define temporary files for tracking results |
|
RESULTS_FILE="matrix_results.tmp" |
|
rm -f "$RESULTS_FILE" |
|
|
|
echo "π Starting automated version-skew matrix test..." |
|
echo "------------------------------------------------" |
|
|
|
# Outer loop: The OLD version trying to READ (e.g., Kube-proxy behavior) |
|
for OLD in "${TAG_ARRAY[@]}"; do |
|
# Inner loop: The NEW version that WROTE the rules (e.g., Host behavior) |
|
for NEW in "${TAG_ARRAY[@]}"; do |
|
|
|
# Optimization: We are primarily interested in userspace skew where |
|
# the host (NEW) is a higher version than the container (OLD). |
|
# If you want to test ALL combinations, remove this if-statement block. |
|
if [ "$(echo -e "$OLD\n$NEW" | sort -V | head -n1)" != "$OLD" ]; then |
|
# NEW is actually older than OLD, skip or mark as N/A |
|
echo "$OLD:$NEW:N/A" >> "$RESULTS_FILE" |
|
continue |
|
fi |
|
|
|
echo -n "π Testing Reader: $OLD vs Writer: $NEW ... " |
|
|
|
# Run the skew test script and suppress its detailed output to keep CI clean |
|
./test-skew.sh "$OLD" "$NEW" > /dev/null 2>&1 |
|
STATUS=$? |
|
|
|
if [ $STATUS -eq 0 ]; then |
|
echo "β
PASSED" |
|
echo "$OLD:$NEW:PASS" >> "$RESULTS_FILE" |
|
else |
|
echo "β FAILED" |
|
echo "$OLD:$NEW:FAIL" >> "$RESULTS_FILE" |
|
fi |
|
done |
|
done |
|
|
|
echo -e "\n------------------------------------------------" |
|
echo "π Matrix Testing Complete! Generating Summary..." |
|
echo -e "------------------------------------------------\n" |
|
|
|
# --- GENERATE MARKDOWN MATRIX REPORT --- |
|
|
|
# Print Header Line 1 (Writers / Host versions) |
|
printf "| Reader (kube-proxy) \\ Writer (Host) " |
|
for NEW in "${TAG_ARRAY[@]}"; do |
|
printf "| %-6s " "$NEW" |
|
done |
|
echo "|" |
|
|
|
# Print Header Separator Line |
|
printf "|-------------------------------------" |
|
for NEW in "${TAG_ARRAY[@]}"; do |
|
printf "|--------" |
|
done |
|
echo "|" |
|
|
|
# Print Rows |
|
for OLD in "${TAG_ARRAY[@]}"; do |
|
printf "| %-35s " "**$OLD**" |
|
for NEW in "${TAG_ARRAY[@]}"; do |
|
# Fetch the status from our temporary file |
|
CELL_STATUS=$(grep "^${OLD}:${NEW}:" "$RESULTS_FILE" | cut -d':' -f3) |
|
|
|
case "$CELL_STATUS" in |
|
"PASS") |
|
printf "| β
" |
|
;; |
|
"FAIL") |
|
printf "| β " |
|
;; |
|
"N/A") |
|
printf "| -- " |
|
;; |
|
*) |
|
printf "| ?? " |
|
;; |
|
esac |
|
done |
|
echo "|" |
|
done |
|
|
|
# Clean up |
|
rm -f "$RESULTS_FILE" |