Marcoil has uploaded a new change for review. https://gerrit.wikimedia.org/r/137680
Change subject: Bug 56601: Keep number of rt selser errors in new column in stat table ...................................................................... Bug 56601: Keep number of rt selser errors in new column in stat table To use with existing database, pass mySQL this script: test/server/sql/003_alter_stats_add_selser_errors.sql Change-Id: Ic49ccfee4d8a469beefb9254fabf03a610de3fec --- M tests/server/server.js A tests/server/sql/003_alter_stats_add_selser_errors.sql M tests/server/sql/create_everything.mysql 3 files changed, 31 insertions(+), 22 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/80/137680/1 diff --git a/tests/server/server.js b/tests/server/server.js index 5616c6f..86c7ab5 100755 --- a/tests/server/server.js +++ b/tests/server/server.js @@ -186,11 +186,12 @@ var dbInsertStats = 'INSERT INTO stats ' + - '( skips, fails, errors, score, page_id, commit_hash ) ' + - 'VALUES ( ?, ?, ?, ?, ?, ? ) ' + + '( skips, fails, errors, selser_errors, score, page_id, commit_hash ) ' + + 'VALUES ( ?, ?, ?, ?, ?, ?, ? ) ' + 'ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID( id ), ' + 'skips = VALUES( skips ), fails = VALUES( fails ), ' + - 'errors = VALUES( errors ), score = VALUES( score )'; + 'errors = VALUES( errors ), selser_errors = VALUES(selser_errors), ' + + 'score = VALUES( score )'; var dbInsertPerfStatsStart = 'INSERT INTO perfstats ' + @@ -255,10 +256,10 @@ 'AND claim_timestamp < ?) AS crashers, ' + // Get num of rt selser errors '(SELECT count(*) ' + - 'FROM pages ' + - 'JOIN results ON pages.id = results.page_id ' + - 'WHERE results.commit_hash = (SELECT hash FROM commits ORDER BY timestamp DESC LIMIT 1) ' + - 'AND results.result LIKE "%(selser)%") AS rtselsererrors ' + + 'FROM pages ' + + 'JOIN stats ON pages.id = stats.page_id ' + + 'WHERE stats.commit_hash = (SELECT hash FROM commits ORDER BY timestamp DESC LIMIT 1) ' + + 'AND stats.selser_errors > 0) AS rtselsererrors ' + 'FROM pages JOIN stats on pages.latest_stat = stats.id'; @@ -312,11 +313,11 @@ 'AND claim_timestamp < ?) AS crashers, ' + // Get num of rt selser errors '(SELECT count(*) ' + - 'FROM pages ' + - 'JOIN results ON pages.id = results.page_id ' + - 'WHERE pages.prefix = ? ' + - 'AND results.commit_hash = (SELECT hash FROM commits ORDER BY timestamp DESC LIMIT 1 ) ' + - 'AND results.result LIKE "%(selser)%" ) AS rtselsererrors ' + + 'FROM pages ' + + 'JOIN stats ON pages.id = stats.page_id ' + + 'WHERE pages.prefix = ? ' + + 'AND stats.commit_hash = (SELECT hash FROM commits ORDER BY timestamp DESC LIMIT 1 ) ' + + 'AND stats.selser_errors > 0) AS rtselsererrors ' + 'FROM pages JOIN stats on pages.latest_stat = stats.id WHERE pages.prefix = ?'; @@ -480,17 +481,15 @@ 'LIMIT 40 OFFSET ?'; var dbPagesWithRTSelserErrors = - 'SELECT pages.title, pages.prefix, commits.hash, stats.errors, stats.fails, stats.skips ' + + 'SELECT pages.title, pages.prefix, commits.hash, ' + + 'stats.errors, stats.fails, stats.skips, stats.selser_errors ' + 'FROM stats ' + 'JOIN pages ON stats.page_id = pages.id ' + 'JOIN commits ON stats.commit_hash = commits.hash ' + - 'WHERE commits.hash = ? AND (SELECT count(*) FROM results WHERE ' + - '(results.page_id = pages.id) AND ' + - '(results.result LIKE "%(selser)%") AND ' + - '(results.commit_hash = commits.hash) ' + - ') > 0 ' + + 'WHERE commits.hash = ? AND ' + + 'stats.selser_errors > 0 ' + 'ORDER BY stats.score DESC ' + - 'LIMIT 40 OFFSET ?' ; + 'LIMIT 40 OFFSET ?'; var dbResultsQuery = 'SELECT result FROM results'; @@ -721,7 +720,8 @@ result = req.body.results, skipCount = result.match( /<skipped/g ), failCount = result.match( /<failure/g ), - errorCount = result.match( /<error/g ); + errorCount = result.match( /<error/g ), + selserErrorCount = 0; var prefix = req.params[1]; var commitHash = req.body.commit; var perfstats = parsePerfStats( result ); @@ -729,6 +729,13 @@ skipCount = skipCount ? skipCount.length : 0; failCount = failCount ? failCount.length : 0; errorCount = errorCount ? errorCount.length : 0; + // Find the number of selser errors + var selserSuites = result.match(/<testsuite[^>]*\(selser\)[^>]*>[\s\S]*?<\/testsuite>/g); + console.warn("selserSuites:", selserSuites); + for (var selserSuite in selserSuites) { + var matches = selserSuites[selserSuite].match(/<testcase/g); + selserErrorCount += matches ? matches.length : 0; + } res.setHeader( 'Content-Type', 'text/plain; charset=UTF-8' ); @@ -761,7 +768,7 @@ transUpdateCB.bind( null, title, prefix, commitHash, "result", res, trans, function( insertedResult ) { latest_resultId = insertedResult.insertId; // Insert the stats - trans.query( dbInsertStats, [ skipCount, failCount, errorCount, score, page.id, commitHash ], + trans.query( dbInsertStats, [ skipCount, failCount, errorCount, selserErrorCount, score, page.id, commitHash ], transUpdateCB.bind( null, title, prefix, commitHash, "stats", res, trans, function( insertedStat ) { latest_statId = insertedStat.insertId; diff --git a/tests/server/sql/003_alter_stats_add_selser_errors.sql b/tests/server/sql/003_alter_stats_add_selser_errors.sql new file mode 100644 index 0000000..a8146a4 --- /dev/null +++ b/tests/server/sql/003_alter_stats_add_selser_errors.sql @@ -0,0 +1 @@ +ALTER TABLE `stats` ADD `selser_errors` INTEGER NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/tests/server/sql/create_everything.mysql b/tests/server/sql/create_everything.mysql index 2a831d2..50e1c54 100644 --- a/tests/server/sql/create_everything.mysql +++ b/tests/server/sql/create_everything.mysql @@ -36,7 +36,8 @@ skips INTEGER NOT NULL DEFAULT 0, fails INTEGER NOT NULL DEFAULT 0, errors INTEGER NOT NULL DEFAULT 0, - score INTEGER NOT NULL DEFAULT 0 + score INTEGER NOT NULL DEFAULT 0, + selser_errors INTEGER NOT NULL DEFAULT 0, ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE UNIQUE INDEX stats_page_commit_idx ON stats ( page_id, commit_hash ); -- To view, visit https://gerrit.wikimedia.org/r/137680 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic49ccfee4d8a469beefb9254fabf03a610de3fec Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Marcoil <marc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits