nic-6443 commented on code in PR #14055:
URL: https://github.com/apache/apisix/pull/14055#discussion_r4323464122


##########
t/cli/test_proxy_cache_purge.sh:
##########
@@ -0,0 +1,139 @@
+#!/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.
+#
+
+. ./t/cli/common.sh

Review Comment:
   errexit is already on: the script sources `t/cli/common.sh`, which starts 
with `set -ex`, so a failing bare `[ ... ]` exits the script non-zero (that is 
the convention the other `t/cli` scripts rely on too). Without the template fix 
the script does exit 1 here, so the assertions do fail. Leaving them as is.



##########
t/cli/test_proxy_cache_purge.sh:
##########
@@ -0,0 +1,139 @@
+#!/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.
+#
+
+. ./t/cli/common.sh
+
+# The http block of the generated nginx.conf enables open_file_cache, which the
+# test-nginx based cases don't have. A disk cache entry removed by PURGE must 
not
+# be served again from a file descriptor cached before the purge.
+
+echo '
+deployment:
+  admin:
+    admin_key_required: false
+    admin_key: ~
+nginx_config:
+  worker_processes: 1
+  http_configuration_snippet: |
+    server {
+        listen 1980;
+        location / {
+            return 200 "hello";
+        }
+    }
+' > conf/config.yaml
+
+rm -rf /tmp/disk_cache_one/*
+make run
+sleep 1

Review Comment:
   Agreed, switched to the `wait_for_tcp 127.0.0.1 9180` helper from 
`common.sh`, which is what the other scripts use after `make run`, in 4d7bcf44f.



##########
t/cli/test_proxy_cache_purge.sh:
##########
@@ -0,0 +1,139 @@
+#!/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.
+#
+
+. ./t/cli/common.sh
+
+# The http block of the generated nginx.conf enables open_file_cache, which the
+# test-nginx based cases don't have. A disk cache entry removed by PURGE must 
not
+# be served again from a file descriptor cached before the purge.
+
+echo '
+deployment:
+  admin:
+    admin_key_required: false
+    admin_key: ~
+nginx_config:
+  worker_processes: 1
+  http_configuration_snippet: |
+    server {
+        listen 1980;
+        location / {
+            return 200 "hello";
+        }
+    }
+' > conf/config.yaml
+
+rm -rf /tmp/disk_cache_one/*
+make run
+sleep 1
+
+admin() {
+    curl -s -o /dev/null -w "%{http_code}" 
http://127.0.0.1:9180/apisix/admin$1 -X PUT -d "$2"
+}

Review Comment:
   The Admin API decodes the body as JSON whatever the Content-Type is, and the 
existing `t/cli` scripts send admin requests the same way (only 2 of 26 set the 
header). Keeping it consistent with them.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to