Merge lp:~gl-az/percona-xtrabackup/2.0-testrun-summary into lp:percona-xtrabackup/2.0

Proposed by George Ormond Lorch III
Status: Superseded
Proposed branch: lp:~gl-az/percona-xtrabackup/2.0-testrun-summary
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 95 lines (+39/-4)
1 file modified
test/testrun.c (+39/-4)
To merge this branch: bzr merge lp:~gl-az/percona-xtrabackup/2.0-testrun-summary
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Needs Fixing
Registry Administrators Pending
Review via email: mp+167117@code.launchpad.net

This proposal supersedes a proposal from 2013-05-31.

This proposal has been superseded by a proposal from 2013-06-04.

Description of the change

Added test status tracking and summary report at end of test run cycle to make it wasy to see what failed at a glance, similar to MTR.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Doesn't this report the skipped testcases (exit code == 200) as the failed ones?

If yes, that wouldn't be entirely correct, I'd report failed and skipped testcases separately.

Typo on diff line 32.

review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) wrote : Posted in a previous version of this proposal

Good catch Laurynas, I didn't think about the skipped cases in this context. Something else worth considering is making the testrun behave more like the suite and MTR in that it will stop on the first failure and return that error code, which can be overridden by a -f and maybe add some retry logic.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

It looks that now the skipped cases will be listed twice: both as skipped (exit == 200), and as failed (exit != 0).

review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) wrote :

Oy, Doh! That's what I get for trying to do n+1 things at once where 'n'
is my max capacity for parallelism...

On 6/3/2013 9:34 PM, Laurynas Biveinis wrote:
> Review: Needs Fixing
>
> It looks that now the skipped cases will be listed twice: both as skipped (exit == 200), and as failed (exit != 0).
>

--
George O. Lorch III
Software Engineer, Percona
+1-888-401-3401 x542 US/Arizona (GMT -7)
skype: george.ormond.lorch.iii

Revision history for this message
George Ormond Lorch III (gl-az) wrote :

OK Laurynas, as we discussed on IRC I did some more testing:
Created a new 'suite' called 'u' which exists as a sibling directory to the current 't' (test/u).
Added 3 simple tests:

$ cat u/test_pass.sh
. inc/common.sh
sleep 5
exit 0

$ cat u/test_fail.sh
. inc/common.sh
sleep 5
exit 1

$ cat u/test_skip.sh
. inc/common.sh
sleep 5
exit $SKIPPED_EXIT_CODE

Then ran the suite:
$ ./testrun -j 1 -s u

The first thing I ran into was all tests were failing with 255, why? Well, testrun.c doesn't work with alternate suites correctly. It will find the tests in the correct location, but when it goes to execute them, it tries to execute them out of ./t/<testname> instead of ./<suitename>/<testname>. This was a simple fix so I made it and updated the branch with this fix.

With that working, I run again and realize that testrun.c launches all tests individually through testrun.sh. testrun.sh only returns success (0) or failure (-1/255), nothing else because it may have run multiple tests so it only returns 'all succeeded or skipped' or 'something failed'. With this, in order to report skipped tests, we will need to modify testrun.sh to do something like pass the result from the tests directly out of there was only one test specified, otherwise, use the old method.

So, that being said, we have two choices here:
1) We just go back to my original work where we were really only interested in reporting true failures and accepting skipped tests as passed.
2) Change testrun.sh to return the true result when only one test was specified.

Opinions?

561. By George Ormond Lorch III

Fixed issue in testrun.c where specifying testsuite would find the tests in the corredt directory but would still try to execute them out of ./t

Added test status tracking and summary report at end of test run cycle to make it wasy to see what passed, skipped and failed at a glance, similar to MTR.

Changed testrun.sh slightly to return same code out of testrun.sh as the test that was executed when only a single test was run.

Unmerged revisions

561. By George Ormond Lorch III

Fixed issue in testrun.c where specifying testsuite would find the tests in the corredt directory but would still try to execute them out of ./t

Added test status tracking and summary report at end of test run cycle to make it wasy to see what passed, skipped and failed at a glance, similar to MTR.

Changed testrun.sh slightly to return same code out of testrun.sh as the test that was executed when only a single test was run.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/testrun.c'
2--- test/testrun.c 2012-11-30 04:28:06 +0000
3+++ test/testrun.c 2013-06-04 17:49:27 +0000
4@@ -41,6 +41,7 @@
5 char *buf;
6 size_t end_of_buf;
7 size_t bufsz;
8+ int status;
9 };
10
11 pid_t *childpid;
12@@ -96,6 +97,7 @@
13 (*cases)[i].buf= NULL;
14 (*cases)[i].end_of_buf= 0;
15 (*cases)[i].bufsz= 0;
16+ (*cases)[i].status= 0;
17 free(namelist[i]);
18 }
19
20@@ -113,6 +115,38 @@
21 free(cases);
22 }
23
24+static void report_status(struct testcase *cases, int n)
25+{
26+ int i;
27+ int failed=0;
28+ int skipped=0;
29+ for (i=0; i<n; i++)
30+ if (WEXITSTATUS(cases[i].status) != 0)
31+ if (WEXITSTATUS(cases[i].status) == 200)
32+ skipped++;
33+ else
34+ failed++;
35+
36+ printf("SUMMARY: %d run, %d successful, %d skipped, %d failed\n", n, n - failed - skipped, skipped, failed);
37+ if (skipped)
38+ {
39+ printf("Skipped cases:");
40+ for (i=0; i<n; i++)
41+ if (WEXITSTATUS(cases[i].status) == 200)
42+ printf(" %s", cases[i].name);
43+ printf("\n");
44+ }
45+
46+ if (failed)
47+ {
48+ printf("Failing cases:");
49+ for (i=0; i<n; i++)
50+ if (WEXITSTATUS(cases[i].status) != 0 && WEXITSTATUS(cases[i].status != 200))
51+ printf(" %s", cases[i].name);
52+ printf("\n");
53+ }
54+}
55+
56 static int run_testcase_in_child(int nr, struct testcase *t, pid_t *cpid, const char* xbtarget)
57 {
58 int fd[2];
59@@ -202,7 +236,6 @@
60 int nfds= 0;
61 int retval;
62 pid_t chpid[njobs];
63- int status;
64 int next_testcase= 0;
65 int i;
66 fd_set rfds;
67@@ -277,8 +310,8 @@
68 t->end_of_buf+= r;
69 } while(r>0);
70
71- pid_t waited= waitpid(childpid[i], &status, WNOHANG);
72- if (!(WIFEXITED(status) || WIFSIGNALED(status)))
73+ pid_t waited= waitpid(childpid[i], &testcases[childtest[i]].status, WNOHANG);
74+ if (!(WIFEXITED(testcases[childtest[i]].status) || WIFSIGNALED(testcases[childtest[i]].status)))
75 continue;
76
77 if (waited != childpid[i])
78@@ -289,7 +322,7 @@
79
80 close(childfd[i]);
81 printf("[%d] completed %s status %d\n",
82- i, testcases[childtest[i]].name, WEXITSTATUS(status));
83+ i, testcases[childtest[i]].name, WEXITSTATUS(testcases[childtest[i]].status));
84 childfd[i]=-1;
85 nchildren--;
86
87@@ -399,6 +432,8 @@
88
89 run_testcases(testcases, nrcases, njobs, timeout, xbtarget);
90
91+ report_status(testcases, nrcases);
92+
93 free_testcases(testcases, nrcases);
94
95 return 0;

Subscribers

People subscribed via source and target branches