env.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2015 rain1017.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. // implied. See the License for the specific language governing
  13. // permissions and limitations under the License. See the AUTHORS file
  14. // for names of contributors.
  15. 'use strict';
  16. var should = require('should');
  17. var path = require('path');
  18. var child_process = require('child_process');
  19. var quick = require('../lib');
  20. var logger = quick.logger.getLogger('test', __filename);
  21. var P = quick.Promise;
  22. P.longStackTraces();
  23. var execMemdbClusterSync = function(cmd){
  24. var configPath = path.join(__dirname, 'memdb.conf.js');
  25. var output = child_process.execFileSync('memdbcluster', [cmd, '--conf=' + configPath]);
  26. logger.info(output.toString());
  27. };
  28. exports.initMemdbSync = function(){
  29. execMemdbClusterSync('drop');
  30. execMemdbClusterSync('start');
  31. };
  32. exports.closeMemdbSync = function(){
  33. execMemdbClusterSync('stop');
  34. };
  35. exports.memdbConfig = {
  36. backend : {
  37. engine : 'mongodb',
  38. url : 'mongodb://localhost/quick-pomelo-test',
  39. options : {},
  40. },
  41. shards : {
  42. area1 : {
  43. host : '127.0.0.1',
  44. port : 32017,
  45. }
  46. },
  47. modelsPath : 'lib/models',
  48. };