tests: improve mqtt server handling
Check that the mqtt server process actually is running. Handle its port number similar to other servers. Closes #15059
This commit is contained in:
parent
e61c5eb417
commit
841fbdb63c
@ -908,6 +908,20 @@ sub verifyhttptls {
|
||||
return $pid;
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# STUB for verifying mqtt
|
||||
#
|
||||
sub verifymqtt {
|
||||
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
|
||||
my $pidfile = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
my $pid = processexists($pidfile);
|
||||
if($pid < 0) {
|
||||
logmsg "RUN: MQTT server has died after starting up\n";
|
||||
}
|
||||
return $pid;
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# STUB for verifying socks
|
||||
#
|
||||
@ -1064,6 +1078,7 @@ my %protofunc = ('http' => \&verifyhttp,
|
||||
'ftps' => \&verifyftp,
|
||||
'pop3s' => \&verifyftp,
|
||||
'imaps' => \&verifyftp,
|
||||
'mqtt' => \&verifymqtt,
|
||||
'smtps' => \&verifyftp,
|
||||
'tftp' => \&verifyftp,
|
||||
'ssh' => \&verifyssh,
|
||||
@ -1952,13 +1967,12 @@ sub runmqttserver {
|
||||
}
|
||||
|
||||
my $mqttport = pidfromfile($portfile);
|
||||
$PORT{"mqtt"} = $mqttport;
|
||||
|
||||
if($verb) {
|
||||
logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $mqttport\n";
|
||||
}
|
||||
|
||||
return (0, $pid2, $sockspid);
|
||||
return (0, $pid2, $sockspid, $mqttport);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
@ -2240,6 +2254,19 @@ sub responsive_http_server {
|
||||
return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port_or_path, $do_http3);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Single shot mqtt server responsiveness test. This should only
|
||||
# be used to verify that a server present in %run hash is still functional
|
||||
#
|
||||
sub responsive_mqtt_server {
|
||||
my ($proto, $id, $verb, $ipv6) = @_;
|
||||
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
|
||||
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
|
||||
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
|
||||
|
||||
return &responsiveserver($proto, $ipvnum, $idnum, $ip);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Single shot pingpong server responsiveness test. This should only be
|
||||
# used to verify that a server present in %run hash is still functional
|
||||
@ -2876,8 +2903,14 @@ sub startservers {
|
||||
}
|
||||
}
|
||||
elsif($what eq "mqtt" ) {
|
||||
if($run{'mqtt'} &&
|
||||
!responsive_mqtt_server("mqtt", "", $verbose)) {
|
||||
if(stopserver('mqtt')) {
|
||||
return ("failed stopping unresponsive MQTT server", 3);
|
||||
}
|
||||
}
|
||||
if(!$run{'mqtt'}) {
|
||||
($serr, $pid, $pid2) = runmqttserver("", $verbose);
|
||||
($serr, $pid, $pid2, $PORT{"mqtt"}) = runmqttserver("", $verbose);
|
||||
if($pid <= 0) {
|
||||
return ("failed starting mqtt server", $serr);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user