You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2021/12/07 12:40:56 UTC

[camel-website] branch pr/redirect-checks created (now 3009a4e)

This is an automated email from the ASF dual-hosted git repository.

zregvart pushed a change to branch pr/redirect-checks
in repository https://gitbox.apache.org/repos/asf/camel-website.git.


      at 3009a4e  chore: run redirect test as a part of checks

This branch includes the following new commits:

     new 3009a4e  chore: run redirect test as a part of checks

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[camel-website] 01/01: chore: run redirect test as a part of checks

Posted by zr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zregvart pushed a commit to branch pr/redirect-checks
in repository https://gitbox.apache.org/repos/asf/camel-website.git

commit 3009a4eed662ac1578f3a8f2d644663711de0c71
Author: Zoran Regvart <zo...@regvart.com>
AuthorDate: Tue Dec 7 13:40:07 2021 +0100

    chore: run redirect test as a part of checks
    
    This makes sure that we run the redirect tests as a part of regular
    checks so we don't unintentionally break redirects.
    
    The `test/redirect.sh` now supports these new parameters:
     - `-s` - start a container with Apache HTTP server and test against it
     - `-v` - verbose test output (print a line for each test)
     - `-x` - verbose script output (equivalent of `set -x`)
---
 package.json      |   3 +-
 tests/redirect.sh | 248 +++++++++++++++++++++++++++++++++---------------------
 2 files changed, 155 insertions(+), 96 deletions(-)

diff --git a/package.json b/package.json
index 9d4cfbd..7694979 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,8 @@
     "build:htaccess": "gulp htaccess",
     "check:html": "html-validate public",
     "check:links": "deadlinks-linux public",
-    "checks": "run-s check:links check:html",
+    "check:redirects": "tests/redirect.sh -s",
+    "checks": "run-s check:links check:html check:redirects",
     "clean": "gulp clean",
     "check:dependencies": "run-p check:cache check:dedupe",
     "check:cache": "yarn workspaces foreach install --immutable --immutable-cache --check-cache",
diff --git a/tests/redirect.sh b/tests/redirect.sh
index 49e8124..d287246 100755
--- a/tests/redirect.sh
+++ b/tests/redirect.sh
@@ -1,106 +1,164 @@
-#!/bin/sh
+#!/bin/env bash
 
-BASE_URL="${1:-https://localhost}"
+set -eu -o pipefail
+
+BASE_URL="https://localhost"
+VERBOSE=0
+SERVE=0
+while [[ $# -gt 0 ]]; do
+  opt="$1"
+
+  case $opt in
+    -v|--verbose)
+      VERBOSE=1
+      shift
+      ;;
+    -x|--very-verbose)
+      set -x
+      shift
+      ;;
+    -s|--serve)
+      SERVE=1
+      shift
+      ;;
+    *)
+      BASE_URL="$1"
+      shift
+      ;;
+  esac
+done
+
+if [ "$SERVE" == 1 ]; then
+  CONTAINER_CMD=podman
+  if ! command -v $CONTAINER_CMD &> /dev/null; then
+    CONTAINER_CMD=docker
+    if ! command -v $CONTAINER_CMD &> /dev/null; then
+      echo -e "\e[1mFAILURE\e[0m: Nether podman nor docker command found"
+      exit 1
+    fi
+  fi
+  CONTAINER_ID=$($CONTAINER_CMD run --rm -d -p 443 -v "$PWD/public":/usr/local/apache2/htdocs/:Z -v "$PWD/support/http":/support:Z httpd:2.4 /bin/bash -c "cp /support/* /usr/local/apache2/conf/ && httpd-foreground")
+  trap '$CONTAINER_CMD stop $CONTAINER_ID > /dev/null' EXIT
+  BASE_URL="https://$($CONTAINER_CMD port "$CONTAINER_ID" 443 | head -1)"
+fi
+
+TOTAL=0
+SUCCESS=0
 
 function test {
   local url=$1
   local code=$2
-  local location=$3
+  local location=${3:-}
 
-  local output=$(curl -k -w '%{http_code},%{redirect_url}\n' -o /dev/null -s "${url}")
+  local output
+  set +e
+  output=$(curl -k -w '%{http_code},%{redirect_url}\n' -o /dev/null -s "${url}")
+  set -e
+  TOTAL=$((TOTAL + 1))
 
-  if [ "${output}" == "${code},${location}" ]; then 
-    echo " OK : ${url}"
+  if [ "${output}" == "${code},${location}" ]; then
+    SUCCESS=$((SUCCESS + 1))
+    if [ "${VERBOSE}" == 1 ]; then
+      echo -e " OK : ${url}"
+    fi
   else
-    echo "FAIL: ${url} -> ${code},${location} != ${output}"
+    echo -e "\e[1m\e[31mFAIL\e[m: ${url}\n    expected: \e[1m${code},${location}\e[0m\n         got: \e[1m${output}\e[0m"
   fi
 }
 
