@applitools/docker-compose-mocha
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -57,3 +57,4 @@ // @flow | ||
{ startOnlyTheseServices, envName, envVars, | ||
healthCheck, cleanUp, containerCleanUp, shouldPullImages = true, brutallyKill = false } | ||
healthCheck, cleanUp, containerCleanUp, shouldPullImages = true, brutallyKill = false, | ||
containerRetentionInMinutes } | ||
/* :DockerComposeToolOptions */ = {})/* : string */ { | ||
@@ -73,3 +74,6 @@ const randomComposeEnv = envName | ||
if (performCleanup) { | ||
yield cleanupOrphanEnvironments(process.env.NODE_ENV === 'developement' || !process.env.NODE_ENV ? 1 : 5).catch(() => 1); | ||
// eslint-disable-next-line | ||
yield cleanupOrphanEnvironments(containerRetentionInMinutes == null | ||
? (process.env.NODE_ENV === 'developement' || !process.env.NODE_ENV ? 2 : 5) | ||
: containerRetentionInMinutes).catch(() => 1); | ||
} | ||
@@ -76,0 +80,0 @@ const onlyTheseServicesMessage = startOnlyTheseServices |
@@ -17,5 +17,2 @@ // @flow | ||
const divider = 'zzdivzz'; | ||
const containerRetentionInMinutes = process.env.CONTAINER_STALE_MIN === undefined ? | ||
0 : | ||
Number(process.env.CONTAINER_STALE_MIN); | ||
@@ -52,6 +49,5 @@ function getUnixTimestampNow() { | ||
if (decision) { | ||
console.log(`container named: ${o} is more than ${containerRetentionInMinutesParam || | ||
containerRetentionInMinutes} minutes old and will be cleaned up`); | ||
console.log(`container named: ${o} is more than ${containerRetentionInMinutesParam} minutes old and will be cleaned up`); | ||
} else { | ||
console.log(`container named: ${o} is fresh and will NOT be cleaned up`); | ||
console.log(`container named: ${o} is fresh and will NOT be cleaned up`, decision, containerRetentionInMinutesParam); | ||
} | ||
@@ -100,10 +96,9 @@ return decision; | ||
console.log('Performing orphan containers cleanup (from previous CI runs)..'); | ||
const minutesAgoInUnixTimestamp = containerRetentionInMinutes === 0 ? | ||
const minutesAgoInUnixTimestamp = containerRetentionInMinutesParam === 0 ? | ||
getUnixTimestampNow() : | ||
getUnixTimestampNow() - (60 * (containerRetentionInMinutesParam | ||
|| containerRetentionInMinutes)); | ||
getUnixTimestampNow() - (60 * containerRetentionInMinutesParam); | ||
const result = yield exec('docker ps --format "{{.ID}} {{.Names}}"'); | ||
const staleContainers = getStaleContainers(result.stdout, | ||
minutesAgoInUnixTimestamp, containerRetentionInMinutes); | ||
minutesAgoInUnixTimestamp, containerRetentionInMinutesParam); | ||
@@ -110,0 +105,0 @@ // Kill stale containers |
{ | ||
"name": "@applitools/docker-compose-mocha", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "Tool used for setting up an isolated environment for end to end testing / integration testing using Docker Compose", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,3 +58,3 @@ const { describe, it, before: b } = require('mocha'); | ||
.then(oldEnvironmentName => runAnEnvironment(pathToCompose) | ||
.then(() => checkOldEnvironmentWasCleaned(pathToCompose, oldEnvironmentName)))); | ||
.then(() => checkOldEnvironmentWasCleaned(pathToCompose, oldEnvironmentName)))); | ||
@@ -64,3 +64,3 @@ it('getLogsForService and should use envVar', coroutine(function* () { | ||
yield simulateMochaRun((before, after) => { | ||
envName = main.dockerComposeTool(before, after, pathToComposeForEnv, { envVars: { FILE_TO_TAIL: '/etc/hosts' } }); | ||
envName = main.dockerComposeTool(before, after, pathToComposeForEnv, { containerRetentionInMinutes: 0, envVars: { FILE_TO_TAIL: '/etc/hosts' } }); | ||
}, coroutine(function* () { | ||
@@ -67,0 +67,0 @@ const stdout = yield main.getLogsForService(envName, pathToComposeForEnv, 'dct_s1'); |
@@ -37,2 +37,3 @@ const chance = require('./../../lib/setup-environment-names-seed'); | ||
targetEnvName, | ||
containerRetentionInMinutes: 0, | ||
healthCheck: { | ||
@@ -121,2 +122,3 @@ state: true, | ||
containerCleanUp: false, | ||
containerRetentionInMinutes: 0, | ||
healthCheck: { | ||
@@ -149,2 +151,3 @@ state: true, | ||
cleanUp: false, | ||
containerRetentionInMinutes: 0, | ||
healthCheck: { | ||
@@ -151,0 +154,0 @@ state: true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
49578
837
11