Skip to content

Commit

Permalink
ci: Ensure tests pass even under high load
Browse files Browse the repository at this point in the history
Workers don't accept jobs if the load is too high.

Issua: https://progress.opensuse.org/issues/165198
  • Loading branch information
perlpunk committed Aug 13, 2024
1 parent bdea10a commit e995891
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions t/05-scheduler-full.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ plan skip_all => "set FULLSTACK=1 (be careful)" unless $ENV{FULLSTACK};
setup_mojo_app_with_default_worker_timeout;
OpenQA::Setup::read_config(OpenQA::App->singleton);

# fake "/proc/loadavg" to ensure the test works under a heavy load
my $load_avg_file = tempfile('worker-overall-load-avg-XXXXX');
my $load_avg_file_realpath = $load_avg_file->realpath;
$load_avg_file->spew('0.93 0.95 3.25 2/2207 1212');
$ENV{OPENQA_LOAD_AVG_FILE} = $load_avg_file_realpath;

# setup directories and database
my $tempdir = setup_fullstack_temp_dir('scheduler');
my $schema = OpenQA::Test::Database->new->create(fixtures_glob => '01-jobs.pl 02-workers.pl');
Expand Down
8 changes: 7 additions & 1 deletion t/43-scheduling-and-worker-scalability.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Test::MockModule;
use Time::HiRes 'sleep';
use File::Path 'make_path';
use Scalar::Util 'looks_like_number';
use Mojo::File 'path';
use Mojo::File qw(path tempfile);
use Mojo::Util 'dumper';
use IPC::Run qw(start);
use FindBin;
Expand Down Expand Up @@ -41,6 +41,12 @@ BEGIN {
setup_mojo_app_with_default_worker_timeout;
OpenQA::Setup::read_config(OpenQA::App->singleton);

# fake "/proc/loadavg" to ensure the test works under a heavy load
my $load_avg_file = tempfile('worker-overall-load-avg-XXXXX');
my $load_avg_file_realpath = $load_avg_file->realpath;
$load_avg_file->spew('0.93 0.95 3.25 2/2207 1212');
$ENV{OPENQA_LOAD_AVG_FILE} = $load_avg_file_realpath;

# read number of workers to spawn from environment variable; skip test entirely if variable not present
# similar to other fullstack tests
my $worker_count = $ENV{SCALABILITY_TEST_WORKER_COUNT};
Expand Down

0 comments on commit e995891

Please sign in to comment.