mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-19 15:54:28 +00:00
chore: attempt stability for test suite
This commit is contained in:
parent
5119c858da
commit
04cd3571d1
1
.github/workflows/test-node.yml
vendored
1
.github/workflows/test-node.yml
vendored
@ -33,6 +33,7 @@ env:
|
||||
jobs:
|
||||
node:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60 # Add a 1-hour timeout to fail faster
|
||||
env:
|
||||
WAKUNODE_IMAGE: ${{ inputs.nim_wakunode_image }}
|
||||
ALLURE_REPORTS: ${{ inputs.allure_reports }}
|
||||
|
@ -7,7 +7,8 @@ const config = {
|
||||
'loader=ts-node/esm'
|
||||
],
|
||||
exit: true,
|
||||
retries: 2
|
||||
retries: 2,
|
||||
timeout: 150_000
|
||||
};
|
||||
|
||||
if (process.env.CI) {
|
||||
|
@ -237,6 +237,7 @@ class MultipleNodesMessageCollector {
|
||||
const startTime = Date.now();
|
||||
const pubsubTopic = options?.pubsubTopic || DefaultTestPubsubTopic;
|
||||
const timeoutDuration = options?.timeoutDuration || 400;
|
||||
const maxTimeout = Math.min(timeoutDuration * numMessages, 30000);
|
||||
const exact = options?.exact || false;
|
||||
|
||||
while (this.messageList.length < numMessages) {
|
||||
@ -248,7 +249,9 @@ class MultipleNodesMessageCollector {
|
||||
return msgs.length >= numMessages;
|
||||
})
|
||||
);
|
||||
return results.every((result) => result);
|
||||
if (results.every((result) => result)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
const results = await Promise.all(
|
||||
this.relayNodes.map(async (node) => {
|
||||
@ -256,16 +259,19 @@ class MultipleNodesMessageCollector {
|
||||
return msgs.length >= numMessages;
|
||||
})
|
||||
);
|
||||
return results.some((result) => result);
|
||||
if (results.some((result) => result)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const elapsed = Date.now() - startTime;
|
||||
if (elapsed > timeoutDuration * numMessages) {
|
||||
return false;
|
||||
}
|
||||
const elapsed = Date.now() - startTime;
|
||||
if (elapsed > maxTimeout) {
|
||||
log.warn(`Timeout waiting for messages after ${elapsed}ms`);
|
||||
return false;
|
||||
}
|
||||
|
||||
await delay(10);
|
||||
await delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
if (exact) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {
|
||||
CreateNodeOptions,
|
||||
DefaultNetworkConfig,
|
||||
IWaku,
|
||||
LightNode,
|
||||
NetworkConfig,
|
||||
ProtocolCreateOptions,
|
||||
Protocols
|
||||
} from "@waku/interfaces";
|
||||
import { createLightNode } from "@waku/sdk";
|
||||
@ -40,7 +40,7 @@ export async function runMultipleNodes(
|
||||
await verifyServiceNodesConnected(serviceNodes.nodes);
|
||||
}
|
||||
|
||||
const wakuOptions: ProtocolCreateOptions = {
|
||||
const wakuOptions: CreateNodeOptions = {
|
||||
staticNoiseKey: NOISE_KEY_1,
|
||||
libp2p: {
|
||||
addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] }
|
||||
|
@ -6,6 +6,8 @@ import { ServiceNode } from "../lib/service_node.js";
|
||||
|
||||
const log = new Logger("test:teardown");
|
||||
|
||||
const TEARDOWN_TIMEOUT = 10000; // 10 seconds timeout for teardown
|
||||
|
||||
export async function tearDownNodes(
|
||||
nwakuNodes: ServiceNode | ServiceNode[],
|
||||
wakuNodes: IWaku | IWaku[]
|
||||
@ -13,37 +15,47 @@ export async function tearDownNodes(
|
||||
const nNodes = Array.isArray(nwakuNodes) ? nwakuNodes : [nwakuNodes];
|
||||
const wNodes = Array.isArray(wakuNodes) ? wakuNodes : [wakuNodes];
|
||||
|
||||
const stopNwakuNodes = nNodes.map(async (nwaku) => {
|
||||
if (nwaku) {
|
||||
await pRetry(
|
||||
async () => {
|
||||
try {
|
||||
await nwaku.stop();
|
||||
} catch (error) {
|
||||
log.error("Nwaku failed to stop:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
{ retries: 3 }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const stopWakuNodes = wNodes.map(async (waku) => {
|
||||
if (waku) {
|
||||
await pRetry(
|
||||
async () => {
|
||||
try {
|
||||
// Use Promise.race to implement timeout
|
||||
const teardownPromise = Promise.all([
|
||||
...nNodes.map(async (nwaku) => {
|
||||
if (nwaku) {
|
||||
await pRetry(
|
||||
async () => {
|
||||
try {
|
||||
await nwaku.stop();
|
||||
} catch (error) {
|
||||
log.error("Nwaku failed to stop:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
{ retries: 3, minTimeout: 1000 }
|
||||
);
|
||||
}
|
||||
}),
|
||||
...wNodes.map(async (waku) => {
|
||||
if (waku) {
|
||||
try {
|
||||
await waku.stop();
|
||||
} catch (error) {
|
||||
log.error("Waku failed to stop:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
{ retries: 3 }
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
]);
|
||||
|
||||
await Promise.all([...stopNwakuNodes, ...stopWakuNodes]);
|
||||
await Promise.race([
|
||||
teardownPromise,
|
||||
new Promise((_, reject) =>
|
||||
setTimeout(
|
||||
() => reject(new Error("Teardown timeout")),
|
||||
TEARDOWN_TIMEOUT
|
||||
)
|
||||
)
|
||||
]);
|
||||
} catch (error) {
|
||||
log.error("Teardown failed:", error);
|
||||
// Force process cleanup if needed
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ describe("DNS Node Discovery [live data]", function () {
|
||||
});
|
||||
|
||||
it(`should use DNS peer discovery with light client`, async function () {
|
||||
this.timeout(100000);
|
||||
this.timeout(100_000);
|
||||
const maxQuantity = 3;
|
||||
|
||||
const nodeRequirements = {
|
||||
|
@ -304,13 +304,10 @@ describe("Waku Store, general", function () {
|
||||
for await (const msg of query) {
|
||||
if (msg) {
|
||||
messages.push(msg as DecodedMessage);
|
||||
console.log(bytesToUtf8(msg.payload!));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(messages.length);
|
||||
|
||||
// Messages are ordered from oldest to latest within a page (1 page query)
|
||||
expect(bytesToUtf8(messages[0].payload!)).to.eq(asymText);
|
||||
expect(bytesToUtf8(messages[1].payload!)).to.eq(symText);
|
||||
|
Loading…
x
Reference in New Issue
Block a user