move update_db_config to util

This commit is contained in:
2026-04-19 13:05:32 +02:00
parent 10bffc0fbc
commit 31d2b422cb
2 changed files with 43 additions and 43 deletions

View File

@ -32,43 +32,6 @@ my $fail_server = "$fail_bin/generic-experiment-server";
my $fail_inject = "$fail_bin/generic-experiment-client";
my $result_browser = "$fail_bin/resultbrowser.py";
sub update_db_config {
my ($experiment) = @_;
open( my $readhandle, '<', $remote_db_conf )
or die "failed to open db.conf: $!";
my @lines;
my $found = 0;
while ( my $line = <$readhandle> ) {
if ( rindex( $line, 'database=', 0 ) == 0 ) {
$line = "database=${db_prefix}_$experiment\n";
$found = 1;
}
push @lines, $line;
}
close($readhandle) or die "failed to close db.conf: $!";
die "no database= line found in $remote_db_conf for some reason"
unless $found;
open( my $writehandle, '>', $remote_db_conf )
or die "failed to open db.conf: $!";
print $writehandle @lines or die "failed to write db.conf: $!";
close($writehandle) or die "failed to close db.conf: $!";
say "Updated db.conf for database $db_prefix\_$experiment";
}
sub cpu_count {
open( my $handle, '/proc/cpuinfo' ) or die "Can't open cpuinfo: $!\n";
my $count = scalar( map /^processor/, <$handle> );
close $handle;
return $count;
}
my @experiments = Util::find_subdirs($remote_builds_dir);
sub trace {
my ($experiment) = @_;
@ -194,8 +157,7 @@ sub import_trace {
sub inject {
my ($experiment) = @_;
# my $count = 1;
my $count = cpu_count();
my $count = Util::cpu_count();
Util::notify("Injecting $experiment using $count cores...");
@ -276,11 +238,13 @@ sub results {
}
# Run experiments
my @experiments = Util::find_subdirs($remote_builds_dir);
for my $experiment (@experiments) {
update_db_config($experiment);
Util::rewrite_file( $remote_db_conf, "database=",
"database=${db_prefix}_$experiment\n" );
# trace($experiment);
# import_trace($experiment);
# inject($experiment);
trace($experiment);
import_trace($experiment);
inject($experiment);
results($experiment);
}