dabue commented on a change in pull request #2488: URL: https://github.com/apache/apisix/pull/2488#discussion_r511587958
########## File path: t/plugin/error-log-logger.t ########## @@ -0,0 +1,122 @@ +# +# 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. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_root_location(); + +add_block_preprocessor(sub { + my ($block) = @_; + + my $stream_single_server = <<_EOC_; + # fake server, only for test + server { + listen 33333; + + content_by_lua_block { + local exiting = ngx.worker.exiting + local sock, err = ngx.req.socket(true) + if not sock then + ngx.log(ngx.WARN, "socket error:" .. err) + return + end + sock:settimeout(30 * 1000) + while(not exiting()) + do + local data, err = sock:receive() + if (data) then + ngx.log(ngx.INFO, "[Server] receive data:" .. data) + else + if err ~= "timeout" then + ngx.log(ngx.WARN, "socket error:" .. err) + return + end + end + end + } + } +_EOC_ + + $block->set_value("stream_config", $stream_single_server); +}); + + +add_block_preprocessor(sub { Review comment: In the test case , I need to add a new TCP server to receive the error log data. At the beginnging, I want to use a special port instead of a built-in one, so I aad the first add_block_preprocessor, but there is a built-in server which has no handler , It'll cause error if I don't add_block_preprocessor for it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
