From 57580e8857f1594fb194c3271eba53f1314fd3ac Mon Sep 17 00:00:00 2001 From: drawing Date: Wed, 6 Nov 2024 15:38:46 +0800 Subject: [PATCH] fix nameserver testcase --- tests/nginx-tests/tengine-tests/dynamic_resolve.t | 7 ++++--- tests/nginx-tests/tengine-tests/vnswrr4dynamic_ups.t | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/nginx-tests/tengine-tests/dynamic_resolve.t b/tests/nginx-tests/tengine-tests/dynamic_resolve.t index 262b3000a1..41057694d0 100644 --- a/tests/nginx-tests/tengine-tests/dynamic_resolve.t +++ b/tests/nginx-tests/tengine-tests/dynamic_resolve.t @@ -16,7 +16,6 @@ BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; use Test::Nginx; -eval { require Net::DNS::Nameserver; }; plan(skip_all => 'Net::DNS::Nameserver not installed') if $@; ############################################################################### @@ -148,7 +147,7 @@ kill $^O eq 'MSWin32' ? 9 : 'TERM', $dns_pid; wait; # wait for dns cache to expire -sleep(2); +sleep(3); unlike(http_get('/stale'), qr/127\.0\.0\.2/, 'stale http server should be www.taobao.com:8081, using initial result'); @@ -251,6 +250,8 @@ sub reply_handler { } sub dns_server_daemon { + eval { require Net::DNS::Nameserver; }; + my $ns = new Net::DNS::Nameserver( LocalAddr => '127.0.0.1', LocalPort => 53530, @@ -258,7 +259,7 @@ sub dns_server_daemon { Verbose => 0 ) or die "couldn't create nameserver object\n"; - $ns->main_loop; + $ns->start_server(1); } ############################################################################### diff --git a/tests/nginx-tests/tengine-tests/vnswrr4dynamic_ups.t b/tests/nginx-tests/tengine-tests/vnswrr4dynamic_ups.t index d0e17b1a06..4769ea5f86 100644 --- a/tests/nginx-tests/tengine-tests/vnswrr4dynamic_ups.t +++ b/tests/nginx-tests/tengine-tests/vnswrr4dynamic_ups.t @@ -15,7 +15,6 @@ BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; use Test::Nginx; -eval { require Net::DNS::Nameserver; }; plan(skip_all => 'Net::DNS::Nameserver not installed') if $@; ############################################################################### @@ -153,7 +152,7 @@ kill $^O eq 'MSWin32' ? 9 : 'TERM', $dns_pid; wait; # wait for dns cache to expire -sleep(2); +sleep(3); unlike(http_get('/stale'), qr/127\.0\.0\.2/, 'stale http server should be www.taobao.com:8081, using initial result'); @@ -248,6 +247,8 @@ sub reply_handler { } sub dns_server_daemon { + eval { require Net::DNS::Nameserver; }; + my $ns = new Net::DNS::Nameserver( LocalAddr => '127.0.0.1', LocalPort => 53530, @@ -255,7 +256,7 @@ sub dns_server_daemon { Verbose => 0 ) or die "couldn't create nameserver object\n"; - $ns->main_loop; + $ns->start_server(1); } ###############################################################################