зеркало из https://github.com/mozilla/galaxy-api.git
Merge pull request #107 from CharlesChong/db-prefill-parameters(issue#106)
Moved db-prefill parameters to an external .json file
This commit is contained in:
Коммит
cc9e1133d9
|
@ -16,5 +16,6 @@ build
|
|||
node_modules
|
||||
|
||||
settings_local.js
|
||||
scripts/prefillParameters.json
|
||||
data/
|
||||
dump.rdb
|
||||
|
|
|
@ -10,6 +10,7 @@ var db = require('../db');
|
|||
var settings = require('../settings');
|
||||
var settings_local = require('../settings_local');
|
||||
var utils = require('../lib/utils');
|
||||
var params = require('./prefillParameters');
|
||||
|
||||
const PERSONA_PORT = '9009';
|
||||
const PERSONA_ENDPOINT = 'http://localhost:' + PERSONA_PORT;
|
||||
|
@ -21,22 +22,6 @@ const API_ENDPOINT = 'http://localhost:' + API_PORT;
|
|||
const PREFILL_NAMESPACE = 'galaxy-db-prefill';
|
||||
const SIGNAL_NAMES = ['api', 'persona-faker'];
|
||||
|
||||
const USER_COUNT = 100;
|
||||
const FAKE_GAMES = [
|
||||
{
|
||||
name: 'Mario Broskis',
|
||||
app_url: 'http://mario.broskis'
|
||||
},
|
||||
{
|
||||
name: 'Halo 718',
|
||||
app_url: 'http://halo.com'
|
||||
},
|
||||
{
|
||||
name: 'Left 5 Dead',
|
||||
app_url: 'http://dead.left'
|
||||
}
|
||||
];
|
||||
|
||||
// A stream.Writable subclass that forwards to another stream after
|
||||
// prefixing each chunk with the provided name
|
||||
function NamedWritable(name, forwardingStream) {
|
||||
|
@ -65,6 +50,12 @@ client.on('ready', function() {
|
|||
});
|
||||
|
||||
function run() {
|
||||
_.defaults(params, {
|
||||
games: [],
|
||||
numUsers: 0,
|
||||
numFriends: 0
|
||||
});
|
||||
|
||||
var ready_promise = new Promise(function(resolve, reject) {
|
||||
// Transform signal names into an object with those keys
|
||||
// so that we can cleanly lookup and delete them
|
||||
|
@ -208,7 +199,7 @@ function createUsers() {
|
|||
});
|
||||
};
|
||||
|
||||
return Promise.all(_.times(USER_COUNT, function(i) {
|
||||
return Promise.all(_.times(params.numUsers, function(i) {
|
||||
return createUser('test' + i + '@test.com').then(login);
|
||||
}));
|
||||
}
|
||||
|
@ -219,7 +210,7 @@ function createGames() {
|
|||
screenshots: 'yes'
|
||||
};
|
||||
|
||||
return Promise.all(FAKE_GAMES.map(function(game) {
|
||||
return Promise.all(params.games.map(function(game) {
|
||||
return postPromise(API_ENDPOINT + '/game/submit',
|
||||
_.defaults(game, default_params));
|
||||
}));
|
||||
|
@ -244,7 +235,7 @@ function purchaseGames(userSSAs, gameSlugs) {
|
|||
|
||||
function createFriends(users) {
|
||||
function sendRequests(user) {
|
||||
var recipients = _.sample(users, Math.min(3, USER_COUNT));
|
||||
var recipients = _.sample(users, Math.min(params.numFriends, params.numUsers));
|
||||
var promises = recipients.map(function(recipient){
|
||||
return sendRequest(user, recipient);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"games": [
|
||||
{
|
||||
"name": "Mario Broskis",
|
||||
"app_url": "http://mario.broskis"
|
||||
},
|
||||
{
|
||||
"name": "Halo 718",
|
||||
"app_url": "http://halo.com"
|
||||
},
|
||||
{
|
||||
"name": "Left 5 Dead",
|
||||
"app_url": "http://dead.left"
|
||||
}
|
||||
],
|
||||
"numUsers": 50,
|
||||
"numFriends": 2
|
||||
}
|
Загрузка…
Ссылка в новой задаче