Skip to contentSkip to conversation

cr-publish-flight-logs: Make a proper option parser

PATCH New Ian Jackson 1 participant 6 messages Aug 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 cr-publish-flight-logs: Make a proper option parser

I was going to add another option but changed my mind. But, let's keep this patch anyway.

---
 cr-publish-flight-logs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
cr-publish-flight-logs +8 -3
index faae7e0e..717cb957 100755
@@ -28,9 +28,14 @@ our %c;
 readglobalconfig();
 
 my $push_harness = 0;
-if (@ARGV && $ARGV[0] =~ m{^--push-harness(?:-try)?$}) {
-    $push_harness = $&;
-    shift @ARGV;
+while (@ARGV && $ARGV[0] =~ m{^-}) {
+    $_ = shift @ARGV;
+    last if $_ eq '--';
+    if (m{^--push-harness(?:-try)?$}) {
+	$push_harness = $&;
+    } else {
+	die "unknown option \`$_' ?";
+    }
 }
 
 my $flight= shift @ARGV // '';
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/6 timing traces: cr-publish-flight-logs: Report more progress

More tools to see where it is faffing too much.

---
 cr-publish-flight-logs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
cr-publish-flight-logs +6 -1
index 717cb957..ba5d3b70 100755
@@ -43,6 +43,9 @@ die unless $flight =~ m/^\d*$/;
 
 die "usage: ./cr-publish-flight-logs [flight]" unless @ARGV==0;
 
+sub progress { print (show_abs_time time), @_, "\n" }
+
+progress("acquiring publish-lock...");
 open LOCK, "> $c{GlobalLockDir}/publish-lock" or die $!;
 flock LOCK, LOCK_EX or die $!;
 
@@ -51,6 +54,7 @@ if ($push_harness) {
     my $gitdir= $c{HarnessPublishGitRepoDir};
 
     if ($githost && $gitdir) {
+	progress("pushing...");
         eval {
     system_checked("git push $githost:$gitdir HEAD:refs/heads/flight-$flight");
     system_checked("ssh $githost 'cd $gitdir && git update-server-info'");
@@ -72,9 +76,10 @@ sub copydir ($$) {
     push @cmd, '-e', join(' ', map { s/\'/''/g; "'$_'"; } @ssh);
     #--bwlimit=50
     push @cmd, $src, $dst;
-    print "+ @cmd\n";
+    progress "+ @cmd";
     $!=0; $?=0; system @cmd; die "rsync $? $!" if $? or $!;
 }
 
 copydir(qw(Logs), "/$flight") if $flight;
 copydir(qw(Results), '');
+progress "complete.";
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/6 timing traces: cr-daily-branch: Add more calls to date >&2

In reply to Ian Jackson

More tools to see where it is faffing too much.

---
 cr-daily-branch | 12 ++++++++++++
 1 file changed, 12 insertions(+)
cr-daily-branch +12 -0
index d84dcc8e..b8f221ee 100755
@@ -51,6 +51,7 @@ determine_version () {
                 if [ "x$FORCE_REVISION" != x ]; then
                         tversion="$FORCE_REVISION"
                 else
+			date >&2
 			tversion=`$AP_FETCH_PFX ./ap-fetch-version "$tbranch"`
                 fi
 		determine_tree "$treevarwhich" "" _${treevarwhich}
@@ -98,6 +99,7 @@ if [ "x$OLD_REVISION" = x ]; then
 		# last test will have tested the previous upstream baseline
 		OLD_REVISION=`check_tested --print-revision=$tree`
 	    else
+		date >&2
 		OLD_REVISION="`$AP_FETCH_PFX ./ap-fetch-version-old $branch`"
 	    fi
 	    ;;
@@ -159,6 +161,7 @@ if [ "x$REVISION_XEN" = x ]; then
         export REVISION_XEN
 fi
 if [ "x$REVISION_PREVXEN" = x -a "x$prevxenbranch" != "x" ]; then
+	date >&2
 	REVISION_PREVXEN="`\
 		$AP_FETCH_PFX ./ap-fetch-version-baseline $prevxenbranch`"
 	export REVISION_PREVXEN
@@ -321,6 +324,7 @@ unset IFS
 
 if [ "x$OLD_REVISION" = xdetermine-late ]; then
 	OLD_REVISION="`\
+ date >&2
  $AP_FETCH_PFX ./ap-fetch-version-baseline-late $branch $NEW_REVISION`"
 fi
 
@@ -430,6 +434,7 @@ case "$NEW_REVISION/$OLD_REVISION" in
 
                 case "$realtree" in
                 xen-4*|xen-unstable*)
+		    date >&2
                     oldqemu=`./ap-qemu-revision $realtree $OLD_REVISION`
                     newqemu=`./ap-qemu-revision $realtree $NEW_REVISION`
                     if [ "$oldqemu" ] && [ "$newqemu" ]; then
@@ -445,6 +450,7 @@ case "$NEW_REVISION/$OLD_REVISION" in
                 cat <<END >tmp/$flight.people-touched
 People who touched revisions under test:
 END
+		date >&2
                 ./adhoc-people-touched-filter <$revlog \
                         >>tmp/$flight.people-touched
 		touched_lines=`wc -l <tmp/$flight.people-touched`
@@ -464,9 +470,12 @@ esac
 
 sgr_args+=" $EXTRA_SGR_ARGS"
 
+date >&2
 : $flight $branch $OSSTEST_BLESSING $sgr_args
 $DAILY_BRANCH_PREEXEC_HOOK
 execute_flight $flight $OSSTEST_BLESSING
+date >&2
+
 start_email $flight $branch "$sgr_args" "$subject_prefix"
 
 push=false
@@ -502,6 +511,7 @@ elif $push; then
 		echo >&2 "BAD PUSH REVISION $to_push"
 		;;
 	[0-9a-f]*)
+		date >&2
 	        if ./ap-push $branch $to_push 2>&1; then
 			rm -f $branch.push $branch.force-rev
 			perl -i~ -pe '
@@ -527,6 +537,7 @@ freebsd-*)
     if grep '^tolerable$' $mrof >/dev/null 2>&1 && $OSSTEST_ANOINT &&
        [ "x$OSSTEST_BLESSING" == "xreal" ]; then
         IFS=$'\n'
+	date >&2
         for anointed in `./mg-anoint list-prepared \
                                      "freebsd build $freebsd_branch *"`; do
             # Update anointed versions
@@ -554,4 +565,5 @@ if [ -f $revlog ]; then
     fi
 fi
 
+date >&2
 publish_send_email $flight
Signature · 1 line
2.20.1
#3 lore raw

PATCH 4/6 timing traces: sg-check-tested: Add prints of (show_abs_time time)

In reply to Ian Jackson

More tools to see where it is faffing too much.

---
 sg-check-tested | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sg-check-tested +4 -4
index 7946e4b5..39c0d0c2 100755
@@ -148,7 +148,7 @@ sub prepare_execute ($@) {
     my ($qtxt, @vars) = @_;
     print DEBUG "\n==========\n", $qtxt,
                 "\n----------\n", (join ' | ', @vars),
-                "\n==========\n";
+                "\n========== ".(show_abs_time time)."\n";
     my $q= $dbh_tests->prepare($qtxt);
     $q->execute(@vars);
     return $q;
@@ -169,7 +169,7 @@ sub search () {
     while (my $row= $q->fetchrow_hashref()) {
 	my $flight= $row->{flight};
 	if (!defined $prrev) {
-	    print DEBUG "==========YES\n";
+	    print DEBUG "========== ".(show_abs_time time)." YES\n";
 	    output $flight,"\n";
 	    return;
 	} else {
@@ -195,7 +195,7 @@ END
 	    my $row1= $valsq->fetchrow_hashref();
 	    next unless defined $row1->{val} && length $row1->{val};
 	    my $val1 = massage($row1->{val});
-	    print DEBUG "got $val1\n";
+	    print DEBUG (show_abs_time time)." got $val1\n";
 	    while (my $row2 = $valsq->fetchrow_hashref()) {
 		my $val2 = massage($row2->{val});
 		next if $val2 eq $val1;
@@ -212,7 +212,7 @@ END
 	    return;
 	}
     }
-    print DEBUG "==========NO\n";
+    print DEBUG "========== ".(show_abs_time time)." NO\n";
 }
 
 db_retry($dbh_tests, [], sub {
Signature · 1 line
2.20.1
#4 lore raw

PATCH 5/6 timing traces: Executive: Provide processing timestamp facilities

In reply to Ian Jackson

Nothing uses these yet.

---
 Osstest/Executive.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Osstest/Executive.pm +13 -0
index c46a979d..1e94b282 100644
@@ -51,6 +51,7 @@ BEGIN {
                       report_run_getinfo report_altcolour
                       report_altchangecolour opendb_tests
                       report_blessingscond report_find_push_age_info
+		      log_stderr_timestamped
                       tcpconnect_queuedaemon plan_search
                       manual_allocation_base_jobinfo
                       alloc_resources alloc_resources_rollback_begin_work
@@ -293,11 +294,23 @@ sub restrictflight_arg ($) {
         $restrictflight_cond .= " AND flights.flight != $_"
 	    foreach split /,/, $1;
 	return 1;
+    } elsif ($arg =~ m/^--report-processing-start-time$/) {
+	# This functionality is wanted by all the callers of
+	# restrictflight_arg and is here for convenience, rather than
+	# out of principle.
+	log_stderr_timestamped("starting...");
+	return 1;
     } else {
 	return 0;
     }
 }
 
+sub log_stderr_timestamped ($) {
+    my $us = $0;
+    $us =~ s{.*/}{};
+    print STDERR (show_abs_time time)." $us: @_\n";
+}
+
 sub restrictflight_cond () {
     return "($restrictflight_cond)";
 }
Signature · 1 line
2.20.1
#5 lore raw

PATCH 6/6 timing traces: cri-args-hostlists: Add some timestamps

In reply to Ian Jackson

Pass --report-processing-start-time, and add some calls to date >&2.

---
 cri-args-hostlists | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
cri-args-hostlists +8 -3
index 61572c2d..994e00c0 100644
@@ -77,11 +77,13 @@ execute_flight () {
         rm -f abort
         check_stop_core ''
 
+	date >&2
         ./cr-ensure-disk-space Logs
         ./cr-ensure-disk-space LogsPublish
 
 	export OSSTEST_RESOURCE_PREINFO="[$branch $2]"
 
+	date >&2
 	set +e
         ./sg-execute-flight $1 $2 >tmp/$1.transcript 2>&1
 	local rc=$?
@@ -120,11 +122,13 @@ start_email () {
 	date >&2
 
 	with-lock-ex -w $globallockdir/report-lock \
-	  ./sg-report-job-history --html-dir=$job_html_dir --flight=$flight
+	  ./sg-report-job-history --report-processing-start-time \
+	    --html-dir=$job_html_dir --flight=$flight
 
 	date >&2
 
-	./sg-report-flight --html-dir=$flight_html_dir/$flight/ \
+	./sg-report-flight --report-processing-start-time \
+	        --html-dir=$flight_html_dir/$flight/ \
 		--allow=allow.all --allow=allow.$branch \
 		$sgr_args $flight >tmp/$flight.report
 	./cr-fold-long-lines tmp/$flight.report
@@ -133,7 +137,8 @@ start_email () {
 
 	mkdir -p $host_html_dir
 	with-lock-ex -w $globallockdir/report-lock \
-	  ./sg-report-host-history --html-dir=$host_html_dir flight:$flight
+	  ./sg-report-host-history --report-processing-start-time \
+	        --html-dir=$host_html_dir flight:$flight
 
 	date >&2
 }
Signature · 1 line
2.20.1