Skip to content

Commit

Permalink
Added some simple stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Nov 5, 2014
1 parent 4c4521a commit a2a9e1a
Showing 1 changed file with 132 additions and 0 deletions.
132 changes: 132 additions & 0 deletions test/integration/datastore/async_methods/findAll.test.js
Expand Up @@ -3,6 +3,20 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
return 'DS.findAll(' + resourceName + ', params[, options]): ';
}

function createComments(iterations) {
var comments = [];
for (var i = 1; i < iterations; i++) {
var comment = {
id: i
};
for (var j = 1; j < 40; j++) {
comment['thing_' + j] = 'test_content_' + j;
}
comments.push(comment);
}
return comments;
}

beforeEach(startInjector);

it('should throw an error when method pre-conditions are not met', function () {
Expand Down Expand Up @@ -303,6 +317,124 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test repeated injection', function () {
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100));

var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();

$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100));

start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();

$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(100));

start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('100 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test 1000', function () {
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(1000));

var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('1000 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test 2000', function () {
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(2000));

var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('2000 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test 3000', function () {
this.timeout(10000);
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(3000));
var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('3000 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test 4000', function () {
this.timeout(10000);
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(4000));
var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('4000 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
it('stress test 5000', function () {
this.timeout(15000);
$httpBackend.expectGET('http://test.angular-cache.com/comment').respond(200, createComments(5000));
var start = new Date().getTime();

DS.findAll('comment', {}, {
bypassCache: true
}).then(function () {
console.log('5000 - time taken: ' + (new Date().getTime() - start) + 'ms');
}, function () {
fail('Should not have failed!');
});

$httpBackend.flush();
});
});

0 comments on commit a2a9e1a

Please sign in to comment.