You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/03/29 20:01:24 UTC
[trafficserver] branch 9.0.x updated: Adding negative revalidating
AuTests. (#7620)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new ba2d3c3 Adding negative revalidating AuTests. (#7620)
ba2d3c3 is described below
commit ba2d3c32251cfe06dbadcc8ef1b2f6db6b6bdeac
Author: Brian Neradt <br...@verizonmedia.com>
AuthorDate: Thu Mar 25 17:51:41 2021 -0500
Adding negative revalidating AuTests. (#7620)
(cherry picked from commit c749721c2945ee1624185e1a9bf394c0d873fcfe)
---
.../gold_tests/cache/negative-revalidating.test.py | 70 +++++++++++
.../negative-revalidating-disabled.replay.yaml | 102 ++++++++++++++++
.../negative-revalidating-enabled.replay.yaml | 133 +++++++++++++++++++++
3 files changed, 305 insertions(+)
diff --git a/tests/gold_tests/cache/negative-revalidating.test.py b/tests/gold_tests/cache/negative-revalidating.test.py
new file mode 100644
index 0000000..1f49752
--- /dev/null
+++ b/tests/gold_tests/cache/negative-revalidating.test.py
@@ -0,0 +1,70 @@
+'''
+Test the negative revalidating feature.
+'''
+# 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.
+
+Test.Summary = '''
+Test the negative revalidating feature.
+'''
+
+#
+# Verify disabled negative_revalidating behavior.
+#
+ts = Test.MakeATSProcess("ts-negative-revalidating-disabled")
+ts.Disk.records_config.update({
+ 'proxy.config.diags.debug.enabled': 1,
+ 'proxy.config.diags.debug.tags': 'http',
+ 'proxy.config.http.insert_age_in_response': 0,
+
+ 'proxy.config.http.negative_revalidating_enabled': 0,
+ 'proxy.config.http.cache.max_stale_age': 6
+})
+tr = Test.AddTestRun("Verify disabled negative revalidating behavior.")
+replay_file = "replay/negative-revalidating-disabled.replay.yaml"
+server = tr.AddVerifierServerProcess("server1", replay_file)
+server_port = server.Variables.http_port
+tr.AddVerifierClientProcess("client1", replay_file, http_ports=[ts.Variables.port])
+ts.Disk.remap_config.AddLine(
+ 'map / http://127.0.0.1:{0}'.format(server_port)
+)
+tr.Processes.Default.StartBefore(ts)
+tr.StillRunningAfter = ts
+
+#
+# Verify enabled negative_revalidating behavior.
+#
+ts = Test.MakeATSProcess("ts-negative-revalidating-enabled")
+ts.Disk.records_config.update({
+ 'proxy.config.diags.debug.enabled': 1,
+ 'proxy.config.diags.debug.tags': 'http',
+ 'proxy.config.http.insert_age_in_response': 0,
+
+ # Negative revalidating is on by default. Verify this by leaving out the
+ # following line and expect negative_revalidating to be enabled.
+ # 'proxy.config.http.negative_revalidating_enabled': 1,
+ 'proxy.config.http.cache.max_stale_age': 6
+})
+tr = Test.AddTestRun("Verify negative revalidating behavior.")
+replay_file = "replay/negative-revalidating-enabled.replay.yaml"
+server = tr.AddVerifierServerProcess("server2", replay_file)
+server_port = server.Variables.http_port
+tr.AddVerifierClientProcess("client2", replay_file, http_ports=[ts.Variables.port])
+ts.Disk.remap_config.AddLine(
+ 'map / http://127.0.0.1:{0}'.format(server_port)
+)
+tr.Processes.Default.StartBefore(ts)
+tr.StillRunningAfter = ts
diff --git a/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml b/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml
new file mode 100644
index 0000000..cfc3c9b
--- /dev/null
+++ b/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml
@@ -0,0 +1,102 @@
+# 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.
+
+#
+# Verify negative_revalidating disabled behavior. This replay file assumes that
+# ATS is configured with negative_revalidating disabled.
+#
+
+meta:
+ version: "1.0"
+
+sessions:
+- transactions:
+
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 1 ]
+
+ # Populate the cache with a 200 response.
+ server-response:
+ status: 200
+ reason: "OK"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ proxy-response:
+ status: 200
+
+ # Verify we serve the 200 OK out of the cache if it is not stale.
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 2 ]
+
+ # Give cache IO enough time to finish.
+ delay: 100ms
+
+ # This should not reach the origin server.
+ server-response:
+ status: 503
+ reason: "Service Unavailable"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ # Again, we should serve this out of the cache.
+ proxy-response:
+ status: 200
+
+ # Verify we serve a 5xx response if the cached 200 OK is stale.
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 3 ]
+
+ # Make sure the item is stale per it's 2 second max-age.
+ delay: 4s
+
+ server-response:
+ status: 503
+ reason: "Service Unavailable"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ # Now the origin's 503 response should be served because
+ # negative_revalidating is disabled.
+ proxy-response:
+ status: 503
diff --git a/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml b/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml
new file mode 100644
index 0000000..3fdb971
--- /dev/null
+++ b/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml
@@ -0,0 +1,133 @@
+# 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.
+
+#
+# Verify negative_revalidating disabled behavior. This replay file assumes:
+# * ATS is configured with negative_revalidating disabled.
+# * max_stale_age is set to 6 seconds.
+#
+
+meta:
+ version: "1.0"
+
+sessions:
+- transactions:
+
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 1 ]
+
+ # Populate the cache with a 200 response.
+ server-response:
+ status: 200
+ reason: "OK"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ proxy-response:
+ status: 200
+
+ # Verify we serve the 200 OK out of the cache if it is not stale.
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 2 ]
+
+ # Give cache IO enough time to finish.
+ delay: 100ms
+
+ # This should not reach the origin server.
+ server-response:
+ status: 503
+ reason: "Service Unavailable"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ # Again, we should serve this out of the cache.
+ proxy-response:
+ status: 200
+
+ # Verify that with negative_revalidating enabled, we serve the 200 OK out of
+ # the cache even though it is stale (but younger than max_stale_age).
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 3 ]
+
+ # Make sure the item is stale per it's 2 second max-age.
+ delay: 4s
+
+ server-response:
+ status: 503
+ reason: "Service Unavailable"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ # With negative_revalidating enabled, the cached response should be served
+ # even though it is stale.
+ proxy-response:
+ status: 200
+
+ # Verify that max_stale_age is respected.
+ - client-request:
+ method: "GET"
+ version: "1.1"
+ scheme: "http"
+ url: /path/reques_item
+ headers:
+ fields:
+ - [ Host, example.com ]
+ - [ uuid, 4 ]
+
+ # After this delay, the item is 8 seconds old. This makes it:
+ # 6 seconds beyond the server's max-age of 2 seconds and
+ # 2 seconds beyond ATS's max_stale_age of 6 seconds.
+ delay: 4s
+
+ server-response:
+ status: 503
+ reason: "Service Unavailable"
+ headers:
+ fields:
+ - [ Content-Length, 32 ]
+ - [ Cache-Control, max-age=2 ]
+
+ # negative_revalidating is enabled, but now the cached item is older than
+ # max_stale_age.
+ proxy-response:
+ status: 503