From f5d3e69d48620e1518bfd82c3975f5aa83fe1578 Mon Sep 17 00:00:00 2001 From: Karl Rister Date: Tue, 12 Mar 2024 09:12:38 -0500 Subject: [PATCH 1/2] reorganize some code that runs initially so it isn't buried among the subroutines --- rickshaw-run | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/rickshaw-run b/rickshaw-run index d924e968..b735df41 100755 --- a/rickshaw-run +++ b/rickshaw-run @@ -1223,18 +1223,6 @@ sub process_bench_roadblocks { } } -# Apply envinronment variables -foreach my $e (qw(RS_NAME RS_EMAIL RS_TAGS RS_DESC RS_REG_AUTH RS_REG_REPO RS_REG_TLS_VERIFY)) { - if (exists $ENV{$e}) { - my $var = $e; - $var =~ s/^RS_//; - $var =~ tr/[A-Z]/[a-z]/; - $var =~ s/_/\-/g; - debug_log(sprintf("Found envornment variable: %s, assigning \"%s\" to %s\n", $e, $ENV{$e}, $var)); - $run{$var} = $ENV{$e}; - } -} - sub process_cmdline() { while (scalar @ARGV > 0) { my $p = shift @ARGV; @@ -2603,6 +2591,20 @@ sub remove_followers { return 0; } +################################################################################ + +# Apply envinronment variables +foreach my $e (qw(RS_NAME RS_EMAIL RS_TAGS RS_DESC RS_REG_AUTH RS_REG_REPO RS_REG_TLS_VERIFY)) { + if (exists $ENV{$e}) { + my $var = $e; + $var =~ s/^RS_//; + $var =~ tr/[A-Z]/[a-z]/; + $var =~ s/_/\-/g; + debug_log(sprintf("Found envornment variable: %s, assigning \"%s\" to %s\n", $e, $ENV{$e}, $var)); + $run{$var} = $ENV{$e}; + } +} + process_cmdline(); load_bench_params(); validate_controller_env(); From 124a1db0eb6fb3652a6814daaee1bb35e5277d73 Mon Sep 17 00:00:00 2001 From: Karl Rister Date: Tue, 12 Mar 2024 09:13:41 -0500 Subject: [PATCH 2/2] all rickshaw-run to process one-json "natively" - this is the first step to having rickshaw-run use the one-json without help - this is moving a lot of functionality from crucible's bin/_main to rickshaw-run --- rickshaw-run | 143 +++++++++++++++++++++++++++++++++++++++++++++++- schema/run.json | 8 ++- 2 files changed, 148 insertions(+), 3 deletions(-) diff --git a/rickshaw-run b/rickshaw-run index b735df41..c169dd34 100755 --- a/rickshaw-run +++ b/rickshaw-run @@ -48,7 +48,8 @@ $toolbox::logging::debug = 0; my $ug = Data::UUID->new; my %defaults = ( "num-samples" => 1, "tool-group" => "default", "test-order" => "s", "base-run-dir" => tempdir(), "id" => $ug->create_str(), - "max-sample-failures" => 1, "max-rb-attempts" => 1); + "max-sample-failures" => 1, "max-rb-attempts" => 1, + "run-file" => ""); my @utilities = ( "packrat" ); @@ -1243,7 +1244,145 @@ sub process_cmdline() { exit 1; } debug_log(sprintf "processing \@ARGV, arg is: [%s], val is: [%s]\n", $arg, $val); - if ($arg eq "endpoint") { + if ($arg eq "from-file") { + $run{'run-file'} = $val; + + ### benchnmarks + # generate a list of the form :[,:] + my $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config benchmarks"; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + (my $cmd, my $cmd_output, my $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR] blockbreaker failed to run with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + chomp($cmd_output); + debug_log(sprintf "appending arg [%s] with value [%s] extracted from from-file to \@ARGV\n", "--bench-ids", $cmd_output); + push @ARGV, "--bench-ids", $cmd_output; + + # extract just the benchmarks from the list + my @benchmarks; + for my $bench_id (split(/,/, $cmd_output)) { + my @array = split(/:/, $bench_id); + push @benchmarks, $array[0]; + } + + ### mv-params + # extract the mv-params and dump them to a file for each benchmark, + # then use multiplex to generate the bench-params + my $bench_params = "";; + foreach my $benchmark (@benchmarks) { + my $benchmark_dir = $ENV{'CRUCIBLE_HOME'} . "/subprojects/benchmarks/" . $benchmark; + + if (! -d $benchmark_dir) { + printf "[ERROR] invalid benchmark %s, benchmark directory %s does not exist\n", $benchmark, $benchmark_dir; + exit 1; + } + + my $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config mv-params --benchmark " . $benchmark; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + (my $cmd, my $cmd_output, my $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR] blockbreaker failed with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + my $bench_mv_params = $run{'base-run-dir'} . "/config/" . $benchmark . "-mv-params.json"; + if (open(BMP, ">", $bench_mv_params)) { + print BMP $cmd_output; + close BMP; + } else { + printf "[ERROR] failed to write %s:\n%s\n", $bench_mv_params, $cmd_output; + exit 1; + } + + my $bench_params_run_file = $run{'base-run-dir'} . "/config/" . $benchmark . "-bench-params.json"; + my $bench_params_run_output = $run{'base-run-dir'} . "/config/" . $benchmark . "-bench-params.txt"; + my $multiplex_cmd = $ENV{'MULTIPLEX_HOME'} . "/multiplex.py --input " . $bench_mv_params . " --output " . $bench_params_run_file; + if (-e $benchmark_dir . "/multiplex.json") { + $multiplex_cmd .= " --requirements " . $benchmark_dir . "/multiplex.json"; + } + debug_log(sprintf "about to run: %s\n", $multiplex_cmd); + ($cmd, $cmd_output, $cmd_rc) = run_cmd($multiplex_cmd); + if (open(MO, ">", $bench_params_run_output)) { + print MO $cmd_output; + close MO; + } else { + print "[ERROR] failed to write %s:\n%s\n", $bench_params_run_output, $cmd_output; + exit 1; + } + if ($cmd_rc != 0) { + printf "[ERROR] multiplex failed with an error and returned rc=%d\n", $cmd_rc; + printf "multiplex output is:\n%s\n", $cmd_output; + exit 1; + } + $bench_params .= ',' . $bench_params_run_file; + } + $bench_params =~ s/^,//; + debug_log(sprintf "appending arg [%s] with value [%s] extracted from from-file to \@ARGV\n", "--bench-params", $bench_params); + push @ARGV, "--bench-params", $bench_params; + + ### tool-params + # dump the output to a file and then create a parameter that references it + $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config tool-params"; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + ($cmd, $cmd_output, $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR] blockbreaker failed to run with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + my $tool_params = $run{'base-run-dir'} . "/config/tool-params.json"; + if (open(TP, ">", $tool_params)) { + print TP $cmd_output; + close TP; + } else { + printf "[ERROR] failed to write %s:\n%s\n", $tool_params, $cmd_output; + exit 1; + } + debug_log(sprintf "appending arg [%s] with value [%s] extracted from from-file to \@ARGV\n", "--tool-params", $tool_params); + push @ARGV, "--tool-params", $tool_params; + + ### tags + $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config tags"; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + ($cmd, $cmd_output, $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR] blockbreaker failed to run with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + chomp($cmd_output); + debug_log(sprintf "appending arg [%s] with value [%s] extracted from from-file to \@ARGV\n", "--tags", $cmd_output); + push @ARGV, "--tags", $cmd_output; + + ### endpoints + $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config endpoints"; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + ($cmd, $cmd_output, $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR] blockbreaker failed to run with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + chomp($cmd_output); + foreach my $endpoint (split(/ /, $cmd_output)) { + debug_log(sprintf "appending arg [%s] with value [%s] extracted from from-file to \@ARGV\n", "--endpoint", $endpoint); + push @ARGV, "--endpoint", $endpoint; + } + + ### run-params + $blockbreaker_cmd = "python3 " . $rickshaw_project_dir . "/util/blockbreaker.py --json " . $run{'run-file'} . " --config run-params"; + debug_log(sprintf "about to run: %s\n", $blockbreaker_cmd); + ($cmd, $cmd_output, $cmd_rc) = run_cmd($blockbreaker_cmd); + if ($cmd_rc != 0) { + printf "[ERROR blockbreaker failed to run with rc=%d for command=[%s]:\n%s\n", $cmd_rc, $cmd, $cmd_output; + exit 1; + } + chomp($cmd_output); + $cmd_output =~ s/^\s+//; + $cmd_output =~ s/\s+$//; + foreach my $arg (split(/ /, $cmd_output)) { + debug_log(sprintf "appending arg [%s] extracted from from-file to \@ARGV\n", $arg); + push @ARGV, $arg; + } + } elsif ($arg eq "endpoint") { $val =~ /^(\w+),(.*)$/; add_endpoint(\@endpoints, $1, $2); } elsif ($arg =~ /^debug$/) { diff --git a/schema/run.json b/schema/run.json index b3f8b0e5..b190cb1d 100644 --- a/schema/run.json +++ b/schema/run.json @@ -9,7 +9,10 @@ "properties": { "version": { "type": "string", - "pattern": "^2020\\.03\\.18$" + "enum": [ + "2020.03.18", + "2024.03.12" + ] } }, "required": [ @@ -232,6 +235,9 @@ "test-order": { "type": "string", "pattern": "^.+$" + }, + "run-file": { + "type": "string" } }, "required": [