tokers commented on a change in pull request #3883:
URL: https://github.com/apache/apisix/pull/3883#discussion_r600203356



##########
File path: t/cli/test_error_page.sh
##########
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# 'make init' operates scripts and related configuration files in the current 
directory
+# The 'apisix' command is a command in the /usr/local/apisix,
+# and the configuration file for the operation is in the /usr/local/apisix/conf
+
+. ./t/cli/common.sh
+
+git checkout conf/config.yaml
+make init
+
+make run
+sleep 0.1
+
+# set route
+code=$(curl -XPUT -k -i -m 20 -o /dev/null -s -w %{http_code} 
http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -d '{
+    "uri": "/error_page",
+    "plugins": {
+        "serverless-pre-function": {
+            "phase": "rewrite",
+            "functions" : ["return function() local status = 
ngx.var.http_X_Test_Status ;ngx.exit(tonumber(status));end"]

Review comment:
       Use small cases `http_X_Test_Status` => `http_x_test_status`.

##########
File path: t/cli/test_error_page.sh
##########
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# 'make init' operates scripts and related configuration files in the current 
directory
+# The 'apisix' command is a command in the /usr/local/apisix,
+# and the configuration file for the operation is in the /usr/local/apisix/conf
+
+. ./t/cli/common.sh
+
+git checkout conf/config.yaml
+make init
+
+make run
+sleep 0.1
+
+# set route
+code=$(curl -XPUT -k -i -m 20 -o /dev/null -s -w %{http_code} 
http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -d '{
+    "uri": "/error_page",
+    "plugins": {
+        "serverless-pre-function": {
+            "phase": "rewrite",
+            "functions" : ["return function() local status = 
ngx.var.http_X_Test_Status ;ngx.exit(tonumber(status));end"]
+        }
+    }
+}')
+if [ ! $code -eq 201 ]; then
+    echo "failed: add route failed"
+    exit 1
+fi
+
+sleep 0.1
+# test 5xx html
+for status in 500 502 503 504;
+do
+    resp=$(curl http://127.0.0.1:9080/error_page -H 'X-Test-Status: '${status})
+    if [[ `echo $resp | grep -c "apisix.apache.org"` -eq '0' ]]; then
+         echo "failed: the error page is not customized"
+         exit 1
+    fi
+done

Review comment:
       Should also add some test cases that an upstream returns `5xx` but these 
error pages are not shown.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to