From patchwork Thu Jul 7 18:47:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9219437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDA8F60467 for ; Thu, 7 Jul 2016 18:50:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF78128408 for ; Thu, 7 Jul 2016 18:50:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3DFA2848F; Thu, 7 Jul 2016 18:50:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2715C28408 for ; Thu, 7 Jul 2016 18:50:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEL5-0004cy-Es; Thu, 07 Jul 2016 18:47:55 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEL3-0004ca-Er for xen-devel@lists.xenproject.org; Thu, 07 Jul 2016 18:47:53 +0000 Received: from [193.109.254.147] by server-16.bemta-14.messagelabs.com id 44/68-24830-8D3AE775; Thu, 07 Jul 2016 18:47:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRWlGSWpSXmKPExsXitHRDpO71xXX hBi9+Wlt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmPn7AVLDauuLd7DVsD43r1LkYODgkBf4mP q3K7GDk52AR0JZq2/GUDCYsIqEjc3msAEmYWKJFYvGsKO0hYWMBC4v2GFJAwC1DF+canjCA2r 4CnxJF1C8BsCQE5ifPHfzKDlAsJqEnMXR8PUSIocXLmExaIiRISB1+8YIYo55a4fXoq8wRGnl lIymYhKVvAyLSKUaM4tagstUjX0EAvqSgzPaMkNzEzR9fQ0EQvN7W4ODE9NScxqVgvOT93EyM wNBiAYAfjuWXOhxglOZiURHkV/OvChfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw7l0ElBMsSk1P rUjLzAEGKUxagoNHSYT3AEiat7ggMbc4Mx0idYpRUUqcNxgkIQCSyCjNg2uDRcYlRlkpYV5Go EOEeApSi3IzS1DlXzGKczAqCfPuAJnCk5lXAjf9FdBiJqDFP12qQRaXJCKkpBoYJyQsaE+e8y T0rtty5QLegqhNa7bPesjYcuSfzJOOK2XiHRNS97bPDNq+rE76m7BhQECVDmtX7fWSU/mVXz7 YyeUpOk2SjlnAN/es3o9uG4bSdd6fhUIauPwbkw5eL9/R7TP5Xqa9gKN6nP7+IO32yXrC9zYy tnKseVC/X/u/vmJrm9WRPw+VWIozEg21mIuKEwEEofzuhwIAAA== X-Env-Sender: prvs=9898cd356=Ian.Jackson@citrix.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1467917270!52518232!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60951 invoked from network); 7 Jul 2016 18:47:51 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Jul 2016 18:47:51 -0000 X-IronPort-AV: E=Sophos;i="5.28,324,1464652800"; d="scan'208";a="364937882" From: Ian Jackson To: Date: Thu, 7 Jul 2016 19:47:39 +0100 Message-ID: <1467917260-21941-1-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Wei Liu , Ian Jackson Subject: [Xen-devel] [OSSTEST PATCH 1/2] Executive: Support substeps X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ts-* scripts can now create `substeps'. For the purposes of archaeology etc., a substep is just like a step. But it does correspond to a single specific ts-* invocation. Instead, it is started and finished explicitly as required. The whole job implementation code needs to explicitly assign a unique stable testid to each substep. The `script' parameter is stored in the `step' field in the database, which is used only for reporting. These do not need to be unique. All substeps started are should also be finished, by the end of the job. If this is not done, the job will be regarded as broken (if it is not already failed or aborted). (But a substep might be finished by a different ts-* script to the one that started it.) Signed-off-by: Ian Jackson CC: Wei Liu --- Osstest/JobDB/Executive.pm | 51 +++++++++++++++++++++++++++++++++++++++++++++ Osstest/JobDB/Standalone.pm | 10 +++++++++ Osstest/TestSupport.pm | 11 ++++++++++ sg-run-job | 6 ++++++ tcl/JobDB-Executive.tcl | 32 ++++++++++++++++++++++++++++ tcl/JobDB-Standalone.tcl | 2 ++ 6 files changed, 112 insertions(+) diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm index c0af21c..fdcb177 100644 --- a/Osstest/JobDB/Executive.pm +++ b/Osstest/JobDB/Executive.pm @@ -161,6 +161,57 @@ END logm("starting $flight started=$now") if $count>0; } +sub step_start ($$) { #method + my ($jd,$testid,$script) = @_; + my $snq = $dbh_tests->prepare(<prepare(<execute($flight,$job); + ($stepno) = $snq->fetchrow_array(); + $stepno //= 0; + $stepno++; + $createq->execute($flight,$job,$stepno, $script, $testid,time); + }); + logm("---------- substep $stepno $testid running ----------"); +} + +sub step_finish ($$) { #method + my ($jd,$testid,$stepstatus) = @_; + die "$flight.$job $testid $stepstatus" unless grep { $stepstatus eq $_ } + qw(pass fail blocked broken); + my $checkq = $dbh_tests->prepare(<prepare(<execute($flight,$job,$testid); + ($stepno, $oldstatus) = $checkq->fetchrow_array(); + die "$flight.$job $testid $stepno $oldstatus ?" + unless $oldstatus eq 'running'; + $setq->execute($stepstatus,time, $flight,$job,$testid, $stepno); + }); + logm("---------- substep $stepno $testid $stepstatus ----------"); +} + sub host_check_allocated ($$) { #method my ($jd, $ho) = @_; diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm index 98d0173..21ea07b 100644 --- a/Osstest/JobDB/Standalone.pm +++ b/Osstest/JobDB/Standalone.pm @@ -87,6 +87,16 @@ sub current_flight ($) { sub job_ensure_started ($) { } +sub step_start ($$) { + my ($jd,$testid,$script) = @_; + logm("========== $flight.$job step $testid running $script =========="); +} + +sub step_finish ($$) { #method + my ($jd,$testid,$stepstatus) = @_; + logm("========== $flight.$job step $testid $stepstatus =========="); +} + sub host_check_allocated ($$) { #method my ($jd, $ho) = @_; diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 9e6479a..76c3a57 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -42,6 +42,7 @@ BEGIN { ts_get_host_guest fail broken logm $logm_handle $logm_prefix + substep_start substep_finish get_filecontents report_once @@ -228,6 +229,16 @@ END : "($flight.$job not marked $newst)"); } +sub substep_start ($$) { + my ($testid,$script) = @_; + $mjobdb->step_start($testid,$script); +} + +sub substep_finish ($$) { + my ($testid,$stepstatus) = @_; + $mjobdb->step_finish($testid,$stepstatus); +} + sub get_filecontents ($;$) { my ($path, $ifnoent) = @_; # $ifnoent=undef => is error my $data= get_filecontents_core_quiet($path); diff --git a/sg-run-job b/sg-run-job index 0847d2f..60855b4 100755 --- a/sg-run-job +++ b/sg-run-job @@ -88,6 +88,12 @@ proc run-job {job} { run-ts !broken capture-logs ts-logs-capture + host } + if {$ok} { + if {[jobdb::job-check-escaped-steps $flight $job]} { + set ok 0 + } + } + if {$ok} { setstatus pass } if {$need_build_host && $ok} { jobdb::preserve-task 90 } diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl index 7dba497..8ba7d92 100644 --- a/tcl/JobDB-Executive.tcl +++ b/tcl/JobDB-Executive.tcl @@ -66,6 +66,38 @@ proc job-set-status {flight job st} { } } +proc job-check-escaped-steps {flight job} { + global runstepinfo + transaction flights { + set any 0 + + db-execute-array runstepinfo " + SELECT stepno, testid + FROM steps + WHERE flight = [pg_quote $flight] + AND job = [pg_quote $job] + AND status = 'running' + " { + logputs stderr \ + "$flight.$job step #$runstepinfo(stepno) $runstepinfo(testid) still running!" + set any 1 + } + + if {$any} { + db-execute " + UPDATE jobs + SET status='broken' + WHERE flight = [pg_quote $flight] + AND job = [pg_quote $job] + AND status<>'aborted' + AND status<>'broken' + AND status<>'fail' + " + } + } + return $any +} + proc set-flight {} { global flight argv env diff --git a/tcl/JobDB-Standalone.tcl b/tcl/JobDB-Standalone.tcl index d7d8422..4ef0962 100644 --- a/tcl/JobDB-Standalone.tcl +++ b/tcl/JobDB-Standalone.tcl @@ -44,6 +44,8 @@ proc job-set-status {flight job st} { } } +proc job-check-escaped-steps {flight job} { } + proc ensure-db-open {} { global c if {![catch { osstestdb version }]} { return }