[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Wait till we're stopped before exiting parserTests

2017-03-10 Thread jenkins-bot (Code Review)
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 
Gerrit-Reviewer: Arlolra 
Gerrit-Reviewer: C. Scott Ananian 
Gerrit-Reviewer: Subramanya Sastry 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Wait till we're stopped before exiting

2017-02-15 Thread Arlolra (Code Review)
Arlolra has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/338035 )

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

Wait till we're stopped before exiting

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


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/35/338035/1

diff --git a/bin/parserTests.js b/bin/parserTests.js
index c7a6312..9c61212 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -1452,8 +1452,10 @@
 };
 
 // Start the mock api server and kick off parser tests
+var runner;
 serviceWrapper.runServices({ skipParsoid: true })
 .then(function(ret) {
+   runner = ret.runner;
var options = PTUtils.prepareOptions();
var testFilePaths;
if (options._[0]) {
@@ -1475,6 +1477,8 @@
}, 0);
 })
 .then(function(status) {
-   process.exit(status);
+   runner.stop().then(function() {
+   process.exit(status);
+   });
 })
 .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 4b4b5a2..f44852b 100644
--- a/lib/config/MWParserEnvironment.js
+++ b/lib/config/MWParserEnvironment.js
@@ -267,7 +267,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 5007b04..1165ee4 100644
--- a/tests/serviceWrapper.js
+++ b/tests/serviceWrapper.js
@@ -90,7 +90,9 @@
});
ret.runner = runner;
return runner.start({
-   num_workers: 1,
+   // Set this to zero since otherwise service-runner 
doesn't actually
+   // call close on the worker.
+   num_workers: 0,
worker_heartbeat_timeout: 2 * 60 * 1000,
logging: {
level: 'info',  // Default is 'warn'

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb65a6e67b8fa91ca660974bff9cae95caad1d0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra 

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