зеркало из https://github.com/microsoft/etcd3.git
chore: try to fix flaking lease test
This commit is contained in:
Родитель
3fafea2e23
Коммит
dacc0805c7
|
@ -94,7 +94,7 @@ describe('lease()', () => {
|
|||
await lease.revoke();
|
||||
|
||||
proxiedClient.close();
|
||||
proxy.deactivate();
|
||||
await proxy.deactivate();
|
||||
});
|
||||
|
||||
it('marks leases as failed if the server is not contacted for a while', async () => {
|
||||
|
@ -108,7 +108,7 @@ describe('lease()', () => {
|
|||
const err = await onceEvent(lease, 'lost');
|
||||
expect(err.message).to.match(/our lease has expired/);
|
||||
proxiedClient.close();
|
||||
proxy.deactivate();
|
||||
await proxy.deactivate();
|
||||
});
|
||||
|
||||
it('emits a lost event if the lease is invalidated', async () => {
|
||||
|
|
|
@ -72,9 +72,9 @@ export class Proxy {
|
|||
/**
|
||||
* Destroys a previously-active proxy server.
|
||||
*/
|
||||
public deactivate() {
|
||||
this.server.close();
|
||||
public async deactivate() {
|
||||
this.isActive = false;
|
||||
await new Promise(r => this.server.close(r));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ export class Proxy {
|
|||
ALPNProtocols: ['h2'],
|
||||
},
|
||||
() => {
|
||||
if (serverBuffer.length > 0) {
|
||||
if (serverBuffer.length > 0 && !ended) {
|
||||
serverCnx.write(Buffer.concat(serverBuffer));
|
||||
}
|
||||
|
||||
|
@ -105,11 +105,11 @@ export class Proxy {
|
|||
|
||||
let ended = false;
|
||||
const end = (err?: Error) => {
|
||||
ended = true;
|
||||
if (err instanceof Error) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
ended = true;
|
||||
clientCnx.end();
|
||||
serverCnx.end();
|
||||
this.connections = this.connections.filter(c => c.end !== end);
|
||||
|
@ -120,17 +120,17 @@ export class Proxy {
|
|||
clientCnx.write(data);
|
||||
}
|
||||
});
|
||||
serverCnx.on('close', end);
|
||||
serverCnx.on('end', end);
|
||||
serverCnx.on('error', end);
|
||||
|
||||
clientCnx.on('data', (data: Buffer) => {
|
||||
if (serverConnected && !ended) {
|
||||
serverCnx.write(data);
|
||||
} else {
|
||||
} else if (!ended) {
|
||||
serverBuffer.push(data);
|
||||
}
|
||||
});
|
||||
clientCnx.on('close', end);
|
||||
clientCnx.on('end', end);
|
||||
clientCnx.on('error', end);
|
||||
|
||||
this.connections.push({ end });
|
||||
|
|
|
@ -69,7 +69,7 @@ describe('watch()', () => {
|
|||
await expectWatching(watcher, 'foo1');
|
||||
|
||||
proxiedClient.close();
|
||||
proxy.deactivate();
|
||||
await proxy.deactivate();
|
||||
});
|
||||
|
||||
// todo(connor4312): this is disabled pending resolution on:
|
||||
|
@ -98,7 +98,7 @@ describe('watch()', () => {
|
|||
});
|
||||
|
||||
proxiedClient.close();
|
||||
proxy.deactivate();
|
||||
await proxy.deactivate();
|
||||
});
|
||||
|
||||
it('caps watchers revisions', async () => {
|
||||
|
@ -189,7 +189,7 @@ describe('watch()', () => {
|
|||
expect(getWatchers()).to.deep.equal([]);
|
||||
|
||||
proxiedClient.close();
|
||||
proxy.deactivate();
|
||||
await proxy.deactivate();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче