diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 1f5efbd64..e33a545bf 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -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 \ No newline at end of file diff --git a/docker/.docker-env.int-example b/docker/.docker-env.int-example index 924f472ab..51b85b36e 100644 --- a/docker/.docker-env.int-example +++ b/docker/.docker-env.int-example @@ -2,3 +2,4 @@ MONGO_HOST=docdb MONGO_PORT=27017 NODE_ENV=integration PORT=3000 +useAWSCert=false \ No newline at end of file diff --git a/src/index.js b/src/index.js index 69a92b55f..322c6ce9e 100644 --- a/src/index.js +++ b/src/index.js @@ -50,20 +50,28 @@ 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('GET') + console.log(config.get(`${process.env}.useAWSCert`)) + console.log(`${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.toLocaleLowerCase() === 'true' && appEnv.toLocaleLowerCase() !== 'test') { const ca = [fs.readFileSync(path.join(__dirname, 'config/global-bundle.pem'))] mongoose.connect(dbConnectionStr, { useNewUrlParser: true,