Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuTest for Split DNS #7325

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/gold_tests/splitdns/gold/test_case_0_stderr.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
``
> GET /foo/ HTTP/1.1
> Host: localhost:``
> User-Agent: curl/``
``
< HTTP/1.1 200 OK
< Server: ATS/``
< Date: ``
< Age: ``
``
10 changes: 10 additions & 0 deletions tests/gold_tests/splitdns/gold/test_case_1_stderr.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
``
> GET /bar/ HTTP/1.1
> Host: localhost:``
> User-Agent: curl/``
``
< HTTP/1.1 200 OK
< Server: ATS/``
< Date: ``
< Age: ``
``
79 changes: 79 additions & 0 deletions tests/gold_tests/splitdns/splitdns.test.py
Original file line number Diff line number Diff line change
@@ -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()