1''' 2Test PUSHing an object into the cache and the GETting it with a few variations on the client connection protocol. 3''' 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, software 15# distributed under the License is distributed on an "AS IS" BASIS, 16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17# See the License for the specific language governing permissions and 18# limitations under the License. 19 20Test.Summary = ''' 21Test PUSHing an object into the cache and the GETting it with a few variations on the client connection protocol. 22''' 23 24# NOTE: You can also use this to test client-side communication when GETting very large (multi-GB) objects 25# by increasing the value of the obj_kilobytes variable below. (But do not increase it on any shared branch 26# that we do CI runs on.) 27 28Test.SkipUnless( 29 Condition.HasCurlFeature('http2') 30) 31 32ts = Test.MakeATSProcess("ts", enable_tls=True) 33 34ts.addDefaultSSLFiles() 35 36ts.Disk.records_config.update({ 37 'proxy.config.diags.debug.enabled': 1, 38 'proxy.config.diags.debug.tags': 'http|dns|cache', 39 'proxy.config.http.cache.required_headers': 0, # No required headers for caching 40 'proxy.config.http.push_method_enabled': 1, 41 'proxy.config.proxy_name': 'Poxy_Proxy', # This will be the server name. 42 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 43 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 44 'proxy.config.url_remap.remap_required': 0 45}) 46 47ts.Disk.ssl_multicert_config.AddLine( 48 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' 49) 50 51ts.Disk.remap_config.AddLine( 52 'map https://localhost http://localhost' 53) 54 55# Set up to check the output after the tests have run. 56# 57log_id = Test.Disk.File("log2.txt") 58log_id.Content = "log2.gold" 59 60# Size of object to get. (NOTE: If you increase this significantly you may also have to increase cache 61# capacity in tests/gold_tests/autest-size/min_cfg/storage.config. Also, for very large objects, if 62# proxy.config.diags.debug.enabled is 1, the PUSH request will timeout and fail.) 63# 64obj_kilobytes = 10 * 1024 65 66tr = Test.AddTestRun() 67tr.Processes.Default.Command = 'cc ' + Test.TestDirectory + '/push_request.c -o push_request' 68tr.Processes.Default.ReturnCode = 0 69 70tr = Test.AddTestRun() 71tr.Processes.Default.Command = 'cc ' + Test.TestDirectory + '/check_ramp.c -o check_ramp' 72tr.Processes.Default.ReturnCode = 0 73 74tr = Test.AddTestRun() 75# Delay on readiness of TS IPv4 ssl port 76tr.Processes.Default.StartBefore(Test.Processes.ts) 77# 78# Put object with URL http://localhost/bigobj in cache using PUSH request. 79tr.Processes.Default.Command = ( 80 './push_request {} | nc localhost {}'.format(obj_kilobytes, ts.Variables.port) 81) 82tr.Processes.Default.ReturnCode = 0 83 84# GET bigobj -- cleartext, HTTP 1.1, IPv4 85# 86tr = Test.AddTestRun() 87tr.Processes.Default.Command = ( 88 'curl --verbose --ipv4 --http1.1 --header "Host: localhost"' + 89 ' http://localhost:{}/bigobj 2>> log.txt | ./check_ramp {}' 90 .format(ts.Variables.port, obj_kilobytes) 91) 92tr.Processes.Default.ReturnCode = 0 93 94# GET bigobj -- TLS, HTTP 1.1, IPv4 95# 96tr = Test.AddTestRun() 97tr.Processes.Default.Command = ( 98 'curl --verbose --ipv4 --http1.1 --insecure --header "Host: localhost"' + 99 ' https://localhost:{}/bigobj 2>> log.txt | ./check_ramp {}' 100 .format(ts.Variables.ssl_port, obj_kilobytes) 101) 102tr.Processes.Default.ReturnCode = 0 103 104# GET bigobj -- TLS, HTTP 2, IPv4 105# 106tr = Test.AddTestRun() 107tr.Processes.Default.Command = ( 108 'curl --verbose --ipv4 --http2 --insecure --header "Host: localhost"' + 109 ' https://localhost:{}/bigobj 2>> log.txt | ./check_ramp {}' 110 .format(ts.Variables.ssl_port, obj_kilobytes) 111) 112tr.Processes.Default.ReturnCode = 0 113 114# GET bigobj -- TLS, HTTP 2, IPv6 115# 116tr = Test.AddTestRun() 117tr.Processes.Default.Command = ( 118 'curl --verbose --ipv6 --http2 --insecure --header "Host: localhost"' + 119 ' https://localhost:{}/bigobj 2>> log.txt | ./check_ramp {}' 120 .format(ts.Variables.ssl_portv6, obj_kilobytes) 121) 122tr.Processes.Default.ReturnCode = 0 123 124tr = Test.AddTestRun() 125tr.Processes.Default.Command = "sed 's/0</0\\\n</' log.txt | grep -F 200 | grep -F HTTP > log2.txt" 126tr.Processes.Default.ReturnCode = 0 127