Skip to content

Commit

Permalink
Fix flaky tests (#644)
Browse files Browse the repository at this point in the history
Includes the following:
* Fix SchemaValidationTest
* Fix unhandled promise rejection in near cache repairing task
  • Loading branch information
puzpuzpuz authored Oct 23, 2020
1 parent 3a273b1 commit cd1f7d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/nearcache/MetadataFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class MetadataFetcher {

private getObjectNames(handlers: Map<string, RepairingHandler>): string[] {
const names: string[] = [];
handlers.forEach((handler: RepairingHandler) => {
handlers.forEach((handler) => {
names.push(handler.getName());
});
return names;
Expand Down
16 changes: 10 additions & 6 deletions src/nearcache/RepairingTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ export class RepairingTask {
this.updateLastKnownStaleSequences(handler);
}
});
this.metadataFetcher.fetchMetadata(this.handlers);
this.metadataFetcher.fetchMetadata(this.handlers)
.catch((err) => {
this.logger.debug('RepairingTask', 'Anti entropy task could not fetch metadata. '
+ 'Going to retry later.', err);
});
} else {
this.shutdown();
this.logger.debug('RepairingTask', 'Anti entropy task was on although client was not running.' +
'Anti entropy task was shutdown forcibly.');
this.logger.debug('RepairingTask', 'Anti entropy task was on although client was not running. '
+ 'Anti entropy task was shutdown forcibly.');
}
}

Expand Down Expand Up @@ -131,9 +135,9 @@ export class RepairingTask {
if (seconds === 0 || seconds >= this.minAllowedReconciliationSeconds) {
return seconds * 1000;
} else {
const message = 'Reconciliation interval can be at least ' + this.minAllowedReconciliationSeconds + ' seconds ' +
'if not 0. Configured interval is ' + seconds + ' seconds. ' +
'Note: configuring a value of 0 seconds disables the reconciliation task.';
const message = 'Reconciliation interval can be at least ' + this.minAllowedReconciliationSeconds
+ ' seconds if not 0. Configured interval is ' + seconds + ' seconds. '
+ 'Note: configuring a value of 0 seconds disables the reconciliation task.';
throw new RangeError(message);
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/config/SchemaValidationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('SchemaValidationTest', function () {

it('invalid configuration is caught by the validator', function () {
const invalidJson = fs.readFileSync(path.resolve(__dirname, 'configurations/invalid.json'), 'utf8');
expect(validateCandidate(invalidJson).errors[0]).to.exist.with.property('message', 'must have a minimum value of 1000');
const result = validateCandidate(invalidJson);
expect(result.errors[0]).to.exist.with.property('message');
expect(result.errors[0].message).to.have.string('1000');
});
});

0 comments on commit cd1f7d0

Please sign in to comment.