ava 测试运行程序写入 EPIPE 和 ECONNRESET 错误

ava test runner write EPIPE and ECONNRESET errors

我在使用 ava 测试时遇到错误 运行ner。对于代码:

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');
});

我得到:

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)

错误不会一直出现,它们是非常低级的错误,所以我怀疑这一定是某种服务器配置问题。也许我应该在测试之间引入延迟? Ava 测试在许多进程上产生并且 运行 同时发生。

连续尝试 运行 测试,看看错误是否仍然存在。可能 运行 所有并行测试对您的服务器来说太多了。

通常服务器应该能够处理并发连接,尽管它有一个限制。您似乎已达到正在测试的部署的限制。

您能否提供您正在执行的个别测试的数量?如果这是您的部署的严重问题或您已达到服务器的边界,此信息可能会有所帮助。也许您可以尝试使用基准测试工具(如 Apache bench)来获取有关您的服务器部署功能的信息。