Skip to content

Commit

Permalink
[dist] check each service in obs-api-support.target separate
Browse files Browse the repository at this point in the history
is-active on a target returns no error even if all services are failed.
  • Loading branch information
M0ses authored and eduardoj committed Jul 9, 2021
1 parent d46ddfd commit 4d8a14a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions dist/t/0060-check_required_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Test::More;
my $tests = 14;
my $max_wait = 300;

my @daemons = qw/obsdispatcher.service obspublisher.service obsrepserver.service
my @active_daemons = qw/obsdispatcher.service obspublisher.service obsrepserver.service
obsscheduler.service obssrcserver.service/;

my $out=`systemctl list-units`;
Expand All @@ -18,27 +18,29 @@ foreach my $unit (split(/\n/, $out)) {

die "could not find mariadb or mysql" if ! $mariadb;

push @daemons, $mariadb;
push @active_daemons, $mariadb;

my $os = get_distribution();
if ($os eq "suse") {
push @daemons, "apache2.service";
push @active_daemons, "apache2.service";
} elsif ($os eq 'rh') {
push @daemons, "httpd.service";
push @active_daemons, "httpd.service";
} else {
die "Could not determine distribution!\n";
}

my $version = `rpm -q --queryformat %{Version} obs-server`;

my @enabled_daemons = @active_daemons;

if ($version !~ /^2\.[89]\./) {
unshift @daemons, "obs-api-support.target";
$tests = 16;
push @active_daemons, 'obs-clockwork.service', 'obs-delayedjob-queue-consistency_check.service', 'obs-delayedjob-queue-default.service', 'obs-delayedjob-queue-issuetracking.service', 'obs-delayedjob-queue-mailers.service', 'obs-delayedjob-queue-project_log_rotate.service', 'obs-delayedjob-queue-quick@0.service', 'obs-delayedjob-queue-quick@1.service', 'obs-delayedjob-queue-quick@2.service', 'obs-delayedjob-queue-releasetracking.service', 'obs-delayedjob-queue-staging.service', 'obs-delayedjob-queue-scm.service', 'obs-sphinx.service';
$tests = $tests + 13;
}

plan tests => $tests;

foreach my $srv (@daemons) {
foreach my $srv (@enabled_daemons) {
my @state=`systemctl is-enabled $srv 2>/dev/null`;
my $result='';
if (@state) {
Expand All @@ -52,7 +54,7 @@ my %srv_state=();
while ($max_wait > 0) {
my $failed=0;
foreach my $srv (@daemons) {
foreach my $srv (@active_daemons) {
my @state=`systemctl is-active $srv 2>/dev/null`;
chomp($state[0]);
print "$srv $state[0]\n";
Expand All @@ -63,13 +65,13 @@ while ($max_wait > 0) {
$srv_state{$srv} = $state[0];
}
}
last if (keys(%srv_state) == scalar(@daemons));
last if (keys(%srv_state) == scalar(@active_daemons));
last if ($failed);
$max_wait--;
sleep 1;
}
foreach my $srv ( @daemons ) {
foreach my $srv ( @active_daemons ) {
is($srv_state{$srv} || 'timeout','active',"Checking recommended systemd unit '$srv' status");
}
Expand Down

0 comments on commit 4d8a14a

Please sign in to comment.