You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2020/11/30 22:46:45 UTC

[trafficserver] branch master updated: AuTest for Split DNS (#7325)

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new ba36d58  AuTest for Split DNS (#7325)
ba36d58 is described below

commit ba36d581c058bbd34e233a241aeebfb3c752cf44
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Tue Dec 1 07:46:35 2020 +0900

    AuTest for Split DNS (#7325)
---
 .../splitdns/gold/test_case_0_stderr.gold          | 10 +++
 .../splitdns/gold/test_case_1_stderr.gold          | 10 +++
 tests/gold_tests/splitdns/splitdns.test.py         | 79 ++++++++++++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/tests/gold_tests/splitdns/gold/test_case_0_stderr.gold b/tests/gold_tests/splitdns/gold/test_case_0_stderr.gold
new file mode 100644
index 0000000..9e86235
--- /dev/null
+++ b/tests/gold_tests/splitdns/gold/test_case_0_stderr.gold
@@ -0,0 +1,10 @@
+``
+> GET /foo/ HTTP/1.1
+> Host: localhost:``
+> User-Agent: curl/``
+``
+< HTTP/1.1 200 OK
+< Server: ATS/``
+< Date: ``
+< Age: ``
+``
diff --git a/tests/gold_tests/splitdns/gold/test_case_1_stderr.gold b/tests/gold_tests/splitdns/gold/test_case_1_stderr.gold
new file mode 100644
index 0000000..34c0e15
--- /dev/null
+++ b/tests/gold_tests/splitdns/gold/test_case_1_stderr.gold
@@ -0,0 +1,10 @@
+``
+> GET /bar/ HTTP/1.1
+> Host: localhost:``
+> User-Agent: curl/``
+``
+< HTTP/1.1 200 OK
+< Server: ATS/``
+< Date: ``
+< Age: ``
+``
diff --git a/tests/gold_tests/splitdns/splitdns.test.py b/tests/gold_tests/splitdns/splitdns.test.py
new file mode 100644
index 0000000..23e277c
--- /dev/null
+++ b/tests/gold_tests/splitdns/splitdns.test.py
@@ -0,0 +1,79 @@
+'''
+'''
+#  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 Split DNS'
+
+
+class SplitDNSTest:
+    def __init__(self):
+        self.setupDNSServer()
+        self.setupOriginServer()
+        self.setupTS()
+
+    def setupDNSServer(self):
+        self.dns = Test.MakeDNServer("dns")
+        self.dns.addRecords(records={'foo.ts.a.o.': ['127.0.0.1']})
+
+    def setupOriginServer(self):
+        self.origin_server = Test.MakeOriginServer("origin_server")
+        self.origin_server.addResponse("sessionlog.json",
+                                       {"headers": "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"},
+                                       {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n"})
+
+    def setupTS(self):
+        self.ts = Test.MakeATSProcess(
+            "ts", select_ports=True, enable_cache=False)
+        self.ts.Disk.records_config.update({
+            "proxy.config.dns.splitDNS.enabled": 1,
+            "proxy.config.diags.debug.enabled": 1,
+            "proxy.config.diags.debug.tags": "dns|splitdns",
+        })
+        self.ts.Disk.splitdns_config.AddLine(
+            f"dest_domain=foo.ts.a.o named=127.0.0.1:{self.dns.Variables.Port}")
+        self.ts.Disk.remap_config.AddLine(
+            f"map /foo/ http://foo.ts.a.o:{self.origin_server.Variables.Port}/")
+        self.ts.Disk.remap_config.AddLine(
+            f"map /bar/ http://127.0.0.1:{self.origin_server.Variables.Port}/")
+
+    def addTestCase0(self):
+        tr = Test.AddTestRun()
+        tr.Processes.Default.Command = f"curl -v http://localhost:{self.ts.Variables.port}/foo/"
+        tr.Processes.Default.ReturnCode = 0
+        tr.Processes.Default.Streams.stderr = "gold/test_case_0_stderr.gold"
+        tr.Processes.Default.StartBefore(self.dns)
+        tr.Processes.Default.StartBefore(self.origin_server)
+        tr.Processes.Default.StartBefore(self.ts)
+        tr.StillRunningAfter = self.dns
+        tr.StillRunningAfter = self.origin_server
+        tr.StillRunningAfter = self.ts
+
+    def addTestCase1(self):
+        tr = Test.AddTestRun()
+        tr.Processes.Default.Command = f"curl -v http://localhost:{self.ts.Variables.port}/bar/"
+        tr.Processes.Default.ReturnCode = 0
+        tr.Processes.Default.Streams.stderr = "gold/test_case_1_stderr.gold"
+        tr.StillRunningAfter = self.dns
+        tr.StillRunningAfter = self.origin_server
+        tr.StillRunningAfter = self.ts
+
+    def run(self):
+        self.addTestCase0()
+        self.addTestCase1()
+
+
+SplitDNSTest().run()