0

I'm getting errors when using the ava test runner. For code:

test('gets account by ID with includes', async t => {
  const c = new Client('http://localhost:8000/v2/', token);
  const included = await c.account.get('2001', ['foo']).then(res => res.data.included);

  t.is(included[0].type, 'Foo');
});

test('gets order item by ID', async t => {
  const c = new Client('http://localhost:8000/v2/', token);
  const orderItem = await c.orderItem.get('2000').then(res => res.data.data);

  t.is(orderItem.type, 'OrderItem');
  t.is(orderItem.id, '2000');
});

I get:

1. get › gets account by ID with includes
Error: connect ECONNRESET 127.0.0.1:8000
Object.exports._errnoException (util.js:1036:11)
exports._exceptionWithHostPort (util.js:1059:20)
TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)


2. get › gets order item by ID
Error: write EPIPE
exports._errnoException (util.js:1036:11)
WriteWrap.afterWrite (net.js:794:14)

The errors don't show up all the time and they are very low level errors, so I suspect it must be a server config issue of somesort. Perhaps I should introduce delays between tests? Ava tests are spawned on many processes and run concurrently.

Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
  • Try running tests serially and see if the errors persist. May be running all tests in parallel are too much for your server. – yeiniel Sep 23 '16 at 20:52
  • that works. If you write it up as a solution I'll make it solved. Any ideas why a dev server wouldn't be able to handle parallel tests? – Harry Moreno Sep 23 '16 at 20:56

1 Answers1

0

Try running tests serially and see if the errors persist. May be running all tests in parallel are too much for your server.

Normally the server should be able to handle concurrent connections although there is a limit to it. It seems you are reaching that limit for the deployment you are testing.

Can you provide the number of individual tests you are performing? This info could shed light if this is a severe problem with your deployment or you are reaching the boundaries of your server. May be you can try using a benchmark tool (like Apache bench) to get info about your server deployment capabilities.

yeiniel
  • 2,416
  • 15
  • 31
  • I'm using the django development server. And my test suite is growing quite large. I'm also on a quad-core machine. So I wouldn't be surprised if the server is being overwhelmed by 4 connections hitting it at once. – Harry Moreno Sep 23 '16 at 21:56
  • Ava will run your tests all in parallel by default. Therefore if you have N tests it potentially will generate N simultaneous connections to your server. That's why is important you use a benchmark tool to determine the amount of concurrent connections your Django server could handle. – yeiniel Sep 23 '16 at 22:39