Skip to content

Commit

Permalink
Fail if 'Serving on port' was not found within 60 seconds of polling …
Browse files Browse the repository at this point in the history
…COMPLETE log file. Print error, fail workflow, and print container log that lacked the required string
  • Loading branch information
david-rocca committed Oct 22, 2024
1 parent d9a77ee commit 3805723
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@ jobs:
docker compose --file docker/docker-compose.yml build
docker compose --file docker/docker-compose.yml up -d
- name: Sleep
run: bash -c "while ! docker compose --file docker/docker-compose.yml logs --tail=10 cveawg | grep -q 'Serving on port'; do sleep 1; done"
run: |
dockercompose="docker compose --file docker/docker-compose.yml"
attempts=60
while ! $dockercompose logs cveawg | grep -q 'Serving on port'; do
attempts=$(expr $attempts - 1)
if [ $($dockercompose ps --status running -q | wc -l) -eq 2 ] && [ $attempts -gt 0 ]; then
sleep 1
$dockercompose logs || true
continue
fi
$dockercompose ps || true
$dockercompose logs || true
echo "==== COULD NOT FIND 'Serving on port' in cveawg output OR one of the services died ====" 1>&2
exit 1
done
- name: Run Tests
run: docker compose -f docker/docker-compose.yml exec -T cveawg npm run test:integration
continue-on-error: false
1 change: 1 addition & 0 deletions docker/.docker-env.int-example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ MONGO_HOST=docdb
MONGO_PORT=27017
NODE_ENV=integration
PORT=3000
useAWSCert=false
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,25 @@ app.use((req, res, next) => {

console.log('Checking for AWS cert file')
const appEnv = process.env.NODE_ENV
console.log(appEnv)
var awsCERTFile = false
console.log('check')
console.log(process.env.useAWSCert)
if (process.env.useAWSCert.toLocaleLowerCase() === 'true') {
console.log('detecting env')
console.log(process.env.useAWSCert)
awsCERTFile = process.env.useAWSCert
} else {
awsCERTFile = config.has(`${appEnv}.useAWSCert`) ? config.get(`${appEnv}.useAWSCert`) : false
awsCERTFile = config.has(`${process.env}.useAWSCert`) ? config.get(`${process.env}.useAWSCert`) : false
console.log('HAS')
console.log(config.has(`${process.env}.useAWSCert`))
console.log('in if checker')
console.log(awsCERTFile)
}

// Connect to MongoDB database
const dbConnectionStr = dbUtils.getMongoConnectionString()
if (awsCERTFile && appEnv.toLocaleLowerCase() !== 'test') {
if (awsCERTFile && awsCERTFile.toLocaleLowerCase() === 'true' && appEnv.toLocaleLowerCase() !== 'test') {
const ca = [fs.readFileSync(path.join(__dirname, 'config/global-bundle.pem'))]
mongoose.connect(dbConnectionStr, {
useNewUrlParser: true,
Expand Down

0 comments on commit 3805723

Please sign in to comment.