@webex/plugin-meetings 3.12.0-webex-services-ready.3 → 3.12.0-webex-services-ready.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aiEnableRequest/index.js +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/events.js +29 -14
- package/dist/breakouts/events.js.map +1 -1
- package/dist/breakouts/index.js +65 -2
- package/dist/breakouts/index.js.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +193 -23
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/index.js +141 -56
- package/dist/locus-info/index.js.map +1 -1
- package/dist/media/properties.js +3 -5
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/index.js +351 -52
- package/dist/meeting/index.js.map +1 -1
- package/dist/meetings/index.js +25 -0
- package/dist/meetings/index.js.map +1 -1
- package/dist/metrics/constants.js +3 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/roap/turnDiscovery.js +8 -1
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/hashTree/hashTreeParser.d.ts +51 -3
- package/dist/types/locus-info/index.d.ts +19 -4
- package/dist/types/media/properties.d.ts +5 -2
- package/dist/types/meeting/index.d.ts +63 -1
- package/dist/types/meetings/index.d.ts +8 -0
- package/dist/types/metrics/constants.d.ts +2 -0
- package/dist/webinar/index.js +4 -4
- package/dist/webinar/index.js.map +1 -1
- package/package.json +23 -23
- package/src/breakouts/events.ts +33 -11
- package/src/breakouts/index.ts +79 -1
- package/src/constants.ts +1 -0
- package/src/hashTree/hashTreeParser.ts +254 -18
- package/src/locus-info/index.ts +143 -51
- package/src/media/properties.ts +7 -3
- package/src/meeting/index.ts +329 -25
- package/src/meetings/index.ts +35 -1
- package/src/metrics/constants.ts +2 -0
- package/src/roap/turnDiscovery.ts +9 -1
- package/src/webinar/index.ts +2 -2
- package/test/unit/spec/breakouts/events.ts +120 -2
- package/test/unit/spec/breakouts/index.ts +142 -2
- package/test/unit/spec/hashTree/hashTreeParser.ts +556 -3
- package/test/unit/spec/locus-info/index.js +148 -5
- package/test/unit/spec/media/properties.ts +23 -23
- package/test/unit/spec/meeting/index.js +832 -126
- package/test/unit/spec/meetings/index.js +116 -12
- package/test/unit/spec/roap/turnDiscovery.ts +20 -0
- package/test/unit/spec/webinar/index.ts +3 -3
|
@@ -13,6 +13,7 @@ import testUtils from '@webex/plugin-meetings/test/utils/testUtils';
|
|
|
13
13
|
import { some } from 'lodash';
|
|
14
14
|
import Metrics from '@webex/plugin-meetings/src/metrics';
|
|
15
15
|
import BEHAVIORAL_METRICS from '@webex/plugin-meetings/src/metrics/constants';
|
|
16
|
+
import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
|
|
16
17
|
|
|
17
18
|
const visibleDataSetsUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/97d64a5f/visibleDataSets';
|
|
18
19
|
|
|
@@ -159,6 +160,7 @@ describe('HashTreeParser', () => {
|
|
|
159
160
|
let callback: sinon.SinonStub;
|
|
160
161
|
let mathRandomStub: sinon.SinonStub;
|
|
161
162
|
let metricsStub: sinon.SinonStub;
|
|
163
|
+
let loggerInfoStub: sinon.SinonStub;
|
|
162
164
|
|
|
163
165
|
beforeEach(() => {
|
|
164
166
|
clock = sinon.useFakeTimers();
|
|
@@ -166,26 +168,36 @@ describe('HashTreeParser', () => {
|
|
|
166
168
|
callback = sinon.stub();
|
|
167
169
|
mathRandomStub = sinon.stub(Math, 'random').returns(0);
|
|
168
170
|
metricsStub = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
171
|
+
loggerInfoStub = sinon.stub(LoggerProxy.logger, 'info');
|
|
169
172
|
});
|
|
170
173
|
afterEach(() => {
|
|
171
174
|
clock.restore();
|
|
172
175
|
mathRandomStub.restore();
|
|
173
176
|
metricsStub.restore();
|
|
177
|
+
loggerInfoStub.restore();
|
|
174
178
|
});
|
|
175
179
|
|
|
176
180
|
// Helper to create a HashTreeParser instance with common defaults
|
|
177
181
|
function createHashTreeParser(
|
|
178
182
|
initialLocus: any = exampleInitialLocus,
|
|
179
183
|
metadata: any = exampleMetadata,
|
|
180
|
-
excludedDataSets?: string[]
|
|
184
|
+
excludedDataSets?: string[],
|
|
185
|
+
syncLatencyTracker?: any,
|
|
186
|
+
syncLatencyMeetingId = 'meeting-1',
|
|
187
|
+
generateTrackingId?: any
|
|
181
188
|
) {
|
|
182
189
|
return new HashTreeParser({
|
|
183
190
|
initialLocus,
|
|
184
191
|
metadata,
|
|
185
192
|
webexRequest,
|
|
186
|
-
|
|
193
|
+
callbacks: {
|
|
194
|
+
locusInfoUpdateCallback: callback,
|
|
195
|
+
syncLatencyTracker,
|
|
196
|
+
generateTrackingId,
|
|
197
|
+
},
|
|
187
198
|
debugId: 'test',
|
|
188
199
|
excludedDataSets,
|
|
200
|
+
syncLatencyMeetingId,
|
|
189
201
|
});
|
|
190
202
|
}
|
|
191
203
|
|
|
@@ -226,7 +238,7 @@ describe('HashTreeParser', () => {
|
|
|
226
238
|
}
|
|
227
239
|
|
|
228
240
|
// Helper to mock sendSyncRequestToLocus response
|
|
229
|
-
function mockSendSyncRequestResponse(dataSetUrl: string, response: any) {
|
|
241
|
+
function mockSendSyncRequestResponse(dataSetUrl: string, response: any, headers?: any) {
|
|
230
242
|
webexRequest
|
|
231
243
|
.withArgs(
|
|
232
244
|
sinon.match({
|
|
@@ -236,6 +248,7 @@ describe('HashTreeParser', () => {
|
|
|
236
248
|
)
|
|
237
249
|
.resolves({
|
|
238
250
|
body: response,
|
|
251
|
+
headers,
|
|
239
252
|
});
|
|
240
253
|
}
|
|
241
254
|
|
|
@@ -1772,6 +1785,118 @@ describe('HashTreeParser', () => {
|
|
|
1772
1785
|
});
|
|
1773
1786
|
});
|
|
1774
1787
|
|
|
1788
|
+
it('filters a "main" sync response down to the requested dataset, ignoring shared datasets like "unjoined"', async () => {
|
|
1789
|
+
// Set up a parser where both "main" and "unjoined" are visible and share the core locus
|
|
1790
|
+
// element (they always advance to the same version on the server).
|
|
1791
|
+
const sharedInitialLocus = {
|
|
1792
|
+
dataSets: [createDataSet('main', 16, 1000), createDataSet('unjoined', 16, 1000)],
|
|
1793
|
+
locus: {
|
|
1794
|
+
url: locusUrl,
|
|
1795
|
+
htMeta: {
|
|
1796
|
+
elementId: {type: 'locus', id: 0, version: 200},
|
|
1797
|
+
dataSetNames: ['main', 'unjoined'],
|
|
1798
|
+
},
|
|
1799
|
+
links: {resources: {visibleDataSets: {url: visibleDataSetsUrl}}},
|
|
1800
|
+
participants: [],
|
|
1801
|
+
},
|
|
1802
|
+
};
|
|
1803
|
+
const sharedMetadata = {
|
|
1804
|
+
htMeta: {elementId: {type: 'metadata', id: 5, version: 50}, dataSetNames: ['self']},
|
|
1805
|
+
visibleDataSets: [
|
|
1806
|
+
{name: 'main', url: `${locusUrl}/datasets/main`},
|
|
1807
|
+
{name: 'unjoined', url: `${locusUrl}/datasets/unjoined`},
|
|
1808
|
+
],
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
const parser = createHashTreeParser(sharedInitialLocus, sharedMetadata);
|
|
1812
|
+
|
|
1813
|
+
// both datasets have their own hash tree, sharing the locus element
|
|
1814
|
+
assert.exists(parser.dataSets.main.hashTree);
|
|
1815
|
+
assert.exists(parser.dataSets.unjoined.hashTree);
|
|
1816
|
+
|
|
1817
|
+
// start the sync timer with a normal "main" message (mismatched root hash)
|
|
1818
|
+
const message = {
|
|
1819
|
+
dataSets: [{...createDataSet('main', 16, 1100), root: 'a'.repeat(32)}],
|
|
1820
|
+
visibleDataSetsUrl,
|
|
1821
|
+
locusUrl,
|
|
1822
|
+
locusStateElements: [
|
|
1823
|
+
{
|
|
1824
|
+
htMeta: {
|
|
1825
|
+
elementId: {type: 'locus' as const, id: 0, version: 201},
|
|
1826
|
+
dataSetNames: ['main'],
|
|
1827
|
+
},
|
|
1828
|
+
data: {info: {id: 'initial-update'}},
|
|
1829
|
+
},
|
|
1830
|
+
],
|
|
1831
|
+
};
|
|
1832
|
+
parser.handleMessage(message, 'initial message');
|
|
1833
|
+
assert.calledOnce(callback);
|
|
1834
|
+
callback.resetHistory();
|
|
1835
|
+
|
|
1836
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
1837
|
+
|
|
1838
|
+
mockGetHashesFromLocusResponse(
|
|
1839
|
+
mainDataSetUrl,
|
|
1840
|
+
new Array(16).fill('0'.repeat(32)),
|
|
1841
|
+
createDataSet('main', 16, 1101)
|
|
1842
|
+
);
|
|
1843
|
+
|
|
1844
|
+
// The sync response for "main" also carries the "unjoined" dataset, the shared locus
|
|
1845
|
+
// element tagged with both datasets, and an "unjoined"-only element - all of which must
|
|
1846
|
+
// be filtered out so that only the requested "main" data is processed.
|
|
1847
|
+
const mainSyncDataSet = createDataSet('main', 16, 1101);
|
|
1848
|
+
mainSyncDataSet.root = parser.dataSets.main.hashTree.getRootHash();
|
|
1849
|
+
mockSendSyncRequestResponse(mainDataSetUrl, {
|
|
1850
|
+
dataSets: [mainSyncDataSet, createDataSet('unjoined', 16, 1101)],
|
|
1851
|
+
visibleDataSetsUrl,
|
|
1852
|
+
locusUrl,
|
|
1853
|
+
locusStateElements: [
|
|
1854
|
+
{
|
|
1855
|
+
htMeta: {
|
|
1856
|
+
elementId: {type: 'locus' as const, id: 0, version: 202},
|
|
1857
|
+
dataSetNames: ['main', 'unjoined'],
|
|
1858
|
+
},
|
|
1859
|
+
data: {info: {id: 'synced-shared-locus'}},
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
htMeta: {
|
|
1863
|
+
elementId: {type: 'participant' as const, id: 99, version: 500},
|
|
1864
|
+
dataSetNames: ['unjoined'],
|
|
1865
|
+
},
|
|
1866
|
+
data: {person: {name: 'unjoined-only'}},
|
|
1867
|
+
},
|
|
1868
|
+
],
|
|
1869
|
+
});
|
|
1870
|
+
|
|
1871
|
+
await clock.tickAsync(1000);
|
|
1872
|
+
|
|
1873
|
+
// the "unjoined" dataset info must NOT be updated from a "main" sync response
|
|
1874
|
+
expect(parser.dataSets.unjoined.version).to.equal(1000);
|
|
1875
|
+
|
|
1876
|
+
// the shared locus element is reported exactly once (not once per dataset), and the
|
|
1877
|
+
// "unjoined"-only element is not reported at all
|
|
1878
|
+
assert.calledOnceWithExactly(callback, {
|
|
1879
|
+
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
1880
|
+
updatedObjects: [
|
|
1881
|
+
{
|
|
1882
|
+
htMeta: {
|
|
1883
|
+
elementId: {type: 'locus', id: 0, version: 202},
|
|
1884
|
+
dataSetNames: ['main', 'unjoined'],
|
|
1885
|
+
},
|
|
1886
|
+
data: {info: {id: 'synced-shared-locus'}},
|
|
1887
|
+
},
|
|
1888
|
+
],
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
// the filtered-out dataset and element are logged
|
|
1892
|
+
assert.calledWith(
|
|
1893
|
+
loggerInfoStub,
|
|
1894
|
+
sinon.match(
|
|
1895
|
+
'keeping only dataset "main", filtering out datasets: [unjoined:1101], elements: [participant:99:500]'
|
|
1896
|
+
)
|
|
1897
|
+
);
|
|
1898
|
+
});
|
|
1899
|
+
|
|
1775
1900
|
describe('emits MEETING_ENDED when 409/2403004 is returned', () => {
|
|
1776
1901
|
it('when /hashtree returns 409', async () => {
|
|
1777
1902
|
const parser = createHashTreeParser();
|
|
@@ -2384,6 +2509,7 @@ describe('HashTreeParser', () => {
|
|
|
2384
2509
|
reason: 'sync failed',
|
|
2385
2510
|
});
|
|
2386
2511
|
});
|
|
2512
|
+
|
|
2387
2513
|
});
|
|
2388
2514
|
|
|
2389
2515
|
describe('handles visible data sets changes correctly', () => {
|
|
@@ -3097,6 +3223,106 @@ describe('HashTreeParser', () => {
|
|
|
3097
3223
|
);
|
|
3098
3224
|
});
|
|
3099
3225
|
|
|
3226
|
+
it('uses the watchdog random backoff when reporting sync metrics', async () => {
|
|
3227
|
+
const syncLatencyTracker = {
|
|
3228
|
+
saveLatency: sinon.stub(),
|
|
3229
|
+
saveTimestamp: sinon.stub(),
|
|
3230
|
+
getLocusSyncLatency: sinon.stub(),
|
|
3231
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
3232
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
3233
|
+
};
|
|
3234
|
+
const parser = createHashTreeParser(
|
|
3235
|
+
undefined,
|
|
3236
|
+
undefined,
|
|
3237
|
+
undefined,
|
|
3238
|
+
syncLatencyTracker
|
|
3239
|
+
);
|
|
3240
|
+
const heartbeatIntervalMs = 5000;
|
|
3241
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
3242
|
+
|
|
3243
|
+
mathRandomStub.onFirstCall().returns(0.1); // root-hash timer backoff = 10ms
|
|
3244
|
+
mathRandomStub.onSecondCall().returns(0.5); // watchdog backoff = 250ms
|
|
3245
|
+
mathRandomStub.returns(0);
|
|
3246
|
+
|
|
3247
|
+
parser.handleMessage(
|
|
3248
|
+
{
|
|
3249
|
+
dataSets: [
|
|
3250
|
+
{
|
|
3251
|
+
...createDataSet('main', 16, 1100),
|
|
3252
|
+
root: parser.dataSets.main.hashTree.getRootHash(),
|
|
3253
|
+
},
|
|
3254
|
+
],
|
|
3255
|
+
visibleDataSetsUrl,
|
|
3256
|
+
locusUrl,
|
|
3257
|
+
},
|
|
3258
|
+
'initial heartbeat'
|
|
3259
|
+
);
|
|
3260
|
+
|
|
3261
|
+
mockGetHashesFromLocusResponse(
|
|
3262
|
+
mainDataSetUrl,
|
|
3263
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
3264
|
+
createDataSet('main', 16, 1101)
|
|
3265
|
+
);
|
|
3266
|
+
mockSendSyncRequestResponse(mainDataSetUrl, null);
|
|
3267
|
+
|
|
3268
|
+
await clock.tickAsync(heartbeatIntervalMs + 250);
|
|
3269
|
+
|
|
3270
|
+
assert.calledWithExactly(
|
|
3271
|
+
syncLatencyTracker.saveLatency,
|
|
3272
|
+
'internal.client.locus.sync.random.backoff',
|
|
3273
|
+
250,
|
|
3274
|
+
{
|
|
3275
|
+
meetingId: 'meeting-1',
|
|
3276
|
+
dataSetName: 'main',
|
|
3277
|
+
}
|
|
3278
|
+
);
|
|
3279
|
+
});
|
|
3280
|
+
|
|
3281
|
+
it('uses the root sync random backoff when root timer fires before watchdog', async () => {
|
|
3282
|
+
const syncLatencyTracker = {
|
|
3283
|
+
saveLatency: sinon.stub(),
|
|
3284
|
+
saveTimestamp: sinon.stub(),
|
|
3285
|
+
getLocusSyncLatency: sinon.stub(),
|
|
3286
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
3287
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
3288
|
+
};
|
|
3289
|
+
const parser = createHashTreeParser(
|
|
3290
|
+
undefined,
|
|
3291
|
+
undefined,
|
|
3292
|
+
undefined,
|
|
3293
|
+
syncLatencyTracker
|
|
3294
|
+
);
|
|
3295
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
3296
|
+
|
|
3297
|
+
mathRandomStub.onFirstCall().returns(0.1); // root-hash timer backoff = 10ms
|
|
3298
|
+
mathRandomStub.onSecondCall().returns(0.5); // watchdog backoff = 250ms
|
|
3299
|
+
mathRandomStub.returns(0);
|
|
3300
|
+
|
|
3301
|
+
parser.handleMessage(
|
|
3302
|
+
createHeartbeatMessage('main', 16, 1100, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1'),
|
|
3303
|
+
'root mismatch heartbeat'
|
|
3304
|
+
);
|
|
3305
|
+
|
|
3306
|
+
mockGetHashesFromLocusResponse(
|
|
3307
|
+
mainDataSetUrl,
|
|
3308
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
3309
|
+
createDataSet('main', 16, 1101)
|
|
3310
|
+
);
|
|
3311
|
+
mockSendSyncRequestResponse(mainDataSetUrl, null);
|
|
3312
|
+
|
|
3313
|
+
await clock.tickAsync(1010);
|
|
3314
|
+
|
|
3315
|
+
assert.calledWithExactly(
|
|
3316
|
+
syncLatencyTracker.saveLatency,
|
|
3317
|
+
'internal.client.locus.sync.random.backoff',
|
|
3318
|
+
10,
|
|
3319
|
+
{
|
|
3320
|
+
meetingId: 'meeting-1',
|
|
3321
|
+
dataSetName: 'main',
|
|
3322
|
+
}
|
|
3323
|
+
);
|
|
3324
|
+
});
|
|
3325
|
+
|
|
3100
3326
|
it('calls POST sync directly for leafCount === 1 data sets', async () => {
|
|
3101
3327
|
const parser = createHashTreeParser();
|
|
3102
3328
|
const heartbeatIntervalMs = 5000;
|
|
@@ -4697,6 +4923,47 @@ describe('HashTreeParser', () => {
|
|
|
4697
4923
|
assert.neverCalledWith(webexRequest, sinon.match({method: 'GET', uri: `${selfUrl}/hashtree`}));
|
|
4698
4924
|
});
|
|
4699
4925
|
|
|
4926
|
+
it('uses the syncAll random backoff when reporting sync metrics', async () => {
|
|
4927
|
+
mathRandomStub.returns(0.5); // syncAll backoff = 0.5^2 * 1000 = 250ms
|
|
4928
|
+
|
|
4929
|
+
const syncLatencyTracker = {
|
|
4930
|
+
saveLatency: sinon.stub(),
|
|
4931
|
+
saveTimestamp: sinon.stub(),
|
|
4932
|
+
getLocusSyncLatency: sinon.stub(),
|
|
4933
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
4934
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
4935
|
+
};
|
|
4936
|
+
const parser = createHashTreeParser(
|
|
4937
|
+
undefined,
|
|
4938
|
+
undefined,
|
|
4939
|
+
['atd-unmuted'],
|
|
4940
|
+
syncLatencyTracker
|
|
4941
|
+
);
|
|
4942
|
+
const mainUrl = parser.dataSets.main.url;
|
|
4943
|
+
|
|
4944
|
+
mockGetHashesFromLocusResponse(
|
|
4945
|
+
mainUrl,
|
|
4946
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
4947
|
+
createDataSet('main', 16, 1100)
|
|
4948
|
+
);
|
|
4949
|
+
mockSendSyncRequestResponse(mainUrl, null);
|
|
4950
|
+
|
|
4951
|
+
const syncAllPromise = parser.syncAllDatasets({onlyLLM: true});
|
|
4952
|
+
|
|
4953
|
+
await clock.tickAsync(250);
|
|
4954
|
+
await syncAllPromise;
|
|
4955
|
+
|
|
4956
|
+
assert.calledWithExactly(
|
|
4957
|
+
syncLatencyTracker.saveLatency,
|
|
4958
|
+
'internal.client.locus.sync.random.backoff',
|
|
4959
|
+
250,
|
|
4960
|
+
{
|
|
4961
|
+
meetingId: 'meeting-1',
|
|
4962
|
+
dataSetName: 'main',
|
|
4963
|
+
}
|
|
4964
|
+
);
|
|
4965
|
+
});
|
|
4966
|
+
|
|
4700
4967
|
it('should upgrade scope from onlyLLM=true to all datasets when onlyLLM=false call arrives during backoff', async () => {
|
|
4701
4968
|
// Make Math.random return 1 so backoff = 1^2 * 1000 = 1000ms (non-zero delay for interleaving)
|
|
4702
4969
|
mathRandomStub.returns(1);
|
|
@@ -5325,4 +5592,290 @@ describe('HashTreeParser', () => {
|
|
|
5325
5592
|
expect(parser.dataSets).to.deep.equal({});
|
|
5326
5593
|
});
|
|
5327
5594
|
});
|
|
5595
|
+
|
|
5596
|
+
describe('#syncMetrics', () => {
|
|
5597
|
+
it('records sync latency timestamps when sync response has empty body', async () => {
|
|
5598
|
+
const syncLatencyTracker = {
|
|
5599
|
+
saveLatency: sinon.stub(),
|
|
5600
|
+
saveTimestamp: sinon.stub(),
|
|
5601
|
+
getLocusSyncLatency: sinon.stub(),
|
|
5602
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
5603
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
5604
|
+
};
|
|
5605
|
+
const parser = createHashTreeParser(
|
|
5606
|
+
undefined,
|
|
5607
|
+
undefined,
|
|
5608
|
+
undefined,
|
|
5609
|
+
syncLatencyTracker
|
|
5610
|
+
);
|
|
5611
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
5612
|
+
|
|
5613
|
+
mockGetHashesFromLocusResponse(
|
|
5614
|
+
mainDataSetUrl,
|
|
5615
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
5616
|
+
createDataSet('main', 16, 1101)
|
|
5617
|
+
);
|
|
5618
|
+
mockSendSyncRequestResponse(mainDataSetUrl, null);
|
|
5619
|
+
|
|
5620
|
+
parser.handleMessage(
|
|
5621
|
+
createHeartbeatMessage('main', 16, 1100, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1'),
|
|
5622
|
+
'trigger sync metrics'
|
|
5623
|
+
);
|
|
5624
|
+
|
|
5625
|
+
await clock.tickAsync(1000);
|
|
5626
|
+
|
|
5627
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5628
|
+
key: 'internal.client.locus.sync.start',
|
|
5629
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: undefined},
|
|
5630
|
+
});
|
|
5631
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5632
|
+
key: 'internal.client.locus.hashtree.request',
|
|
5633
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: undefined},
|
|
5634
|
+
});
|
|
5635
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5636
|
+
key: 'internal.client.locus.hashtree.response',
|
|
5637
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: undefined},
|
|
5638
|
+
});
|
|
5639
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5640
|
+
key: 'internal.client.locus.sync.request',
|
|
5641
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: undefined},
|
|
5642
|
+
});
|
|
5643
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5644
|
+
key: 'internal.client.locus.sync.response',
|
|
5645
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: undefined},
|
|
5646
|
+
});
|
|
5647
|
+
assert.notCalled(syncLatencyTracker.getLocusSyncLatency);
|
|
5648
|
+
});
|
|
5649
|
+
|
|
5650
|
+
it('clears only the failed sync record (by tracking id) when the /sync request errors', async () => {
|
|
5651
|
+
const syncLatencyTracker = {
|
|
5652
|
+
saveLatency: sinon.stub(),
|
|
5653
|
+
saveTimestamp: sinon.stub(),
|
|
5654
|
+
getLocusSyncLatency: sinon.stub(),
|
|
5655
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
5656
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
5657
|
+
};
|
|
5658
|
+
const generateTrackingId = sinon.stub().returns('our-sync-tracking-id');
|
|
5659
|
+
const parser = createHashTreeParser(
|
|
5660
|
+
undefined,
|
|
5661
|
+
undefined,
|
|
5662
|
+
undefined,
|
|
5663
|
+
syncLatencyTracker,
|
|
5664
|
+
undefined,
|
|
5665
|
+
generateTrackingId
|
|
5666
|
+
);
|
|
5667
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
5668
|
+
|
|
5669
|
+
// Mismatched hashes so the flow proceeds to POST /sync, which then fails.
|
|
5670
|
+
mockGetHashesFromLocusResponse(
|
|
5671
|
+
mainDataSetUrl,
|
|
5672
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
5673
|
+
createDataSet('main', 16, 1101)
|
|
5674
|
+
);
|
|
5675
|
+
webexRequest
|
|
5676
|
+
.withArgs(sinon.match({method: 'POST', uri: `${mainDataSetUrl}/sync`}))
|
|
5677
|
+
.rejects(new Error('sync failed'));
|
|
5678
|
+
|
|
5679
|
+
parser.handleMessage(
|
|
5680
|
+
createHeartbeatMessage('main', 16, 1100, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1'),
|
|
5681
|
+
'trigger sync metrics'
|
|
5682
|
+
);
|
|
5683
|
+
|
|
5684
|
+
await clock.tickAsync(1000);
|
|
5685
|
+
|
|
5686
|
+
// Because /sync failed, syncRequestSent stays false and the finally block drops the record,
|
|
5687
|
+
// passing the tracking id so only this in-progress record is removed (native onSyncError parity).
|
|
5688
|
+
assert.calledWithExactly(
|
|
5689
|
+
syncLatencyTracker.clearLocusSyncLatency,
|
|
5690
|
+
'main',
|
|
5691
|
+
'meeting-1',
|
|
5692
|
+
'our-sync-tracking-id'
|
|
5693
|
+
);
|
|
5694
|
+
});
|
|
5695
|
+
|
|
5696
|
+
it('forces a pre-generated tracking id onto the sync request and records it', async () => {
|
|
5697
|
+
const syncLatencyTracker = {
|
|
5698
|
+
saveLatency: sinon.stub(),
|
|
5699
|
+
saveTimestamp: sinon.stub(),
|
|
5700
|
+
getLocusSyncLatency: sinon.stub(),
|
|
5701
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
5702
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
5703
|
+
};
|
|
5704
|
+
// two distinct tracking ids are generated: the first for the /hashtree request and the
|
|
5705
|
+
// second for the /sync request (which is also stored in metrics and used for LLM matching)
|
|
5706
|
+
const generateTrackingId = sinon.stub();
|
|
5707
|
+
generateTrackingId.onFirstCall().returns('our-hashtree-tracking-id');
|
|
5708
|
+
generateTrackingId.onSecondCall().returns('our-sync-tracking-id');
|
|
5709
|
+
const parser = createHashTreeParser(
|
|
5710
|
+
undefined,
|
|
5711
|
+
undefined,
|
|
5712
|
+
undefined,
|
|
5713
|
+
syncLatencyTracker,
|
|
5714
|
+
undefined,
|
|
5715
|
+
generateTrackingId
|
|
5716
|
+
);
|
|
5717
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
5718
|
+
|
|
5719
|
+
mockGetHashesFromLocusResponse(
|
|
5720
|
+
mainDataSetUrl,
|
|
5721
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
5722
|
+
createDataSet('main', 16, 1102)
|
|
5723
|
+
);
|
|
5724
|
+
mockSendSyncRequestResponse(mainDataSetUrl, null);
|
|
5725
|
+
|
|
5726
|
+
parser.handleMessage(
|
|
5727
|
+
createHeartbeatMessage('main', 16, 1100, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1'),
|
|
5728
|
+
'trigger sync metrics'
|
|
5729
|
+
);
|
|
5730
|
+
|
|
5731
|
+
await clock.tickAsync(1000);
|
|
5732
|
+
|
|
5733
|
+
// two distinct tracking ids are generated up-front so the /hashtree and /sync requests do
|
|
5734
|
+
// not share a tracking id
|
|
5735
|
+
assert.calledTwice(generateTrackingId);
|
|
5736
|
+
// the /hashtree request carries its own (first) tracking id
|
|
5737
|
+
assert.calledWith(
|
|
5738
|
+
webexRequest,
|
|
5739
|
+
sinon.match({
|
|
5740
|
+
method: 'GET',
|
|
5741
|
+
uri: `${mainDataSetUrl}/hashtree`,
|
|
5742
|
+
headers: {trackingid: 'our-hashtree-tracking-id'},
|
|
5743
|
+
})
|
|
5744
|
+
);
|
|
5745
|
+
// the /sync request carries the second tracking id, which Locus echoes back on the resulting
|
|
5746
|
+
// LLM message so the Meeting object can match it to this sync
|
|
5747
|
+
assert.calledWith(
|
|
5748
|
+
webexRequest,
|
|
5749
|
+
sinon.match({
|
|
5750
|
+
method: 'POST',
|
|
5751
|
+
uri: `${mainDataSetUrl}/sync`,
|
|
5752
|
+
headers: {trackingid: 'our-sync-tracking-id'},
|
|
5753
|
+
})
|
|
5754
|
+
);
|
|
5755
|
+
|
|
5756
|
+
// the same tracking id is stamped on the sync milestones so the Meeting object can later
|
|
5757
|
+
// match the LLM event to this sync
|
|
5758
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5759
|
+
key: 'internal.client.locus.sync.start',
|
|
5760
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: 'our-sync-tracking-id'},
|
|
5761
|
+
});
|
|
5762
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5763
|
+
key: 'internal.client.locus.hashtree.request',
|
|
5764
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: 'our-sync-tracking-id'},
|
|
5765
|
+
});
|
|
5766
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5767
|
+
key: 'internal.client.locus.hashtree.response',
|
|
5768
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: 'our-sync-tracking-id'},
|
|
5769
|
+
});
|
|
5770
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5771
|
+
key: 'internal.client.locus.sync.request',
|
|
5772
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: 'our-sync-tracking-id'},
|
|
5773
|
+
});
|
|
5774
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5775
|
+
key: 'internal.client.locus.sync.response',
|
|
5776
|
+
options: {meetingId: 'meeting-1', dataSetName: 'main', trackingId: 'our-sync-tracking-id'},
|
|
5777
|
+
});
|
|
5778
|
+
assert.notCalled(syncLatencyTracker.getLocusSyncLatency);
|
|
5779
|
+
});
|
|
5780
|
+
|
|
5781
|
+
it('does not complete or clear metrics when matching dataset message arrives', () => {
|
|
5782
|
+
const syncLatencyTracker = {
|
|
5783
|
+
saveLatency: sinon.stub(),
|
|
5784
|
+
saveTimestamp: sinon.stub(),
|
|
5785
|
+
getLocusSyncLatency: sinon.stub(),
|
|
5786
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
5787
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
5788
|
+
};
|
|
5789
|
+
const parser = createHashTreeParser(
|
|
5790
|
+
undefined,
|
|
5791
|
+
undefined,
|
|
5792
|
+
undefined,
|
|
5793
|
+
syncLatencyTracker
|
|
5794
|
+
);
|
|
5795
|
+
|
|
5796
|
+
parser.handleMessage({
|
|
5797
|
+
dataSets: [
|
|
5798
|
+
{
|
|
5799
|
+
...createDataSet('main', 16, 1001),
|
|
5800
|
+
root: 'newroot',
|
|
5801
|
+
},
|
|
5802
|
+
],
|
|
5803
|
+
visibleDataSetsUrl,
|
|
5804
|
+
locusUrl,
|
|
5805
|
+
locusStateElements: [],
|
|
5806
|
+
});
|
|
5807
|
+
|
|
5808
|
+
assert.notCalled(syncLatencyTracker.getLocusSyncLatency);
|
|
5809
|
+
assert.notCalled(syncLatencyTracker.clearLocusSyncLatency);
|
|
5810
|
+
assert.notCalled(syncLatencyTracker.completeLocusSyncLatency);
|
|
5811
|
+
});
|
|
5812
|
+
|
|
5813
|
+
it('does not complete sync metrics when sync response has body (completion is LLM-only)', async () => {
|
|
5814
|
+
const syncLatencyTracker = {
|
|
5815
|
+
saveLatency: sinon.stub(),
|
|
5816
|
+
saveTimestamp: sinon.stub(),
|
|
5817
|
+
getLocusSyncLatency: sinon.stub(),
|
|
5818
|
+
clearLocusSyncLatency: sinon.stub(),
|
|
5819
|
+
completeLocusSyncLatency: sinon.stub(),
|
|
5820
|
+
};
|
|
5821
|
+
const generateTrackingId = sinon.stub().returns('our-sync-tracking-id');
|
|
5822
|
+
const parser = createHashTreeParser(
|
|
5823
|
+
undefined,
|
|
5824
|
+
undefined,
|
|
5825
|
+
undefined,
|
|
5826
|
+
syncLatencyTracker,
|
|
5827
|
+
undefined,
|
|
5828
|
+
generateTrackingId
|
|
5829
|
+
);
|
|
5830
|
+
const mainDataSetUrl = parser.dataSets.main.url;
|
|
5831
|
+
const syncResponse = {
|
|
5832
|
+
dataSets: [
|
|
5833
|
+
{
|
|
5834
|
+
...createDataSet('main', 16, 1102),
|
|
5835
|
+
root: 'newroot',
|
|
5836
|
+
},
|
|
5837
|
+
],
|
|
5838
|
+
visibleDataSetsUrl,
|
|
5839
|
+
locusUrl,
|
|
5840
|
+
locusStateElements: [],
|
|
5841
|
+
};
|
|
5842
|
+
|
|
5843
|
+
mockGetHashesFromLocusResponse(
|
|
5844
|
+
mainDataSetUrl,
|
|
5845
|
+
new Array(16).fill('00000000000000000000000000000000'),
|
|
5846
|
+
createDataSet('main', 16, 1102)
|
|
5847
|
+
);
|
|
5848
|
+
mockSendSyncRequestResponse(mainDataSetUrl, syncResponse);
|
|
5849
|
+
|
|
5850
|
+
parser.handleMessage(
|
|
5851
|
+
createHeartbeatMessage('main', 16, 1100, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1'),
|
|
5852
|
+
'trigger sync metrics'
|
|
5853
|
+
);
|
|
5854
|
+
|
|
5855
|
+
await clock.tickAsync(1000);
|
|
5856
|
+
|
|
5857
|
+
assert.calledWithExactly(syncLatencyTracker.saveTimestamp, {
|
|
5858
|
+
key: 'internal.client.locus.sync.response',
|
|
5859
|
+
options: {
|
|
5860
|
+
meetingId: 'meeting-1',
|
|
5861
|
+
dataSetName: 'main',
|
|
5862
|
+
trackingId: 'our-sync-tracking-id',
|
|
5863
|
+
},
|
|
5864
|
+
});
|
|
5865
|
+
// body-mode syncs return the state elements in the /sync HTTP response, but per the LLM-only
|
|
5866
|
+
// design the CA metric is completed solely from Meeting#processLocusLLMEvent once the matching
|
|
5867
|
+
// LLM message arrives. handleMessage must not record the message-received milestone nor
|
|
5868
|
+
// complete the metric here.
|
|
5869
|
+
assert.neverCalledWith(syncLatencyTracker.saveTimestamp, {
|
|
5870
|
+
key: 'internal.client.locus.sync.message.received',
|
|
5871
|
+
options: {
|
|
5872
|
+
meetingId: 'meeting-1',
|
|
5873
|
+
dataSetName: 'main',
|
|
5874
|
+
trackingId: 'our-sync-tracking-id',
|
|
5875
|
+
},
|
|
5876
|
+
});
|
|
5877
|
+
assert.notCalled(syncLatencyTracker.completeLocusSyncLatency);
|
|
5878
|
+
});
|
|
5879
|
+
|
|
5880
|
+
});
|
|
5328
5881
|
});
|