-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathloadTesting.js
93 lines (86 loc) · 2.49 KB
/
loadTesting.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require("./extensions/string");
require("./extensions/number");
require("./inheritance");
var config = require("./config");
var mapper = require("./data/mapping/mapper");
var bundler = require("./bundling/bundler");
var caches = require("./data/newCaches");
var controllers = require("./controllers/controllers");
var connection = require("./data/connection");
var repositories = require("./data/repositories");
var ObjectId = require("mongoose").Types.ObjectId;
var models = require("./data/models");
var Promise = require("bluebird");
var ISSUE_COUNT = 50000;
return connection.open().then(function () {
//return _removeIssues();
return Promise.all(_buildIssues(ISSUE_COUNT));
}).then(function () {
console.log("Done.");
});
function _removeIssues() {
return new Promise(function(resolve, reject) {
models.Issue.find({ type: "Load Testing" }).remove(function(err) {
if (err) reject(err);
else resolve();
});
});
}
function _buildIssues(count) {
var promises = [];
for (var i = 0; i < count; i++) {
promises.push(repositories.Issue.create({
name: "load testing issue name",
number: Math.round(Math.random()*10)%3,
closed: Date.now(),
developer: "Chris Harrington",
tester: "Chris Harrington",
priority: "Medium",
status: "Pending Development",
milestone: "Backlog",
type: "Load Testing",
project: ObjectId("532bb0e4654c146016485bec"),
updatedBy: "Chris Harrington",
priorityId: ObjectId("532bb0e5654c146016485bf5"),
priorityOrder: 2,
statusId: ObjectId("532bb0e5654c146016485bf8"),
statusOrder: 1,
milestoneId: ObjectId("532bb0e5654c146016485bf1"),
typeId: ObjectId("532bb0e5654c146016485bf0"),
updatedById: ObjectId("532bb0e4654c146016485bed"),
testerId: ObjectId("532bb0e4654c146016485bed"),
developerId: ObjectId("532bb0e4654c146016485bed"),
details: "load testing issue details",
updated: Date.now(),
opened: Date.now(),
isDeleted: false
}));
}
return promises;
}
/*
name: String,
details: String,
number: Number,
isDeleted: { type: Boolean, default: false },
opened: { type: Date, default: Date.now },
closed: Date,
updated: { type: Date, default: Date.now },
priorityId: objectId,
priority: String,
priorityOrder: Number,
developerId: objectId,
developer: String,
testerId: objectId,
tester: String,
statusId: objectId,
status: String,
statusOrder: Number,
milestoneId: objectId,
milestone: String,
typeId: objectId,
type: String,
updatedById: objectId,
updatedBy: String,
project: { type: objectId, ref: "project" }
*/