|
| 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 | +# Verify RangeTransform on stale-revalidate |
| 18 | +# |
| 19 | +# Preconditions for the bug: |
| 20 | +# 1. Client request has a `Range` header. |
| 21 | +# 2. Cached object is stale, so ATS revalidates. |
| 22 | +# 3. Origin returns `200 OK` with the full body (not 304, not 206). |
| 23 | +# 4. The fresh `Content-Length` differs from the cached object size. |
| 24 | + |
| 25 | +meta: |
| 26 | + version: '1.0' |
| 27 | + |
| 28 | +autest: |
| 29 | + description: 'Verify RangeTransform' |
| 30 | + |
| 31 | + dns: |
| 32 | + name: "dns-range-transform" |
| 33 | + |
| 34 | + server: |
| 35 | + name: "server-range-transform" |
| 36 | + |
| 37 | + client: |
| 38 | + name: "client-range-transform" |
| 39 | + |
| 40 | + ats: |
| 41 | + name: "ts-range-transform" |
| 42 | + |
| 43 | + process_config: |
| 44 | + enable_cache: true |
| 45 | + |
| 46 | + records_config: |
| 47 | + proxy.config.http.wait_for_cache: 1 |
| 48 | + proxy.config.http.cache.required_headers: 0 |
| 49 | + proxy.config.diags.debug.enabled: 1 |
| 50 | + proxy.config.diags.debug.tags: 'http' |
| 51 | + |
| 52 | + remap_config: |
| 53 | + - from: "http://example.com/" |
| 54 | + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" |
| 55 | + |
| 56 | + log_validation: |
| 57 | + traffic_out: |
| 58 | + contains: |
| 59 | + - expression: 'perform_transform_cache_write_action CacheAction_t::REPLACE' |
| 60 | + description: 'Stale cache is replaced via RangeTransform' |
| 61 | + |
| 62 | +sessions: |
| 63 | + # Prime cache with BIG body. |
| 64 | + - transactions: |
| 65 | + - client-request: |
| 66 | + method: "GET" |
| 67 | + version: "1.1" |
| 68 | + url: /obj |
| 69 | + headers: |
| 70 | + fields: |
| 71 | + - [Host, example.com] |
| 72 | + - [uuid, prime] |
| 73 | + |
| 74 | + server-response: |
| 75 | + status: 200 |
| 76 | + reason: OK |
| 77 | + headers: |
| 78 | + fields: |
| 79 | + - [Date, "Mon, 01 Jan 2026 00:00:00 GMT"] |
| 80 | + - [Cache-Control, "max-age=1, public"] |
| 81 | + - [Content-Type, application/octet-stream] |
| 82 | + - [Content-Length, 64097] |
| 83 | + content: |
| 84 | + size: 64097 |
| 85 | + |
| 86 | + proxy-response: |
| 87 | + status: 200 |
| 88 | + |
| 89 | + # Stale revalidate: origin body shrunk to 40000, Range end (64096) unreachable. |
| 90 | + - transactions: |
| 91 | + - client-request: |
| 92 | + delay: 1500ms |
| 93 | + method: "GET" |
| 94 | + version: "1.1" |
| 95 | + url: /obj |
| 96 | + headers: |
| 97 | + fields: |
| 98 | + - [Host, example.com] |
| 99 | + - [uuid, range-revalidate] |
| 100 | + - [Range, "bytes=0-64096"] |
| 101 | + |
| 102 | + server-response: |
| 103 | + status: 200 |
| 104 | + reason: OK |
| 105 | + headers: |
| 106 | + fields: |
| 107 | + - [Date, "Mon, 01 Jan 2026 00:00:05 GMT"] |
| 108 | + - [Cache-Control, "max-age=1, public"] |
| 109 | + - [Content-Type, application/octet-stream] |
| 110 | + - [Content-Length, 40000] |
| 111 | + content: |
| 112 | + size: 40000 |
| 113 | + |
| 114 | + proxy-response: |
| 115 | + status: 206 |
| 116 | + reason: Partial Content |
| 117 | + headers: |
| 118 | + fields: |
| 119 | + - [Content-Range, {value: "bytes 0-39999/40000", as: equal}] |
| 120 | + - [Content-Length, {value: 40000, as: equal}] |
| 121 | + |
| 122 | + |
| 123 | + # Stale revalidate: origin body grown to 80000 (larger than cached). Range stays |
| 124 | + # satisfiable, but Content-Range total must reflect fresh 80000, not stale size. |
| 125 | + - transactions: |
| 126 | + - client-request: |
| 127 | + delay: 1500ms |
| 128 | + method: "GET" |
| 129 | + version: "1.1" |
| 130 | + url: /obj |
| 131 | + headers: |
| 132 | + fields: |
| 133 | + - [Host, example.com] |
| 134 | + - [uuid, range-revalidate-grown] |
| 135 | + - [Range, "bytes=0-64096"] |
| 136 | + |
| 137 | + server-response: |
| 138 | + status: 200 |
| 139 | + reason: OK |
| 140 | + headers: |
| 141 | + fields: |
| 142 | + - [Date, "Mon, 01 Jan 2026 00:00:10 GMT"] |
| 143 | + - [Cache-Control, "max-age=1, public"] |
| 144 | + - [Content-Type, application/octet-stream] |
| 145 | + - [Content-Length, 80000] |
| 146 | + content: |
| 147 | + size: 80000 |
| 148 | + |
| 149 | + proxy-response: |
| 150 | + status: 206 |
| 151 | + reason: Partial Content |
| 152 | + headers: |
| 153 | + fields: |
| 154 | + - [Content-Range, {value: "bytes 0-64096/80000", as: equal}] |
| 155 | + - [Content-Length, {value: 64097, as: equal}] |
| 156 | + |
| 157 | + # Error Cases: when requested range is unsatisfiable, choices are below from RFC 9110. Our choice is B. |
| 158 | + # A). Return 416 Range Not Satisfiable |
| 159 | + # B). Ignore Range header, return 200 OK |
| 160 | + |
| 161 | + # Stale revalidate: new origin body is empty |
| 162 | + - transactions: |
| 163 | + - client-request: |
| 164 | + delay: 1500ms |
| 165 | + method: "GET" |
| 166 | + version: "1.1" |
| 167 | + url: /obj |
| 168 | + headers: |
| 169 | + fields: |
| 170 | + - [Host, example.com] |
| 171 | + - [uuid, range-revalidate-empty] |
| 172 | + - [Range, "bytes=0-64096"] |
| 173 | + |
| 174 | + server-response: |
| 175 | + status: 200 |
| 176 | + reason: OK |
| 177 | + headers: |
| 178 | + fields: |
| 179 | + - [Date, "Mon, 01 Jan 2026 00:00:20 GMT"] |
| 180 | + - [Cache-Control, "max-age=1, public"] |
| 181 | + - [Content-Type, application/octet-stream] |
| 182 | + - [Content-Length, 0] |
| 183 | + content: |
| 184 | + size: 0 |
| 185 | + |
| 186 | + proxy-response: |
| 187 | + status: 200 |
| 188 | + reason: OK |
| 189 | + headers: |
| 190 | + fields: |
| 191 | + - [Content-Length, 40000] |
| 192 | + |
| 193 | + # Stale revalidate: new origin body is smaller than requested range |
| 194 | + - transactions: |
| 195 | + - client-request: |
| 196 | + delay: 1500ms |
| 197 | + method: "GET" |
| 198 | + version: "1.1" |
| 199 | + url: /obj |
| 200 | + headers: |
| 201 | + fields: |
| 202 | + - [Host, example.com] |
| 203 | + - [uuid, range-revalidate-out-of-range] |
| 204 | + - [Range, "bytes=60000-64096"] |
| 205 | + |
| 206 | + server-response: |
| 207 | + status: 200 |
| 208 | + reason: OK |
| 209 | + headers: |
| 210 | + fields: |
| 211 | + - [Date, "Mon, 01 Jan 2026 00:00:30 GMT"] |
| 212 | + - [Cache-Control, "max-age=1, public"] |
| 213 | + - [Content-Type, application/octet-stream] |
| 214 | + - [Content-Length, 40000] |
| 215 | + content: |
| 216 | + size: 40000 |
| 217 | + |
| 218 | + proxy-response: |
| 219 | + status: 200 |
| 220 | + reason: OK |
| 221 | + headers: |
| 222 | + fields: |
| 223 | + - [Content-Length, 40000] |
0 commit comments