Skip to content

Commit 0c8b658

Browse files
committed
Adds some autests
1 parent b26230e commit 0c8b658

2 files changed

Lines changed: 241 additions & 0 deletions

File tree

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
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+
meta:
18+
version: "1.0"
19+
20+
# Configuration section for autest integration
21+
autest:
22+
description: "Test proxy.config.cache.default_volumes configuration"
23+
24+
dns:
25+
name: "dns"
26+
27+
server:
28+
name: "server"
29+
30+
client:
31+
name: "client"
32+
33+
ats:
34+
name: "ts"
35+
36+
records_config:
37+
proxy.config.diags.debug.enabled: 1
38+
proxy.config.diags.debug.tags: "cache|cache_hosting|cache_init"
39+
proxy.config.http.insert_response_via_str: 0
40+
proxy.config.cache.enable_read_while_writer: 0
41+
# Set default volumes to volume 2 - this is the key configuration under test
42+
proxy.config.cache.default_volumes: "2"
43+
44+
volume_config:
45+
# Volume 1: Used for explicit @volume=1 selection
46+
- volume: 1
47+
scheme: "http"
48+
size: "32M"
49+
50+
# Volume 2: Used as the default volume via default_volumes setting
51+
- volume: 2
52+
scheme: "http"
53+
size: "32M"
54+
55+
# Volume 3: Another volume to verify routing is correct
56+
- volume: 3
57+
scheme: "http"
58+
size: "32M"
59+
60+
remap_config:
61+
# Default volume selection (should use default_volumes -> volume 2)
62+
- from: "http://default.example.com/"
63+
to: "http://backend.ex:{SERVER_HTTP_PORT}/"
64+
65+
# Explicit volume 1 selection (should override default_volumes)
66+
- from: "http://volume1.example.com/"
67+
to: "http://backend.ex:{SERVER_HTTP_PORT}/"
68+
options:
69+
- "@volume=1"
70+
71+
# Explicit volume 3 selection (should override default_volumes)
72+
- from: "http://volume3.example.com/"
73+
to: "http://backend.ex:{SERVER_HTTP_PORT}/"
74+
options:
75+
- "@volume=3"
76+
77+
# Proxy verifier test sessions
78+
sessions:
79+
# Test 1: Request using default_volumes (should use volume 2)
80+
# This verifies that when no @volume= is specified, the default_volumes setting is used
81+
- transactions:
82+
- client-request:
83+
method: "GET"
84+
version: "1.1"
85+
url: "/default_test"
86+
headers:
87+
fields:
88+
- [Host, default.example.com]
89+
- [X-Test-ID, "default-volumes-test"]
90+
- [uuid, 1]
91+
92+
server-response:
93+
status: 200
94+
reason: OK
95+
headers:
96+
fields:
97+
- [Content-Type, "text/plain"]
98+
- [Cache-Control, "max-age=3600"]
99+
- [X-Default-Volumes-Test, "success"]
100+
content:
101+
data: "Content using default_volumes"
102+
103+
proxy-response:
104+
status: 200
105+
headers:
106+
fields:
107+
- [X-Default-Volumes-Test, { value: "success", as: equal }]
108+
109+
# Test 2: Request with explicit @volume=1 (should override default_volumes)
110+
- transactions:
111+
- client-request:
112+
method: "GET"
113+
version: "1.1"
114+
url: "/volume1_test"
115+
headers:
116+
fields:
117+
- [Host, volume1.example.com]
118+
- [X-Test-ID, "volume1-override-test"]
119+
- [uuid, 2]
120+
121+
server-response:
122+
status: 200
123+
reason: OK
124+
headers:
125+
fields:
126+
- [Content-Type, "text/plain"]
127+
- [Cache-Control, "max-age=3600"]
128+
- [X-Volume-Override, "volume1"]
129+
content:
130+
data: "Content explicitly on volume 1"
131+
132+
proxy-response:
133+
status: 200
134+
headers:
135+
fields:
136+
- [X-Volume-Override, { value: "volume1", as: equal }]
137+
138+
# Test 3: Request with explicit @volume=3 (should override default_volumes)
139+
- transactions:
140+
- client-request:
141+
method: "GET"
142+
version: "1.1"
143+
url: "/volume3_test"
144+
headers:
145+
fields:
146+
- [Host, volume3.example.com]
147+
- [X-Test-ID, "volume3-override-test"]
148+
- [uuid, 3]
149+
150+
server-response:
151+
status: 200
152+
reason: OK
153+
headers:
154+
fields:
155+
- [Content-Type, "text/plain"]
156+
- [Cache-Control, "max-age=3600"]
157+
- [X-Volume-Override, "volume3"]
158+
content:
159+
data: "Content explicitly on volume 3"
160+
161+
proxy-response:
162+
status: 200
163+
headers:
164+
fields:
165+
- [X-Volume-Override, { value: "volume3", as: equal }]
166+
167+
# Test 4: Cache hit test for default_volumes content
168+
# First request to populate cache
169+
- transactions:
170+
- client-request:
171+
method: "GET"
172+
version: "1.1"
173+
url: "/cached_default"
174+
headers:
175+
fields:
176+
- [Host, default.example.com]
177+
- [X-Test-ID, "cache-hit-setup"]
178+
- [uuid, 4]
179+
180+
server-response:
181+
status: 200
182+
reason: OK
183+
headers:
184+
fields:
185+
- [Content-Type, "text/plain"]
186+
- [Cache-Control, "max-age=3600"]
187+
- [X-Origin-Response, "yes"]
188+
content:
189+
data: "Cached content via default_volumes"
190+
191+
proxy-response:
192+
status: 200
193+
headers:
194+
fields:
195+
- [X-Origin-Response, { value: "yes", as: equal }]
196+
197+
# Test 5: Second request should be a cache hit
198+
- transactions:
199+
- client-request:
200+
method: "GET"
201+
version: "1.1"
202+
url: "/cached_default"
203+
headers:
204+
fields:
205+
- [Host, default.example.com]
206+
- [X-Test-ID, "cache-hit-verify"]
207+
- [uuid, 5]
208+
209+
# Server should not be contacted for cache hit
210+
server-response:
211+
status: 500
212+
reason: "Should not reach server"
213+
214+
proxy-response:
215+
status: 200
216+
content:
217+
data: "Cached content via default_volumes"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
Test.Summary = '''
18+
Test proxy.config.cache.default_volumes configuration:
19+
- Verify that default_volumes is used as fallback when no other volume selection applies
20+
- Verify that @volume= directive takes priority over default_volumes
21+
- Verify that hosting.config takes priority over default_volumes
22+
'''
23+
24+
Test.ATSReplayTest(replay_file="cache_volume_defaults.replay.yaml",)

0 commit comments

Comments
 (0)