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/10/13 22:58:17 UTC

[trafficserver] branch 9.2.x updated: Add Au test for pqsi and pqsp log fields. (#8372)

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

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 8df0bb8  Add Au test for pqsi and pqsp log fields. (#8372)
8df0bb8 is described below

commit 8df0bb8f5c1d00730b6512c4cf5817c2ab10b814
Author: Walt Karas <wk...@verizonmedia.com>
AuthorDate: Thu Oct 7 16:21:25 2021 -0500

    Add Au test for pqsi and pqsp log fields. (#8372)
    
    (cherry picked from commit a7c0f794813b17329b421da38f869884287cece0)
---
 tests/gold_tests/logging/gold/pqsi-pqsp.gold |  2 +
 tests/gold_tests/logging/pqsi-pqsp.test.py   | 95 ++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/tests/gold_tests/logging/gold/pqsi-pqsp.gold b/tests/gold_tests/logging/gold/pqsi-pqsp.gold
new file mode 100644
index 0000000..8238b1c
--- /dev/null
+++ b/tests/gold_tests/logging/gold/pqsi-pqsp.gold
@@ -0,0 +1,2 @@
+abc
+0 0
diff --git a/tests/gold_tests/logging/pqsi-pqsp.test.py b/tests/gold_tests/logging/pqsi-pqsp.test.py
new file mode 100644
index 0000000..28a2e03
--- /dev/null
+++ b/tests/gold_tests/logging/pqsi-pqsp.test.py
@@ -0,0 +1,95 @@
+'''
+'''
+#  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.
+
+import os
+
+Test.Summary = '''
+Test pqsi and pqsp log fields.
+'''
+
+ts = Test.MakeATSProcess("ts", enable_cache=False)
+server = Test.MakeOriginServer("server")
+
+request_header = {
+    "headers":
+        "GET /test HTTP/1.1\r\n"
+        "Host: whatever\r\n"
+        "\r\n",
+    "body": "",
+    'timestamp': "1469733493.993",
+}
+response_header = {
+    "headers":
+        "HTTP/1.1 200 OK\r\n"
+        "Connection: close\r\n"
+        "\r\n",
+    "body": "body\n",
+    'timestamp': "1469733493.993",
+}
+server.addResponse("sessionlog.json", request_header, response_header)
+
+nameserver = Test.MakeDNServer("dns", default='127.0.0.1')
+
+ts.Disk.records_config.update({
+    'proxy.config.dns.nameservers': f"127.0.0.1:{nameserver.Variables.Port}",
+    'proxy.config.dns.resolv_conf': 'NULL',
+    'proxy.config.http.cache.http': 1,
+    'proxy.config.http.cache.required_headers': 0,
+})
+ts.Disk.remap_config.AddLine(
+    'map / http://localhost:{}/'.format(server.Variables.Port)
+)
+
+ts.Disk.logging_yaml.AddLines(
+    '''
+logging:
+  formats:
+    - name: custom
+      format: '%<pqsi> %<pqsp>'
+  logs:
+    - filename: field-test
+      format: custom
+'''.split("\n")
+)
+
+tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(server)
+tr.Processes.Default.StartBefore(nameserver)
+# Delay on readiness of our ssl ports
+tr.Processes.Default.StartBefore(Test.Processes.ts)
+tr.Processes.Default.Command = f'curl --verbose http://localhost:{ts.Variables.port}/test'
+tr.Processes.Default.ReturnCode = 0
+
+# Response for this duplicate request should come from cache.
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = f'curl --verbose http://localhost:{ts.Variables.port}/test'
+tr.Processes.Default.ReturnCode = 0
+
+log_filespec = os.path.join(ts.Variables.LOGDIR, 'field-test.log')
+
+# Wait for log file to appear, then wait one extra second to make sure TS is done writing it.
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = (
+    os.path.join(Test.Variables.AtsTestToolsDir, 'condwait') + ' 60 1 -f ' + log_filespec
+)
+tr.Processes.Default.ReturnCode = 0
+
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = "sed '1s/^127.0.0.1 [1-6][0-9]*$$/abc/' < " + log_filespec
+tr.Processes.Default.Streams.stdout = "gold/pqsi-pqsp.gold"
+tr.Processes.Default.ReturnCode = 0