Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retry-limiter

Package Overview
Dependencies
Maintainers
9
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retry-limiter - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/constants.js

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

## [3.3.0](https://github.com/gemini-testing/retry-limiter/compare/v3.2.0...v3.3.0) (2019-09-05)
### Features
* add disable retries for a given duration of tests ([1c9d543](https://github.com/gemini-testing/retry-limiter/commit/1c9d543))
## [3.2.0](https://github.com/gemini-testing/retry-limiter/compare/v3.1.1...v3.2.0) (2019-07-03)

@@ -7,0 +16,0 @@

8

gemini.js

@@ -6,3 +6,3 @@ 'use strict';

const parseOpts = require('./lib/plugin-opts');
const RetryLimiter = require('./lib/retry-limiter');
const Limiter = require('./lib/limiter');

@@ -18,9 +18,9 @@ module.exports = (gemini, opts) => {

let retryLimiter;
let limiter;
gemini.on(gemini.events.BEGIN, (data) => {
retryLimiter = RetryLimiter.create(opts.limit, getTotalTestsCount(data.suiteCollection));
limiter = Limiter.create({limit: opts.limit}, getTotalTestsCount(data.suiteCollection));
});
gemini.on(gemini.events.RETRY, function retryCallback() {
if (!retryLimiter.exceedLimit()) {
if (!limiter.exceedRetriesLimit()) {
return;

@@ -27,0 +27,0 @@ }

@@ -5,3 +5,3 @@ 'use strict';

const parseOpts = require('./lib/plugin-opts');
const RetryLimiter = require('./lib/retry-limiter');
const Limiter = require('./lib/limiter');
const logger = require('./lib/logger');

@@ -21,3 +21,3 @@

let retryLimiter;
let limiter;

@@ -28,14 +28,14 @@ hermione.on(hermione.events.AFTER_TESTS_READ, (collection) => {

retryLimiter = RetryLimiter.create(opts.limit, totalTestsCount);
limiter = Limiter.create(totalTestsCount, {limit: opts.limit, timeLimit: opts.timeLimit});
});
hermione.on(hermione.events.RETRY, function retryCallback() {
if (!retryLimiter.exceedLimit()) {
return;
}
if (Number.isFinite(opts.timeLimit)) {
logger.info(`will stop retrying tests after ${opts.timeLimit} seconds`);
configDecorator.disableRetries();
hermione.removeListener(hermione.events.RETRY, retryCallback);
});
hermione.once(hermione.events.TEST_BEGIN, () => limiter.startCountdown());
hermione.on(hermione.events.TEST_BEGIN, testBeginCallback);
}
hermione.on(hermione.events.RETRY, retryCallback);
if (Number.isFinite(opts.setRetriesOnTestFail)) {

@@ -45,2 +45,16 @@ logger.info(`will set retries to ${opts.setRetriesOnTestFail} after the first failed test`);

}
function testBeginCallback() {
limiter.exceedTimeLimit() && disableRetries();
}
function retryCallback() {
limiter.exceedRetriesLimit() && disableRetries();
}
function disableRetries() {
configDecorator.disableRetries();
hermione.removeListener(hermione.events.TEST_BEGIN, testBeginCallback);
hermione.removeListener(hermione.events.RETRY, retryCallback);
}
};

@@ -33,3 +33,9 @@ 'use strict';

parseCli: Number,
validate: (value) => !isNonNegativeInteger(value) && value !== Infinity && thr('Option "setRetriesOnTestFail" must be a non negative integer or "Infinity"')
validate: (value) => !isNonNegativeIntegerOrInfinity(value) && thr('Option "setRetriesOnTestFail" must be a non negative integer or "Infinity"')
}),
timeLimit: option({
defaultValue: Infinity,
parseEnv: Number,
parseCli: Number,
validate: (value) => !isNonNegativeIntegerOrInfinity(value) && thr('Option "timeLimit" must be a non negative integer or "Infinity"')
})

@@ -47,4 +53,4 @@ }), {envPrefix: ENV_PREFIX, cliPrefix: CLI_PREFIX});

function isNonNegativeInteger(value) {
return value >= 0 && Number.isInteger(value);
function isNonNegativeIntegerOrInfinity(value) {
return value >= 0 && Number.isInteger(value) || value === Infinity;
}
{
"name": "retry-limiter",
"version": "3.2.0",
"version": "3.3.0",
"description": "Plugin for gemini and hermione to disable retries at runtime",

@@ -5,0 +5,0 @@ "scripts": {

@@ -7,3 +7,3 @@ # retry-limiter [![Build Status](https://travis-ci.org/gemini-testing/retry-limiter.svg?branch=master)](https://travis-ci.org/gemini-testing/retry-limiter)

Plugin sets retries threshold. If it’s exceeded test will or will not be retried based on the result of `shouldRetry` function in config.
Plugin sets retries and duration threshold. If it’s exceeded test will or will not be retried based on the result of `shouldRetry` function in config.

@@ -26,4 +26,8 @@ For Gemini the rule is: if the test ends without result (nor `equal:false` nor `equal:true`) test will be retried if it’s attempts not exceeded.

* **limit** (optional) `Number` – number in range from 0 to 1; if retries count to a total number of tests exceed the specified limit all next tests will be run without retries; default `1`.
* **setRetriesOnTestFail** (optional) `Number` – set retries to the given value after the first test fail; default `Infinity` (retries will not be reset). **Option is supported only in hermione**.
#### Hermione only
* **setRetriesOnTestFail** (optional) `Number` – set retries to the given value after the first test fail; default `Infinity` (retries will not be reset).
* **timeLimit** (optional) `Number` - time in seconds; if test duration exceeds the specified limit all next tests will be run without retries; default `Infinity`.
### Gemini

@@ -52,3 +56,4 @@

limit: 0.3,
setRetriesOnTestFail: 1
setRetriesOnTestFail: 1,
timeLimit: 600
}

@@ -55,0 +60,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc