Browse Source

MT#55283 refactor autotest_init

Don't depend on ->socket being set. Instead run the actual ping check
and use that as condition to see whether the daemon is ready or not.

Change-Id: I6d39ca6cb9b3a61a94194fe827768dff28ca0508
pull/1938/head
Richard Fuchs 7 months ago
parent
commit
9d82d0876a
1 changed files with 19 additions and 16 deletions
  1. +19
    -16
      perl/NGCP/Rtpengine/AutoTest.pm

+ 19
- 16
perl/NGCP/Rtpengine/AutoTest.pm View File

@ -59,6 +59,10 @@ sub autotest_start {
ok $rtpe_pid, 'daemon launched in background';
}
if ($launch_cb) {
$launch_cb->();
}
return autotest_init();
}
@ -66,28 +70,27 @@ sub autotest_init {
# keep trying to connect to the control socket while daemon is starting up
for (1 .. 300) {
$c = NGCP::Rtpengine->new($ENV{RTPENGINE_HOST} // '127.0.0.1', $ENV{RTPENGINE_PORT} // 2223);
last if $c->{socket};
Time::HiRes::usleep(100000); # 100 ms x 300 = 30 sec
}
1;
$c->{socket} or die;
$tag_iter = 0;
$tag_suffix = '-' . rand();
$tag_iter = 0;
$tag_suffix = '-' . rand();
my $ok = 0;
eval {
my $r = $c->req({command => 'ping'});
$ok = $r->{result} eq 'pong';
};
if ($launch_cb) {
$launch_cb->();
}
next if not $ok;
my $r = $c->req({command => 'ping'});
ok $r->{result} eq 'pong', 'ping works, daemon operational';
# Setup a global die handler.
## no critic (Variables::RequireLocalizedPunctuationVars)
$SIG{__DIE__} = sub {
terminate(@_);
};
# Setup a global die handler.
## no critic (Variables::RequireLocalizedPunctuationVars)
$SIG{__DIE__} = sub {
terminate(@_);
};
last;
}
return 1;
}


Loading…
Cancel
Save