|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# |
| 18 | +# This replay file assumes that caching is enabled and |
| 19 | +# proxy.config.http.cache.ignore_client_cc_max_age is set to 0 so that we can |
| 20 | +# test max-age in the client requests. |
| 21 | +# |
| 22 | + |
| 23 | +meta: |
| 24 | + version: "1.0" |
| 25 | + |
| 26 | +autest: |
| 27 | + description: 'Verify that stale content is served when the origin server is down' |
| 28 | + |
| 29 | + dns: |
| 30 | + name: 'dns-serve-stale-origin-down' |
| 31 | + records: |
| 32 | + backend.example.com: ["127.0.0.1"] |
| 33 | + |
| 34 | + |
| 35 | + server: |
| 36 | + name: 'server-serve-stale-origin-down' |
| 37 | + |
| 38 | + client: |
| 39 | + name: 'client-serve-stale-origin-down' |
| 40 | + |
| 41 | + ats: |
| 42 | + name: 'ts-serve-stale-origin-down' |
| 43 | + process_config: |
| 44 | + enable_cache: true |
| 45 | + |
| 46 | + records_config: |
| 47 | + proxy.config.diags.debug.enabled: 1 |
| 48 | + proxy.config.diags.debug.tags: 'cache|http|dns|hostdb' |
| 49 | + proxy.config.http.cache.max_stale_age: 10 |
| 50 | + proxy.config.http.connect.down.policy: 4 |
| 51 | + proxy.config.http.connect_attempts_timeout: 1 |
| 52 | + proxy.config.http.connect_attempts_rr_retries: 0 |
| 53 | + proxy.config.http.connect_attempts_max_retries: 1 |
| 54 | + proxy.config.http.connect_attempts_max_retries_down_server: 0 |
| 55 | + proxy.config.http.down_server.cache_time: 5 |
| 56 | + |
| 57 | + remap_config: |
| 58 | + - from: "http://example.com/" |
| 59 | + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" |
| 60 | + |
| 61 | + plugin_config: |
| 62 | + - 'xdebug.so --enable=x-cache,x-cache-key,via' |
| 63 | + |
| 64 | +sessions: |
| 65 | +- transactions: |
| 66 | + # 1. Cache object |
| 67 | + # cache-key: /path/a/ |
| 68 | + # cache: miss |
| 69 | + # origin server: up |
| 70 | + - client-request: |
| 71 | + method: "GET" |
| 72 | + version: "1.1" |
| 73 | + url: /path/a/ |
| 74 | + headers: |
| 75 | + fields: |
| 76 | + - [ Host, example.com ] |
| 77 | + - [ x-debug, "x-cache,x-cache-key,via" ] |
| 78 | + - [ uuid, a-1 ] |
| 79 | + |
| 80 | + server-response: |
| 81 | + status: 200 |
| 82 | + headers: |
| 83 | + fields: |
| 84 | + - [ Content-Length, 16] |
| 85 | + - [ Cache-Control, "public, max-age=1"] |
| 86 | + |
| 87 | + proxy-response: |
| 88 | + status: 200 |
| 89 | + headers: |
| 90 | + fields: |
| 91 | + - [ X-Cache, { value: miss, as: equal } ] |
| 92 | + |
| 93 | + # 2. Make the origin server down |
| 94 | + # cache-key: /path/b/ |
| 95 | + # cache: miss |
| 96 | + # origin server: down |
| 97 | + - client-request: |
| 98 | + method: "GET" |
| 99 | + version: "1.1" |
| 100 | + url: /path/b/ |
| 101 | + headers: |
| 102 | + fields: |
| 103 | + - [ Host, example.com ] |
| 104 | + - [ x-debug, "x-cache,x-cache-key,via" ] |
| 105 | + - [ uuid, b-1 ] |
| 106 | + |
| 107 | + server-response: |
| 108 | + on_connect: reset |
| 109 | + |
| 110 | + proxy-response: |
| 111 | + status: 502 |
| 112 | + headers: |
| 113 | + fields: |
| 114 | + - [ X-Cache, { value: miss, as: equal } ] |
| 115 | + |
| 116 | + # 3. Serve stale while down_serve.cache_time |
| 117 | + # cache-key: /path/a/ |
| 118 | + # cache: stale |
| 119 | + # origin server: down (cached) |
| 120 | + - client-request: |
| 121 | + delay: 2s |
| 122 | + method: "GET" |
| 123 | + version: "1.1" |
| 124 | + url: /path/a/ |
| 125 | + headers: |
| 126 | + fields: |
| 127 | + - [ Host, example.com ] |
| 128 | + - [ x-debug, "x-cache,x-cache-key,via" ] |
| 129 | + - [ uuid, a-2 ] |
| 130 | + |
| 131 | + proxy-request: |
| 132 | + expect: absent |
| 133 | + |
| 134 | + server-response: |
| 135 | + on_connect: reset |
| 136 | + |
| 137 | + proxy-response: |
| 138 | + status: 200 |
| 139 | + headers: |
| 140 | + fields: |
| 141 | + - [ X-Cache, { value: hit-stale, as: equal } ] |
| 142 | + |
| 143 | + # 4. Revalidate stale contents |
| 144 | + # cache-key: /path/a/ |
| 145 | + # cache: stale |
| 146 | + # origin server: up |
| 147 | + - client-request: |
| 148 | + delay: 5s |
| 149 | + method: "GET" |
| 150 | + version: "1.1" |
| 151 | + url: /path/a/ |
| 152 | + headers: |
| 153 | + fields: |
| 154 | + - [ Host, example.com ] |
| 155 | + - [ x-debug, "x-cache,x-cache-key,via" ] |
| 156 | + - [ uuid, a-99 ] |
| 157 | + |
| 158 | + server-response: |
| 159 | + status: 304 |
| 160 | + |
| 161 | + proxy-response: |
| 162 | + status: 200 |
| 163 | + headers: |
| 164 | + fields: |
| 165 | + - [ X-Cache, { value: hit-stale, as: equal } ] |
| 166 | + |
0 commit comments