jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/338035 )

Change subject: Wait till we're stopped before exiting parserTests
......................................................................


Wait till we're stopped before exiting parserTests

Change-Id: Ibb65a6e67b8fa91ca660974bff9cae95caad1d0f
---
M bin/parserTests.js
M lib/api/ParsoidService.js
M lib/config/MWParserEnvironment.js
M tests/serviceWrapper.js
4 files changed, 27 insertions(+), 10 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/bin/parserTests.js b/bin/parserTests.js
index 127beca..4b05668 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -1484,10 +1484,11 @@
 Promise.resolve(null).then(function() {
        var options = PTUtils.prepareOptions();
        return serviceWrapper.runServices({ skipParsoid: true })
-               .then(function(ret) {
-                       return [ options, ret.mockURL ];
-               });
-}).spread(function(options, mockURL) {
+       .then(function(ret) {
+               return [ ret.runner, options, ret.mockURL ];
+       });
+})
+.spread(function(runner, options, mockURL) {
        var testFilePaths;
        if (options._[0]) {
                testFilePaths = [path.resolve(process.cwd(), options._[0])];
@@ -1515,13 +1516,17 @@
                        Object.keys(stats).forEach(function(k) {
                                stats[k] += result.stats[k]; // Sum all stats
                        });
-                       return exitCode || result.exitCode;
+                       return [ runner, exitCode || result.exitCode ];
                });
-       }, 0).tap(function() {
+       }, 0)
+       .tap(function() {
                options.reportSummary([], stats, null, stats.loggedErrorCount, 
null);
        });
 })
-.then(function(exitCode) {
-       process.exit(exitCode);
+.spread(function(runner, exitCode) {
+       return runner.stop()
+       .then(function() {
+               process.exit(exitCode);
+       });
 })
 .done();
diff --git a/lib/api/ParsoidService.js b/lib/api/ParsoidService.js
index 399a3ed..c75e5d8 100644
--- a/lib/api/ParsoidService.js
+++ b/lib/api/ParsoidService.js
@@ -200,7 +200,14 @@
                        util.format('ready on %s:%s', host || '', port));
                return {
                        close: function() {
-                               return Promise.promisify(server.close, false, 
server)();
+                               return Promise.promisify(server.close, false, 
server)()
+                               .tap(function() {
+                                       // The conf cache is reused across 
requests, but shouldn't
+                                       // be shared between services.  This 
conflict arises when
+                                       // service-runner num_workers is zero, 
and mocha spawns
+                                       // services in succession.
+                                       
require('../config/MWParserEnvironment.js').MWParserEnvironment.resetConfCache();
+                               });
                        },
                        port: port,
                };
diff --git a/lib/config/MWParserEnvironment.js 
b/lib/config/MWParserEnvironment.js
index d9b1fa4..a8d15af 100644
--- a/lib/config/MWParserEnvironment.js
+++ b/lib/config/MWParserEnvironment.js
@@ -281,7 +281,10 @@
 MWParserEnvironment.prototype.defaultPageName = "Main Page";
 
 // Cache for wiki configurations, shared between requests.
-MWParserEnvironment.prototype.confCache = {};
+MWParserEnvironment.resetConfCache = function() {
+       MWParserEnvironment.prototype.confCache = {};
+};
+MWParserEnvironment.resetConfCache();
 
 MWParserEnvironment.prototype.setCaches = function(caches) {
        // TODO gwicke: probably not that useful any more as this is per-request
diff --git a/tests/serviceWrapper.js b/tests/serviceWrapper.js
index 9bae85e..b4cd566 100644
--- a/tests/serviceWrapper.js
+++ b/tests/serviceWrapper.js
@@ -90,6 +90,8 @@
                });
                ret.runner = runner;
                return runner.start({
+                       // T158265: We should set this to zero since otherwise
+                       // service-runner doesn't actually call close on the 
worker.
                        num_workers: 1,
                        worker_heartbeat_timeout: 2 * 60 * 1000,
                        logging: {

-- 
To view, visit https://gerrit.wikimedia.org/r/338035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb65a6e67b8fa91ca660974bff9cae95caad1d0f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to