Skip to content

Commit de67879

Browse files
committed
test: Make loop stop wait time configurable so tests run faster/more stable
1 parent 9d0cf8f commit de67879

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/backend/scrobblers/AbstractScrobbleClient.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
9494

9595
scrobbleDelay: number = 1000;
9696
scrobbleSleep: number = 2000;
97+
scrobbleWaitStopInterval: number = 2000;
9798
scrobbleRetries: number = 0;
9899
scrobbling: boolean = false;
99100
userScrobblingStopSignal: undefined | any;
@@ -626,11 +627,11 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
626627
return;
627628
}
628629
this.userScrobblingStopSignal = true;
629-
let secsPassed = 0;
630-
while(this.userScrobblingStopSignal !== undefined && secsPassed < 10) {
631-
await sleep(2000);
632-
secsPassed += 2;
633-
this.logger.verbose(`Waiting for scrobble processing stop signal to be acknowledged (waited ${secsPassed}s)`);
630+
let timePasssed = 0;
631+
while(this.userScrobblingStopSignal !== undefined && timePasssed < (this.scrobbleWaitStopInterval * 10)) {
632+
await sleep(this.scrobbleWaitStopInterval);
633+
timePasssed += this.scrobbleWaitStopInterval;
634+
this.logger.verbose(`Waiting for scrobble processing stop signal to be acknowledged (waited ${timePasssed}ms)`);
634635
}
635636
if(this.userScrobblingStopSignal !== undefined) {
636637
this.logger.warn('Could not stop scrobble processing! Or signal was lost :(');

src/backend/tests/scrobbler/TestScrobbler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class TestScrobbler extends AbstractScrobbleClient {
2121
this.getScrobblesForTimeRange = async (_) => this.testRecentScrobbles;
2222
this.scrobbleDelay = 10;
2323
this.scrobbleSleep = 20;
24+
this.scrobbleWaitStopInterval = 20;
2425
}
2526

2627
doScrobble(playObj: PlayObject) {

0 commit comments

Comments
 (0)