-C_V="3.13.x"
-CK_V="1.6.x"
-CKC_V="0.11.0"
-CQ_V="2.4.x"
-
-test $BASE_URL/components 302 $BASE_URL/components/${C_V}/
-test $BASE_URL/components/ 302 $BASE_URL/components/${C_V}/
-test $BASE_URL/components/next 301 $BASE_URL/components/next/
-test $BASE_URL/components/next/ 200
-test $BASE_URL/components/latest 302 $BASE_URL/components/${C_V}
-test $BASE_URL/components/latest/ 302 $BASE_URL/components/${C_V}/
-test $BASE_URL/components/activemq-component.html 302 $BASE_URL/components/${C_V}/activemq-component.html
-test $BASE_URL/components/latest/activemq-component.html 302 $BASE_URL/components/${C_V}/activemq-component.html
-test $BASE_URL/components/${C_V}/activemq-component.html 200
-test $BASE_URL/components/next/activemq-component.html 200
-
-test $BASE_URL/camel-spring-boot 302 $BASE_URL/camel-spring-boot/${C_V}/
-test $BASE_URL/camel-spring-boot/ 302 $BASE_URL/camel-spring-boot/${C_V}/
-test $BASE_URL/camel-spring-boot/next 301 $BASE_URL/camel-spring-boot/next/
-test $BASE_URL/camel-spring-boot/next/ 200
-test $BASE_URL/camel-spring-boot/latest 302 $BASE_URL/camel-spring-boot/${C_V}
-test $BASE_URL/camel-spring-boot/latest/ 302 $BASE_URL/camel-spring-boot/${C_V}/
-test $BASE_URL/camel-spring-boot/list.html 302 $BASE_URL/camel-spring-boot/${C_V}/list.html
-test $BASE_URL/camel-spring-boot/latest/list.html 302 $BASE_URL/camel-spring-boot/${C_V}/list.html
-test $BASE_URL/camel-spring-boot/${C_V}/list.html 200
-test $BASE_URL/camel-spring-boot/next/list.html 200
-
-test $BASE_URL/camel-k 302 $BASE_URL/camel-k/${CK_V}/
-test $BASE_URL/camel-k/ 302 $BASE_URL/camel-k/${CK_V}/
-test $BASE_URL/camel-k/next 301 $BASE_URL/camel-k/next/
-test $BASE_URL/camel-k/next/ 200
-test $BASE_URL/camel-k/latest 302 $BASE_URL/camel-k/${CK_V}
-test $BASE_URL/camel-k/latest/ 302 $BASE_URL/camel-k/${CK_V}/
-test $BASE_URL/camel-k/traits/master.html 302 $BASE_URL/camel-k/${CK_V}/traits/master.html
-test $BASE_URL/camel-k/latest/traits/master.html 302 $BASE_URL/camel-k/${CK_V}/traits/master.html
-test $BASE_URL/camel-k/${CK_V}/traits/master.html 200
-test $BASE_URL/camel-k/next/traits/master.html 200
-
-test $BASE_URL/camel-karaf 302 $BASE_URL/camel-karaf/${C_V}/
-test $BASE_URL/camel-karaf/ 302 $BASE_URL/camel-karaf/${C_V}/
-test $BASE_URL/camel-karaf/next 301 $BASE_URL/camel-karaf/next/
-test $BASE_URL/camel-karaf/next/ 200
-test $BASE_URL/camel-karaf/latest 302 $BASE_URL/camel-karaf/${C_V}
-test $BASE_URL/camel-karaf/latest/ 302 $BASE_URL/camel-karaf/${C_V}/
-test $BASE_URL/camel-karaf/latest/components.html 302 $BASE_URL/camel-karaf/${C_V}/components.html
-test $BASE_URL/camel-karaf/latest/components.html 302 $BASE_URL/camel-karaf/${C_V}/components.html
-test $BASE_URL/camel-karaf/${C_V}/components.html 200
-test $BASE_URL/camel-karaf/next/components.html 200
-
-test $BASE_URL/camel-kafka-connector 302 $BASE_URL/camel-kafka-connector/${CKC_V}/
-test $BASE_URL/camel-kafka-connector/ 302 $BASE_URL/camel-kafka-connector/${CKC_V}/
-test $BASE_URL/camel-kafka-connector/next 301 $BASE_URL/camel-kafka-connector/next/
-test $BASE_URL/camel-kafka-connector/next/ 200
-test $BASE_URL/camel-kafka-connector/latest 302 $BASE_URL/camel-kafka-connector/${CKC_V}
-test $BASE_URL/camel-kafka-connector/latest/ 302 $BASE_URL/camel-kafka-connector/${CKC_V}/
-test $BASE_URL/camel-kafka-connector/contributor-guide/release-guide.html 302 $BASE_URL/camel-kafka-connector/${CKC_V}/contributor-guide/release-guide.html
-test $BASE_URL/camel-kafka-connector/latest/contributor-guide/release-guide.html 302 $BASE_URL/camel-kafka-connector/${CKC_V}/contributor-guide/release-guide.html
-test $BASE_URL/camel-kafka-connector/${CKC_V}/contributor-guide/release-guide.html 200
-test $BASE_URL/camel-kafka-connector/next/contributor-guide/release-guide.html 200
-
-test $BASE_URL/camel-kamelets 302 $BASE_URL/camel-kamelets/next/
-test $BASE_URL/camel-kamelets/ 302 $BASE_URL/camel-kamelets/next/
-test $BASE_URL/camel-kamelets/next 301 $BASE_URL/camel-kamelets/next/
-test $BASE_URL/camel-kamelets/next/ 200
-test $BASE_URL/camel-kamelets/latest 302 $BASE_URL/camel-kamelets/next
-test $BASE_URL/camel-kamelets/latest/ 302 $BASE_URL/camel-kamelets/next/
-test $BASE_URL/camel-kamelets/github-source.html 302 $BASE_URL/camel-kamelets/next/github-source.html
-test $BASE_URL/camel-kamelets/latest/github-source.html 302 $BASE_URL/camel-kamelets/next/github-source.html
-test $BASE_URL/camel-kamelets/next/github-source.html 200
-test $BASE_URL/camel-kamelets/next/github-source.html 200
-
-test $BASE_URL/camel-quarkus 302 $BASE_URL/camel-quarkus/${CQ_V}/
-test $BASE_URL/camel-quarkus/ 302 $BASE_URL/camel-quarkus/${CQ_V}/
-test $BASE_URL/camel-quarkus/next 301 $BASE_URL/camel-quarkus/next/
-test $BASE_URL/camel-quarkus/next/ 200
-test $BASE_URL/camel-quarkus/latest 302 $BASE_URL/camel-quarkus/${CQ_V}
-test $BASE_URL/camel-quarkus/latest/ 302 $BASE_URL/camel-quarkus/${CQ_V}/
-test $BASE_URL/camel-quarkus/user-guide/cdi.html 302 $BASE_URL/camel-quarkus/${CQ_V}/user-guide/cdi.html
-test $BASE_URL/camel-quarkus/latest/user-guide/cdi.html 302 $BASE_URL/camel-quarkus/${CQ_V}/user-guide/cdi.html
-test $BASE_URL/camel-quarkus/${CQ_V}/user-guide/cdi.html 200
-test $BASE_URL/camel-quarkus/next/user-guide/cdi.html 200
-
-test $BASE_URL/manual 301 $BASE_URL/manual/
-test $BASE_URL/manual/latest 302 $BASE_URL/manual
-test $BASE_URL/manual/latest/ 302 $BASE_URL/manual/
-test $BASE_URL/manual/latest/component-dsl.html 302 $BASE_URL/manual/component-dsl.html
-test $BASE_URL/manual/ 200
-test $BASE_URL/manual/component-dsl.html 200
+COMPONENTS_VERSION="$(grep 'components/latest' documentation/.htaccess | grep -Z -o '[^/]*$')"
+CAMEL_K_VERSION="$(grep 'camel-k/latest' documentation/.htaccess | grep -Z -o '[^/]*$')"
+CAMEL_KAFKA_CONNECTOR_VERSION="$(grep 'camel-kafka-connector/latest' documentation/.htaccess | grep -Z -o '[^/]*$')"
+CAMEL_QUARKUS_VERSION="$(grep 'camel-quarkus/latest' documentation/.htaccess | grep -Z -o '[^/]*$')"
+CAMEL_KAMELETS_VERSION="$(grep 'camel-kamelets/latest' documentation/.htaccess | grep -Z -o '[^/]*$')"
+
+test "$BASE_URL/components" 302 "$BASE_URL/components/${COMPONENTS_VERSION}/"
+test "$BASE_URL/components/" 302 "$BASE_URL/components/${COMPONENTS_VERSION}/"
+test "$BASE_URL/components/next" 301 "$BASE_URL/components/next/"
+test "$BASE_URL/components/next/" 200
+test "$BASE_URL/components/latest" 302 "$BASE_URL/components/${COMPONENTS_VERSION}"
+test "$BASE_URL/components/latest/" 302 "$BASE_URL/components/${COMPONENTS_VERSION}/"
+test "$BASE_URL/components/activemq-component.html" 302 "$BASE_URL/components/${COMPONENTS_VERSION}/activemq-component.html"
+test "$BASE_URL/components/latest/activemq-component.html" 302 "$BASE_URL/components/${COMPONENTS_VERSION}/activemq-component.html"
+test "$BASE_URL/components/${COMPONENTS_VERSION}/activemq-component.html" 200
+test "$BASE_URL/components/next/activemq-component.html" 200
+
+test "$BASE_URL/camel-spring-boot" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-spring-boot/" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-spring-boot/next" 301 "$BASE_URL/camel-spring-boot/next/"
+test "$BASE_URL/camel-spring-boot/next/" 200
+test "$BASE_URL/camel-spring-boot/latest" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}"
+test "$BASE_URL/camel-spring-boot/latest/" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-spring-boot/list.html" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/list.html"
+test "$BASE_URL/camel-spring-boot/latest/list.html" 302 "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/list.html"
+test "$BASE_URL/camel-spring-boot/${COMPONENTS_VERSION}/list.html" 200
+test "$BASE_URL/camel-spring-boot/next/list.html" 200
+
+test "$BASE_URL/camel-k" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}/"
+test "$BASE_URL/camel-k/" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}/"
+test "$BASE_URL/camel-k/next" 301 "$BASE_URL/camel-k/next/"
+test "$BASE_URL/camel-k/next/" 200
+test "$BASE_URL/camel-k/latest" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}"
+test "$BASE_URL/camel-k/latest/" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}/"
+test "$BASE_URL/camel-k/traits/master.html" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}/traits/master.html"
+test "$BASE_URL/camel-k/latest/traits/master.html" 302 "$BASE_URL/camel-k/${CAMEL_K_VERSION}/traits/master.html"
+test "$BASE_URL/camel-k/${CAMEL_K_VERSION}/traits/master.html" 200
+test "$BASE_URL/camel-k/next/traits/master.html" 200
+
+test "$BASE_URL/camel-karaf" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-karaf/" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-karaf/next" 301 "$BASE_URL/camel-karaf/next/"
+test "$BASE_URL/camel-karaf/next/" 200
+test "$BASE_URL/camel-karaf/latest" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}"
+test "$BASE_URL/camel-karaf/latest/" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/"
+test "$BASE_URL/camel-karaf/latest/components.html" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/components.html"
+test "$BASE_URL/camel-karaf/latest/components.html" 302 "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/components.html"
+test "$BASE_URL/camel-karaf/${COMPONENTS_VERSION}/components.html" 200
+test "$BASE_URL/camel-karaf/next/components.html" 200
+
+test "$BASE_URL/camel-kafka-connector" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/"
+test "$BASE_URL/camel-kafka-connector/" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/"
+test "$BASE_URL/camel-kafka-connector/next" 301 "$BASE_URL/camel-kafka-connector/next/"
+test "$BASE_URL/camel-kafka-connector/next/" 200
+test "$BASE_URL/camel-kafka-connector/latest" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}"
+test "$BASE_URL/camel-kafka-connector/latest/" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/"
+test "$BASE_URL/camel-kafka-connector/contributor-guide/release-guide.html" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/contributor-guide/release-guide.html"
+test "$BASE_URL/camel-kafka-connector/latest/contributor-guide/release-guide.html" 302 "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/contributor-guide/release-guide.html"
+test "$BASE_URL/camel-kafka-connector/${CAMEL_KAFKA_CONNECTOR_VERSION}/contributor-guide/release-guide.html" 200
+test "$BASE_URL/camel-kafka-connector/next/contributor-guide/release-guide.html" 200
+
+test "$BASE_URL/camel-kamelets" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}/"
+test "$BASE_URL/camel-kamelets/" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}/"
+test "$BASE_URL/camel-kamelets/next" 301 "$BASE_URL/camel-kamelets/next/"
+test "$BASE_URL/camel-kamelets/next/" 200
+test "$BASE_URL/camel-kamelets/latest" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}"
+test "$BASE_URL/camel-kamelets/latest/" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}/"
+test "$BASE_URL/camel-kamelets/github-source.html" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}/github-source.html"
+test "$BASE_URL/camel-kamelets/latest/github-source.html" 302 "$BASE_URL/camel-kamelets/${CAMEL_KAMELETS_VERSION}/github-source.html"
+test "$BASE_URL/camel-kamelets/next/github-source.html" 200
+test "$BASE_URL/camel-kamelets/next/github-source.html" 200
+
+test "$BASE_URL/camel-quarkus" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/"
+test "$BASE_URL/camel-quarkus/" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/"
+test "$BASE_URL/camel-quarkus/next" 301 "$BASE_URL/camel-quarkus/next/"
+test "$BASE_URL/camel-quarkus/next/" 200
+test "$BASE_URL/camel-quarkus/latest" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}"
+test "$BASE_URL/camel-quarkus/latest/" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/"
+test "$BASE_URL/camel-quarkus/user-guide/cdi.html" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/user-guide/cdi.html"
+test "$BASE_URL/camel-quarkus/latest/user-guide/cdi.html" 302 "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/user-guide/cdi.html"
+test "$BASE_URL/camel-quarkus/${CAMEL_QUARKUS_VERSION}/user-guide/cdi.html" 200
+test "$BASE_URL/camel-quarkus/next/user-guide/cdi.html" 200
+
+test "$BASE_URL/manual" 301 "$BASE_URL/manual/"
+test "$BASE_URL/manual/latest" 302 "$BASE_URL/manual"
+test "$BASE_URL/manual/latest/" 302 "$BASE_URL/manual/"
+test "$BASE_URL/manual/latest/component-dsl.html" 302 "$BASE_URL/manual/component-dsl.html"
+test "$BASE_URL/manual/" 200
+test "$BASE_URL/manual/component-dsl.html" 200
+
+if [ "$TOTAL" == "$SUCCESS" ]; then
+  echo -e "$0 \e[1mSUCCESSFULLY\e[0m ran $TOTAL tests"
+else
+  echo -e "$0 \e[1m\e[31mFAILURE\e[0m: $((TOTAL - SUCCESS)) tests failed out of ${TOTAL}"
+  exit 1
+fi