Skip to content

Commit c06a703

Browse files
dianabarsanwitash
authored andcommitted
chore(#9169): build couchdb image for api integration tests (#9455)
Instead of downloading a pre-released couchdb image, we build the couchdb image to test api integration. The image gets built when publishing, so downloading all layers was required for a later step anyway. Removed one unused couchdb compose file. Added a missing callback in an ancient migration that caused tests to fail. #9169
1 parent a5dc0e4 commit c06a703

26 files changed

+42
-186
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ jobs:
5858
uses: actions/setup-node@v4
5959
with:
6060
node-version: ${{ env.NODE_VERSION }}
61-
- name: Couch Start
62-
run: ./scripts/ci/couch-start
6361
- name: Create logs directory
6462
run: mkdir tests/logs
6563
- run: npm ci

api/src/migrations/extract-person-contacts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const createPerson = function(id, callback) {
136136
.catch(() => {
137137
// we tried our best - log the details and exit
138138
logger.error(`Failed to restore contact on facility "${facilityId}", contact: ${JSON.stringify(oldContact)}`);
139+
callback();
139140
});
140141
};
141142

api/tests/integration/.mocharc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
process.env.COUCH_URL='http://admin:pass@localhost:5984/medic';
2+
3+
module.exports = {
4+
allowUncaught: false,
5+
color: true,
6+
checkLeaks: true,
7+
fullTrace: true,
8+
asyncOnly: false,
9+
spec: './api/tests/integration/**/*.js',
10+
timeout: 20000,
11+
reporter: 'spec',
12+
};

api/tests/integration/compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
couchdb:
3+
build: ../../../couchdb
4+
ports:
5+
- "5984:5984"
6+
environment:
7+
- "COUCHDB_USER=admin"
8+
- "COUCHDB_PASSWORD=pass"
9+
- "SVC_NAME=couchdb"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -eu
2+
3+
set -e
4+
5+
docker compose -f ./api/tests/integration/compose.yml up -d
6+
echo "Starting CouchDB"
7+
8+
until nc -z localhost 5984; do sleep 1; done
9+
sleep 2
10+
echo "CouchDB Started"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -eu
2+
set -e
3+
docker compose -f ./api/tests/integration/compose.yml down --remove-orphans

api/tests/integration/migrations/add-contact-id-to-user-docs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const getUserDoc = async (id) => db.users.get(id);
3333
describe('add-contact-id-to-user migration', function() {
3434
afterEach(() => {
3535
sinon.restore();
36-
utils.tearDown();
3736
});
3837

3938
it('migrates the contact_id value from user-settings to _users for all users', async () => {

api/tests/integration/migrations/add-meta-validate-doc-update.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ const assertUserDb = (name) => {
5353
};
5454

5555
describe('add-meta-validate-doc-update migration', () => {
56-
afterEach(() => utils.tearDown());
57-
5856
it('should work with no user dbs', () => {
5957
return utils
6058
.initDb([])

api/tests/integration/migrations/add-uuid-to-scheduled-tasks.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ const utils = require('./utils');
33
const UUID_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
44

55
describe('add-uuid-to-scheduled-tasks migration', function() {
6-
afterEach(function() {
7-
return utils.tearDown();
8-
});
9-
106
const FUTURE = moment().add(1, 'week').toISOString();
117
const PAST = moment().subtract(1, 'week').toISOString();
128

api/tests/integration/migrations/clean-up-corrupted-users.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
const utils = require('./utils');
22

33
describe('clean-up-corrupted-users migration', function() {
4-
afterEach(function() {
5-
return utils.tearDown();
6-
});
7-
84
it('cleans up users with $promise and $resolved fields', function() {
95
// given
106
return utils.initDb([

0 commit comments

Comments
 (0)