Skip to content

Commit

Permalink
Fix some canary issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Bret Ambrose committed Dec 1, 2023
1 parent a91e55a commit 69ce61f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions canary/mqtt5/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ interface CanaryContext {
}

function sleep(millisecond: number) {
return new Promise((resolve) => setInterval(resolve, millisecond));
return new Promise((resolve) => setTimeout(resolve, millisecond));
}

function getRandomIndex(clients : mqtt5.Mqtt5Client[]): number
Expand Down Expand Up @@ -192,7 +192,7 @@ async function runCanary(testContext: TestContext, mqttStats: CanaryMqttStatisti
};

// Start clients
context.clients.forEach( async client => {
for (let client of context.clients) {
client.start();
const connectionSuccess = once(client, "connectionSuccess");

Expand All @@ -205,7 +205,7 @@ async function runCanary(testContext: TestContext, mqttStats: CanaryMqttStatisti
});
// setup empty subscription string array
context.subscriptions.push(new Array());
});
}

let operationTable = [
{ weight : 1, op: async () => { await doSubscribe(context); }},
Expand All @@ -214,7 +214,7 @@ async function runCanary(testContext: TestContext, mqttStats: CanaryMqttStatisti
{ weight : 20, op: async () => { await doPublish(context, mqtt5.QoS.AtLeastOnce); }}
];

var weightedOperations = operationTable.map(function (operation) {
let weightedOperations = operationTable.map(function (operation) {
return operation.weight;
});

Expand All @@ -232,13 +232,12 @@ async function runCanary(testContext: TestContext, mqttStats: CanaryMqttStatisti


// Stop and close clients
context.clients.forEach( async client => {
for (let client of context.clients) {
const stopped = once(client, "stopped");
client.stop();
await stopped;
client.close();
});

}
}

async function main(args : Args){
Expand Down

0 comments on commit 69ce61f

Please sign in to comment.