This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.1.x by this push:
new 4e7f1e7 Add Au test for strategies.yaml, with consistent hashing,
with fallover. (#7914)
4e7f1e7 is described below
commit 4e7f1e7e0adf7ef410637640ae05e3b34aa8cf3f
Author: Walt Karas <[email protected]>
AuthorDate: Thu Jun 3 11:10:47 2021 -0500
Add Au test for strategies.yaml, with consistent hashing, with fallover.
(#7914)
(cherry picked from commit c38992ccd38e4adacd633f024d3ca858e3f21431)
---
tests/gold_tests/next_hop/strategies_ch2/body.gold | 1 +
.../next_hop/strategies_ch2/strategies_ch2.test.py | 159 +++++++++++++++++++++
.../gold_tests/next_hop/strategies_ch2/trace.gold | 82 +++++++++++
3 files changed, 242 insertions(+)
diff --git a/tests/gold_tests/next_hop/strategies_ch2/body.gold
b/tests/gold_tests/next_hop/strategies_ch2/body.gold
new file mode 100644
index 0000000..b220ced
--- /dev/null
+++ b/tests/gold_tests/next_hop/strategies_ch2/body.gold
@@ -0,0 +1 @@
+This is the body.
diff --git a/tests/gold_tests/next_hop/strategies_ch2/strategies_ch2.test.py
b/tests/gold_tests/next_hop/strategies_ch2/strategies_ch2.test.py
new file mode 100644
index 0000000..3dcf1d5
--- /dev/null
+++ b/tests/gold_tests/next_hop/strategies_ch2/strategies_ch2.test.py
@@ -0,0 +1,159 @@
+'''
+'''
+# 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 next hop selection using strategies.yaml with consistent hashing, with
fallover
+'''
+
+# Define and populate MicroServer.
+#
+server = Test.MakeOriginServer("server")
+response_header = {
+ "headers":
+ "HTTP/1.1 200 OK\r\n"
+ "Connection: close\r\n"
+ "Cache-control: max-age=85000\r\n"
+ "\r\n",
+ "timestamp": "1469733493.993",
+ "body": "This is the body.\n"
+}
+num_objects = 32
+for i in range(num_objects):
+ request_header = {
+ "headers":
+ f"GET /obj{i} HTTP/1.1\r\n"
+ "Host: does.not.matter\r\n" # But cannot be omitted.
+ "\r\n",
+ "timestamp": "1469733493.993",
+ "body": ""
+ }
+ server.addResponse("sessionlog.json", request_header, response_header)
+
+dns = Test.MakeDNServer("dns")
+
+# Define next hop trafficserver instances.
+#
+num_nh = 8
+ts_nh = []
+for i in range(num_nh):
+ ts = Test.MakeATSProcess(f"ts_nh{i}")
+ ts.Disk.records_config.update({
+ 'proxy.config.diags.debug.enabled': 1,
+ 'proxy.config.diags.debug.tags': 'http|dns',
+ 'proxy.config.dns.nameservers': f"127.0.0.1:{dns.Variables.Port}",
+ 'proxy.config.dns.resolv_conf': "NULL",
+ })
+ ts.Disk.remap_config.AddLine(
+ f"map / http://127.0.0.1:{server.Variables.Port}"
+ )
+ ts_nh.append(ts)
+
+ts = Test.MakeATSProcess("ts", command="traffic_server 2> trace.log")
+
+ts.Disk.records_config.update({
+ 'proxy.config.diags.debug.enabled': 1,
+ 'proxy.config.diags.debug.tags':
'http|dns|parent|next_hop|host_statuses|hostdb',
+ 'proxy.config.dns.nameservers': f"127.0.0.1:{dns.Variables.Port}", # Only
nameservers if resolv_conf NULL.
+ 'proxy.config.dns.resolv_conf': "NULL", # This defaults to
/etc/resvolv.conf (OS namesevers) if not NULL.
+ 'proxy.config.http.cache.http': 0,
+ 'proxy.config.http.uncacheable_requests_bypass_parent': 0,
+ 'proxy.config.http.no_dns_just_forward_to_parent': 1,
+ 'proxy.config.http.parent_proxy.mark_down_hostdb': 1,
+ 'proxy.config.http.parent_proxy.self_detect': 0,
+})
+
+ts.Disk.File(ts.Variables.CONFIGDIR + "/strategies.yaml", id="strategies",
typename="ats:config")
+s = ts.Disk.strategies
+s.AddLine("groups:")
+s.AddLine(" - &g1")
+for i in range(num_nh):
+ dns.addRecords(records={f"next_hop{i}": ["127.0.0.1"]})
+ s.AddLine(f" - host: next_hop{i}")
+ s.AddLine(f" protocol:")
+ s.AddLine(f" - scheme: http")
+ s.AddLine(f" port: {ts_nh[i].Variables.port}")
+ # The health check URL does not seem to be used currently.
+ # s.AddLine(f" health_check_url:
http://next_hop{i}:{ts_nh[i].Variables.port}")
+ s.AddLine(f" weight: 1.0")
+s.AddLines([
+ "strategies:",
+ " - strategy: the-strategy",
+ " policy: consistent_hash",
+ " hash_key: path",
+ " go_direct: false",
+ " parent_is_proxy: true",
+ " ignore_self_detect: true",
+ " groups:",
+ " - *g1",
+ " scheme: http"
+])
+
+# Use default fallover config.
+#
+# s.AddLines([
+# " fallover:",
+# " max_simple_retries: 2",
+# " ring_mode: exhaust_ring",
+# " response_codes:",
+# " - 404",
+# " health_check:",
+# " - passive"
+# ])
+
+ts.Disk.remap_config.AddLine(
+ "map http://dummy.com http://not_used @strategy=the-strategy"
+)
+
+tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(server)
+tr.Processes.Default.StartBefore(dns)
+for i in range(num_nh):
+ if (i != 3) and (i != 6):
+ tr.Processes.Default.StartBefore(ts_nh[i])
+tr.Processes.Default.StartBefore(Test.Processes.ts)
+tr.Processes.Default.Command = 'echo start TS, HTTP server, DNS server and all
but 2 next hop TSes'
+tr.Processes.Default.ReturnCode = 0
+
+for i in range(num_objects):
+ tr = Test.AddTestRun()
+ tr.Processes.Default.Command = (
+ f'curl --verbose --proxy 127.0.0.1:{ts.Variables.port}
http://dummy.com/obj{i}'
+ )
+ tr.Processes.Default.Streams.stdout = "body.gold"
+ tr.Processes.Default.ReturnCode = 0
+
+tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(ts_nh[3])
+tr.Processes.Default.StartBefore(ts_nh[6])
+tr.Processes.Default.Command = 'echo start the 2 unstarted next hop TSes'
+tr.Processes.Default.ReturnCode = 0
+
+for i in range(num_objects):
+ tr = Test.AddTestRun()
+ tr.Processes.Default.Command = (
+ f'curl --verbose --proxy 127.0.0.1:{ts.Variables.port}
http://dummy.com/obj{i}'
+ )
+ tr.Processes.Default.Streams.stdout = "body.gold"
+ tr.Processes.Default.ReturnCode = 0
+
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = (
+ "grep -F PARENT_SPECIFIED trace.log | sed 's/^.*(next_hop) [^ ]* //' | sed
's/[.][0-9]*$$//'"
+)
+tr.Processes.Default.Streams.stdout = "trace.gold"
+tr.Processes.Default.ReturnCode = 0
diff --git a/tests/gold_tests/next_hop/strategies_ch2/trace.gold
b/tests/gold_tests/next_hop/strategies_ch2/trace.gold
new file mode 100644
index 0000000..06092b3
--- /dev/null
+++ b/tests/gold_tests/next_hop/strategies_ch2/trace.gold
@@ -0,0 +1,82 @@
+result->result: PARENT_SPECIFIED Chosen parent: next_hop6
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop4
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop4
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop4
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop4
+result->result: PARENT_SPECIFIED Chosen parent: next_hop7
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop7
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+not firstcall, line_number: 0, result: PARENT_SPECIFIED
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop6
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop4
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop2
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop0
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop7
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop1
+result->result: PARENT_SPECIFIED Chosen parent: next_hop5
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3
+result->result: PARENT_SPECIFIED Chosen parent: next_hop7
+result->result: PARENT_SPECIFIED Chosen parent: next_hop3