This is an automated email from the ASF dual-hosted git repository.
shinrich 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 1ce86a82b6 Remove netcat from bigobj test (#10866)
1ce86a82b6 is described below
commit 1ce86a82b63ce33756af68c8da1c3fb6d12fb2c6
Author: Susan Hinrichs <[email protected]>
AuthorDate: Thu Nov 30 10:38:29 2023 -0600
Remove netcat from bigobj test (#10866)
---
tests/CMakeLists.txt | 1 -
tests/gold_tests/bigobj/CMakeLists.txt | 19 ------
tests/gold_tests/bigobj/bigobj.test.py | 112 +++++++++++++++++++--------------
tests/gold_tests/bigobj/check_ramp.c | 57 -----------------
tests/gold_tests/bigobj/log2.gold | 4 --
tests/gold_tests/bigobj/push_request.c | 79 -----------------------
6 files changed, 66 insertions(+), 206 deletions(-)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d58dcd3265..afd94746d3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -27,7 +27,6 @@ function(ADD_AUTEST_PLUGIN _NAME)
endfunction()
add_subdirectory(tools/plugins)
-add_subdirectory(gold_tests/bigobj)
add_subdirectory(gold_tests/chunked_encoding)
add_subdirectory(gold_tests/continuations/plugins)
add_subdirectory(gold_tests/jsonrpc/plugins)
diff --git a/tests/gold_tests/bigobj/CMakeLists.txt
b/tests/gold_tests/bigobj/CMakeLists.txt
deleted file mode 100644
index b56709f853..0000000000
--- a/tests/gold_tests/bigobj/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-#######################
-#
-# 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.
-#
-#######################
-
-add_executable(check_ramp check_ramp.c)
-add_executable(push_request push_request.c)
diff --git a/tests/gold_tests/bigobj/bigobj.test.py
b/tests/gold_tests/bigobj/bigobj.test.py
index b46f417878..30b82541ee 100644
--- a/tests/gold_tests/bigobj/bigobj.test.py
+++ b/tests/gold_tests/bigobj/bigobj.test.py
@@ -28,11 +28,6 @@ Test.SkipUnless(
Condition.HasCurlFeature('http2')
)
-# push_request and check_ramp are built via `make`. Here we copy the built
binary down to the test
-# directory so that the test runs in this file can use it.
-Test.Setup.Copy(os.path.join(Test.Variables.AtsBuildGoldTestsDir, 'bigobj',
'push_request'))
-Test.Setup.Copy(os.path.join(Test.Variables.AtsBuildGoldTestsDir, 'bigobj',
'check_ramp'))
-
ts = Test.MakeATSProcess("ts1", enable_tls=True)
ts.addDefaultSSLFiles()
@@ -52,65 +47,88 @@ ts.Disk.ssl_multicert_config.AddLine(
)
ts.Disk.remap_config.AddLine(
- 'map https://localhost http://localhost'
+ f'map https://localhost:{ts.Variables.ssl_port}
http://localhost:{ts.Variables.port}'
+)
+ts.Disk.remap_config.AddLine(
+ f'map https://localhost:{ts.Variables.ssl_portv6}
http://localhost:{ts.Variables.port}'
)
-
-# Set up to check the output after the tests have run.
-#
-log_id = Test.Disk.File("log2.txt")
-log_id.Content = "log2.gold"
# Size of object to get. (NOTE: If you increase this significantly you may
also have to increase cache
# capacity in tests/gold_tests/autest-size/min_cfg/storage.config. Also, for
very large objects, if
# proxy.config.diags.debug.enabled is 1, the PUSH request will timeout and
fail.)
#
obj_kilobytes = 10 * 1024
+obj_bytes = obj_kilobytes * 10
+header = "HTTP/1.1 200 OK\r\nContent-length: {}\r\n\r\n".format(obj_bytes)
+
+
+def create_pushfile():
+ f = open(Test.RunDirectory + "/objfile", "w")
+ f.write(header)
+ f.write("x" * obj_bytes)
+ f.close()
+ return True
+
tr = Test.AddTestRun("PUSH an object to the cache")
# Delay on readiness of TS IPv4 ssl port
-tr.Processes.Default.StartBefore(ts)
-#
+tr.Processes.Default.StartBefore(ts, ready=lambda: create_pushfile())
# Put object with URL http://localhost/bigobj in cache using PUSH request.
-tr.Processes.Default.Command = (
- f'./push_request {obj_kilobytes} | nc localhost {ts.Variables.port}'
-)
+tr.Processes.Default.Command = "curl -v -H 'Content-Type:
application/octet-stream' --data-binary @{}/objfile -X PUSH
http://localhost:{}/bigobj -H 'Content-Length:{}'".format(
+ Test.RunDirectory, ts.Variables.port, len(header) + obj_bytes)
tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "HTTP/1.1 201 Created",
+ "The PUSH request should have succeeded"
+)
tr = Test.AddTestRun("GET bigobj: cleartext, HTTP/1.1, IPv4")
-tr.Processes.Default.Command = (
- 'curl --verbose --ipv4 --http1.1 --header "Host: localhost"'
- f' http://localhost:{ts.Variables.port}/bigobj 2>> log.txt |'
- f' ./check_ramp {obj_kilobytes}'
-)
+tr.Processes.Default.Command = f'curl --verbose --ipv4 --http1.1
http://localhost:{ts.Variables.port}/bigobj'
tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "HTTP/1.1 200 OK",
+ "Should fetch pushed object"
+)
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "Content-length: 102400",
+ "Content size should be accurate"
+)
tr = Test.AddTestRun("GET bigobj: TLS, HTTP/1.1, IPv4")
-tr.Processes.Default.Command = (
- 'curl --verbose --ipv4 --http1.1 --insecure --header "Host: localhost"'
- f' https://localhost:{ts.Variables.ssl_port}/bigobj 2>> log.txt |'
- f' ./check_ramp {obj_kilobytes}'
-)
+tr.Processes.Default.Command = f'curl --verbose --ipv4 --http1.1 --insecure
https://localhost:{ts.Variables.ssl_port}/bigobj'
tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "HTTP/1.1 200 OK",
+ "Should fetch pushed object"
+)
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "Content-length: 102400",
+ "Content size should be accurate"
+)
tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv4")
-tr.Processes.Default.Command = (
- 'curl --verbose --ipv4 --http2 --insecure --header "Host: localhost"'
- f' https://localhost:{ts.Variables.ssl_port}/bigobj 2>> log.txt |'
- f' ./check_ramp {obj_kilobytes}'
-)
+tr.Processes.Default.Command = f'curl --verbose --ipv4 --http2 --insecure
https://localhost:{ts.Variables.ssl_port}/bigobj'
tr.Processes.Default.ReturnCode = 0
-
-tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv6")
-tr.Processes.Default.Command = (
- 'curl --verbose --ipv6 --http2 --insecure --header "Host: localhost"'
- f' https://localhost:{ts.Variables.ssl_portv6}/bigobj 2>> log.txt |'
- f' ./check_ramp {obj_kilobytes}'
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "HTTP/2 200",
+ "Should fetch pushed object"
+)
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "content-length: 102400",
+ "Content size should be accurate"
)
-tr.Processes.Default.ReturnCode = 0
-tr = Test.AddTestRun()
-tr.Processes.Default.Command = "sed 's/0</0\\\n</' log.txt | grep -F 200 |
grep -F HTTP > log2.txt"
+tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv6")
+tr.Processes.Default.Command = f'curl --verbose --ipv6 --http2 --insecure
https://localhost:{ts.Variables.ssl_portv6}/bigobj'
tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "HTTP/2 200",
+ "Should fetch pushed object"
+)
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
+ "content-length: 102400",
+ "Content size should be accurate"
+)
# Verify that PUSH requests are rejected when push_method_enabled is 0 (the
# default configuration).
@@ -132,16 +150,18 @@ ts.Disk.ssl_multicert_config.AddLine(
)
ts.Disk.remap_config.AddLine(
- 'map https://localhost http://localhost'
+ f'map https://localhost:{ts.Variables.ssl_port}
http://localhost:{ts.Variables.port}'
+)
+ts.Disk.remap_config.AddLine(
+ f'map https://localhost:{ts.Variables.ssl_portv6}
http://localhost:{ts.Variables.port}'
)
tr = Test.AddTestRun("PUSH request is rejected when push_method_enabled is 0")
tr.Processes.Default.StartBefore(ts)
-tr.Processes.Default.Command = (
- f'./push_request {obj_kilobytes} | nc localhost {ts.Variables.port}'
-)
-tr.Processes.Default.ReturnCode = 1
-tr.Processes.Default.Streams.stdout = Testers.ContainsExpression(
+tr.Processes.Default.Command = "curl -v -H 'Content-Type:
application/octet-stream' --data-binary @{}/objfile -X PUSH
http://localhost:{}/bigobj -H 'Content-Length:{}'".format(
+ Test.RunDirectory, ts.Variables.port, len(header) + obj_bytes)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = Testers.ContainsExpression(
"403 Access Denied",
"The PUSH request should have received a 403 response."
)
diff --git a/tests/gold_tests/bigobj/check_ramp.c
b/tests/gold_tests/bigobj/check_ramp.c
deleted file mode 100644
index fbea580692..0000000000
--- a/tests/gold_tests/bigobj/check_ramp.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- 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.
-*/
-
-// Program to read standard input and verify it is ramping pattern.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-int
-main(int n_arg, char const *const *arg)
-{
- int64_t data_count;
- int c = 0;
-
- if ((n_arg != 2) || ((data_count = atoi(arg[1])) < 0)) {
- fprintf(stderr, "usage: check_ramp number-of-kilobytes\n");
- return 1;
- }
-
- data_count *= 1024;
-
- while (data_count--) {
- if (getchar() != c) {
- fprintf(stderr, "error in standard input\n");
- return 1;
- }
- if (c == 255) {
- c = 0;
- } else {
- ++c;
- }
- }
-
- if (getchar() != EOF) {
- fprintf(stderr, "error in standard input (too long)\n");
- return 1;
- }
-
- return 0;
-}
diff --git a/tests/gold_tests/bigobj/log2.gold
b/tests/gold_tests/bigobj/log2.gold
deleted file mode 100644
index c4367a7cfe..0000000000
--- a/tests/gold_tests/bigobj/log2.gold
+++ /dev/null
@@ -1,4 +0,0 @@
-< HTTP/1.1 200 OK
-< HTTP/1.1 200 OK
-< HTTP/2 200
-< HTTP/2 200
diff --git a/tests/gold_tests/bigobj/push_request.c
b/tests/gold_tests/bigobj/push_request.c
deleted file mode 100644
index 98a291e3ec..0000000000
--- a/tests/gold_tests/bigobj/push_request.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- 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.
-*/
-
-// Program to output push request with ramping data.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-int
-main(int n_arg, char const *const *arg)
-{
- int64_t data_count;
- int c = 0, hdr_count;
- ;
- char buf[200];
-
- if ((n_arg != 2) || ((data_count = atoi(arg[1])) < 0)) {
- fprintf(stderr, "usage: push_request number-of-kilobytes\n");
- return 1;
- }
-
- data_count *= 1024;
-
- hdr_count = snprintf(buf, sizeof(buf),
- "HTTP/1.1 200 OK\r\n"
- "Content-Type: text/plain\r\n"
- "Content-Length: %" PRId64 "\r\n"
- "\r\n",
- data_count);
-
- if (hdr_count <= 0) {
- fprintf(stderr, "INTERNAL ERROR\n");
- return 1;
- }
-
- if (printf("PUSH http://localhost/bigobj HTTP/1.1\r\n"
- "Content-Length: %" PRId64 "\r\n"
- "\r\n%s",
- hdr_count + data_count, buf) <= 0) {
- fprintf(stderr, "error writing standard output\n");
- return 1;
- }
-
- while (data_count--) {
- if (putchar(c) != c) {
- fprintf(stderr, "error writing standard output\n");
- return 1;
- }
- if (c == 255) {
- c = 0;
- } else {
- ++c;
- }
- }
-
- if (fflush(stdout) != 0) {
- fprintf(stderr, "error writing standard output\n");
- return 1;
- }
-
- return 0;
-}