Skip to content

Commit b31e315

Browse files
committed
REALMC-4874 - add sync progress to admin api
1 parent 2390d46 commit b31e315

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

.evg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ buildvariants:
321321
- rhel70
322322
expansions:
323323
go_url: "https://dl.google.com/go/go1.13.linux-amd64.tar.gz"
324-
mongodb_url: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.2.tgz
324+
mongodb_url: https://downloads.mongodb.com/linux/mongodb-linux-x86_64-enterprise-rhel70-4.4.0-rc3.tgz
325325
server_stitch_lib_url: 'https://s3.amazonaws.com/mciuploads/mongodb-mongo-master/stitch-support/enterprise-rhel-70-64-bit/18ca0d551818d6c8274358b8e6444640bec93c88/stitch-support-4.3.0-120-g18ca0d5.tgz'
326326
transpiler_target: node8-linux
327327
node_url: "https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz"

src/admin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ export class StitchAdminClient extends StitchClient {
497497
};
498498
},
499499
data: (params = {}) => api._get(`${syncUrl}/data`, params),
500-
patchSchemas: data => api._patch(`${syncUrl}/schemas`, { body: JSON.stringify(data) })
500+
patchSchemas: data => api._patch(`${syncUrl}/schemas`, { body: JSON.stringify(data) }),
501+
progress: () => api._get(`${syncUrl}/progress`)
501502
};
502503
}
503504
};

test/admin/sync.test.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,38 +225,25 @@ describe('Sync', () => {
225225
expect(deployResult.status).toBe('created');
226226
});
227227

228-
229-
it('can use the allow_destructive_changes param to do a destructive rule create', async() => {
228+
it('can create a rule with invalid sync schema', async() => {
230229
const syncService = await createSampleMongodbSyncService(services);
231230

232231
const schemaInvalidatingRule = {
233232
database: 'db',
234233
collection: 'coll',
235234
config: {
236235
schema: {
237-
title: 'double',
238236
properties: {
239237
_id: { bsonType: 'objectId' },
240238
key: { bsonType: 'string' },
241-
obj: {
242-
bsonType: 'object',
243-
title: 'double'
244-
}
239+
bad: { bsonType: 'null' }
245240
}
246241
}
247242
}
248243
};
249244

250-
let stitchError;
251-
try {
252-
await addRuleToMongodbService(services, syncService, schemaInvalidatingRule );
253-
} catch (e) {
254-
stitchError = e;
255-
}
256-
expect(stitchError.code).toBe('InvalidSyncSchema');
257-
258-
const createResult = await addRuleToMongodbService(services, syncService, schemaInvalidatingRule, { allow_destructive_changes: true });
259-
expect(createResult).toBeTruthy();
245+
const ruleResponse = await addRuleToMongodbService(services, syncService, schemaInvalidatingRule );
246+
expect(ruleResponse._id).toBeTruthy();
260247
});
261248

262249
it('can use the allow_destructive_changes param to do a destructive rule change', async() => {
@@ -332,4 +319,22 @@ describe('Sync', () => {
332319
expect(updateResult.status).toBe(204);
333320
});
334321
});
322+
323+
describe('progress', () => {
324+
it('should 404 if there is no active sync service', async() => {
325+
let errorCode;
326+
try {
327+
await sync.progress();
328+
} catch (e) {
329+
errorCode = e.response.status;
330+
}
331+
expect(errorCode).toBe(404);
332+
});
333+
334+
it('should return a map of progress if there is an active sync service', async() => {
335+
await createSampleMongodbSyncService(services);
336+
const progressResponse = await sync.progress();
337+
expect(progressResponse.progress).toEqual({});
338+
});
339+
});
335340
});

0 commit comments

Comments
 (0)