1# Licensed to the Apache Software Foundation (ASF) under one 2# or more contributor license agreements. See the NOTICE file 3# distributed with this work for additional information 4# regarding copyright ownership. The ASF licenses this file 5# to you under the Apache License, Version 2.0 (the 6# "License"); you may not use this file except in compliance 7# with the License. You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import os 18Test.Summary = ''' 19Test traffic_ctl config reload with remap.config .include directive 20''' 21 22Test.ContinueOnFail = False 23 24Test.Setup.Copy("wait_reload.sh") 25 26# Define ATS and configure 27ts = Test.MakeATSProcess("ts", command="traffic_manager", enable_cache=False) 28 29ts.Disk.File(ts.Variables.CONFIGDIR + "/test.inc", id="test_cfg", typename="ats:config") 30ts.Disk.test_cfg.AddLine( 31 "map http://example.two/ http://yada.com/ " + 32 "@plugin=conf_remap.so @pparam=proxy.config.url_remap.pristine_host_hdr=1" 33) 34 35ts.Disk.remap_config.AddLine( 36 "map http://example.one/ http://yada.com/" 37) 38ts.Disk.remap_config.AddLine( 39 ".include test.inc" 40) 41ts.Disk.remap_config.AddLine( 42 "map http://example.three/ http://yada.com/" 43) 44 45# minimal configuration 46ts.Disk.records_config.update({ 47 'proxy.config.diags.debug.enabled': 1, 48 'proxy.config.diags.debug.tags': 'regex_remap|url_rewrite|plugin_factory', 49}) 50 51tr = Test.AddTestRun("Start TS, then update test.inc") 52tr.Processes.Default.StartBefore(Test.Processes.ts) 53test_inc_path = ts.Variables.CONFIGDIR + "/test.inc" 54tr.Processes.Default.Command = ( 55 f"rm -f {test_inc_path} ; " + 56 f"echo 'map http://example.four/ http://localhost/ @plugin=generator.so' > {test_inc_path}" 57) 58tr.Processes.Default.ReturnCode = 0 59tr.StillRunningAfter = ts 60 61tr = Test.AddTestRun("Reload config") 62tr.StillRunningAfter = ts 63tr.Processes.Default.Command = 'traffic_ctl config reload' 64# Need to copy over the environment so traffic_ctl knows where to find the unix domain socket 65tr.Processes.Default.Env = ts.Env 66tr.Processes.Default.ReturnCode = 0 67 68tr = Test.AddTestRun("Wait for config reload") 69tr.Processes.Default.Command = './wait_reload.sh ' + os.path.join(ts.Variables.LOGDIR, 'diags.log') 70tr.Processes.Default.ReturnCode = 0 71tr.StillRunningAfter = ts 72 73tr = Test.AddTestRun("Get response from generator") 74tr.Processes.Default.Command = ( 75 f'test $$(curl --proxy 127.0.0.1:{ts.Variables.port} http://example.four/nocache/5 | wc -c) == 5' 76) 77tr.Processes.Default.ReturnCode = 0 78tr.StillRunningAfter = ts 79 80ts.Disk.manager_log.Content += Testers.ExcludesExpression( 81 "needs restart", 82 "Ensure that extra msg reported in issue #7530 does not reappear") 83