ronething commented on code in PR #8826: URL: https://github.com/apache/apisix/pull/8826#discussion_r1105228890
########## t/tars/discovery/stream/tars.t: ########## @@ -0,0 +1,216 @@ +# +# 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; + +my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx'; +my $version = eval { `$nginx_binary -V 2>&1` }; + +if ($version =~ m/\/1.19.3/) { + plan(skip_all => "require OpenResty version >= 1.19.9.1"); +} else { + plan('no_plan'); +} + +repeat_each(1); +log_level('warn'); +no_root_location(); +no_shuffle(); +workers(4); + +add_block_preprocessor(sub { + my ($block) = @_; + + my $yaml_config = <<_EOC_; +apisix: + node_listen: 1984 + enable_admin: false +deployment: + role: data_plane + role_data_plane: + config_provider: yaml +discovery: + tars: + db_conf: + host: 127.0.0.1 + port: 3306 + database: db_tars + user: root + password: tars2022 + full_fetch_interval: 3 + incremental_fetch_interval: 1 +_EOC_ + + $block->set_value("yaml_config", $yaml_config); + + my $apisix_yaml = $block->apisix_yaml // <<_EOC_; +routes: [] +#END +_EOC_ + + $block->set_value("apisix_yaml", $apisix_yaml); + + my $extra_init_by_lua_start = <<_EOC_; + -- reduce incremental_fetch_interval,full_fetch_interval + local schema = require("apisix.discovery.tars.schema") + schema.properties.incremental_fetch_interval.minimum=1 + schema.properties.incremental_fetch_interval.default=1 + schema.properties.full_fetch_interval.minimum = 3 + schema.properties.full_fetch_interval.default = 3 +_EOC_ + + $block->set_value("extra_init_by_lua_start", $extra_init_by_lua_start); Review Comment: The discovery configuration will affect both the HTTP and steam subsystem simultaneously. If we do not set `extra_init_by_lua_start ` in HTTP, it will cause error like below. `nginx: [error] init_by_lua error: .../apisix/apisix/core/config_local.lua:71: invalid discovery tars configuration: property "full_fetch_interval" validation failed: expected 3 to be at least 90` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
