@webex/plugin-meetings 3.0.0-beta.257 → 3.0.0-beta.258

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.
@@ -1,12 +1,12 @@
1
1
  import {assert} from '@webex/test-helper-chai';
2
2
  import MockWebex from '@webex/test-helper-mock-webex';
3
3
  import sinon from 'sinon';
4
- import Reachability, {ICECandidateResult} from '@webex/plugin-meetings/src/reachability/';
4
+ import Reachability, {ICECandidateResult, ReachabilityResults} from '@webex/plugin-meetings/src/reachability/';
5
5
  import MeetingUtil from '@webex/plugin-meetings/src/meeting/util';
6
6
 
7
7
  import { IP_VERSION } from '@webex/plugin-meetings/src/constants';
8
8
 
9
- describe('isAnyClusterReachable', () => {
9
+ describe('isAnyPublicClusterReachable', () => {
10
10
  let webex;
11
11
 
12
12
  beforeEach(() => {
@@ -29,7 +29,7 @@ describe('isAnyClusterReachable', () => {
29
29
  }
30
30
  const reachability = new Reachability(webex);
31
31
 
32
- const result = await reachability.isAnyClusterReachable();
32
+ const result = await reachability.isAnyPublicClusterReachable();
33
33
 
34
34
  assert.equal(result, expectedValue);
35
35
  };
@@ -57,6 +57,63 @@ describe('isAnyClusterReachable', () => {
57
57
  it('returns false when reachability.result item is not there', async () => {
58
58
  await checkIsClusterReachable(undefined, false);
59
59
  });
60
+
61
+ describe('ignores video mesh reachability', () => {
62
+ it('returns false if there are no public cluster results, only video mesh', async () => {
63
+ await checkIsClusterReachable({
64
+ x: {
65
+ udp: {reachable: 'true'},
66
+ tcp: {reachable: 'true'},
67
+ isVideoMesh: true,
68
+ },
69
+ y: {
70
+ udp: {reachable: 'false'},
71
+ tcp: {reachable: 'true'},
72
+ isVideoMesh: true,
73
+ }
74
+ }, false);
75
+ });
76
+
77
+ it('returns false if there public cluster reachability failed, only video mesh succeeded', async () => {
78
+ await checkIsClusterReachable({
79
+ x: {
80
+ udp: {reachable: 'false'},
81
+ tcp: {reachable: 'true'},
82
+ isVideoMesh: true,
83
+ },
84
+ y: {
85
+ udp: {reachable: 'true'},
86
+ tcp: {reachable: 'false'},
87
+ isVideoMesh: true,
88
+ },
89
+ publicOne: {
90
+ udp: {reachable: 'false'},
91
+ tcp: {reachable: 'false'},
92
+ isVideoMesh: false,
93
+ }
94
+ }, false);
95
+ });
96
+
97
+ it('returns true if there is at least 1 public cluster result, while video mesh is not reachable', async () => {
98
+ await checkIsClusterReachable({
99
+ x: {
100
+ udp: {reachable: 'true'},
101
+ tcp: {reachable: 'true'},
102
+ isVideoMesh: true,
103
+ },
104
+ y: {
105
+ udp: {reachable: 'false'},
106
+ tcp: {reachable: 'true'},
107
+ isVideoMesh: true,
108
+ },
109
+ publicOne: {
110
+ udp: {reachable: 'false'},
111
+ tcp: {reachable: 'true'},
112
+ isVideoMesh: false,
113
+ }
114
+ }, true);
115
+ });
116
+ })
60
117
  });
61
118
 
62
119
  describe('gatherReachability', () => {
@@ -160,8 +217,8 @@ describe('gatherReachability', () => {
160
217
  let testingClass: TestReachability;
161
218
 
162
219
  class TestReachability extends Reachability {
163
- public testParseIceResultsToReachabilityResults(iceResults: Array<ICECandidateResult>) {
164
- return this.parseIceResultsToReachabilityResults(iceResults);
220
+ public testParseIceResultsToInternalReachabilityResults(iceResults: Array<ICECandidateResult>) {
221
+ return this.parseIceResultsToInternalReachabilityResults(iceResults);
165
222
  }
166
223
  public testAddPublicIP(peerConnection: RTCPeerConnection, publicIP?: string | null) {
167
224
  return this.addPublicIP(peerConnection, publicIP);
@@ -171,22 +228,25 @@ describe('gatherReachability', () => {
171
228
  testingClass = new TestReachability({webex});
172
229
  });
173
230
 
174
- it('calls parseIceResultsToReachabilityResults correctly', () => {
175
- const res = testingClass.testParseIceResultsToReachabilityResults([
231
+ it('calls parseIceResultsToInternalReachabilityResults correctly', () => {
232
+ const res = testingClass.testParseIceResultsToInternalReachabilityResults([
176
233
  {
177
234
  clusterId: 'id1',
178
235
  elapsed: '12312',
179
236
  publicIPs: ['1.1.1.1'],
237
+ isVideoMesh: true,
180
238
  },
181
239
  {
182
240
  clusterId: 'id2',
183
241
  elapsed: null,
184
242
  publicIPs: ['1.1.1.1'],
243
+ isVideoMesh: false,
185
244
  },
186
245
  {
187
246
  clusterId: 'id2',
188
247
  elapsed: '14123',
189
248
  publicIPs: undefined,
249
+ isVideoMesh: false,
190
250
  },
191
251
  ]);
192
252
 
@@ -203,6 +263,7 @@ describe('gatherReachability', () => {
203
263
  latencyInMilliseconds: '12312',
204
264
  reachable: 'true',
205
265
  },
266
+ isVideoMesh: true,
206
267
  },
207
268
  id2: {
208
269
  xtls: {
@@ -215,6 +276,7 @@ describe('gatherReachability', () => {
215
276
  latencyInMilliseconds: '14123',
216
277
  reachable: 'true',
217
278
  },
279
+ isVideoMesh: false,
218
280
  },
219
281
  });
220
282
  });
@@ -260,3 +322,97 @@ describe('gatherReachability', () => {
260
322
  });
261
323
  });
262
324
  });
325
+
326
+ describe('getReachabilityResults', () => {
327
+ let webex;
328
+
329
+ beforeEach(() => {
330
+ webex = new MockWebex();
331
+
332
+ // sinon.stub(MeetingUtil, 'getIpVersion').returns(IP_VERSION.unknown);
333
+ });
334
+
335
+ afterEach(() => {
336
+ sinon.restore();
337
+ });
338
+
339
+ const runCheck = async (mockStorage: any, expectedResult: ReachabilityResults) => {
340
+ if (mockStorage) {
341
+ await webex.boundedStorage.put(
342
+ 'Reachability',
343
+ 'reachability.result',
344
+ JSON.stringify(mockStorage)
345
+ );
346
+ }
347
+ const reachability = new Reachability(webex);
348
+
349
+ const result = await reachability.getReachabilityResults();
350
+
351
+ assert.deepEqual(result, expectedResult);
352
+ };
353
+
354
+ it('returns undefined if reading from local storage fails', async () => {
355
+ sinon.stub(webex.boundedStorage, 'get').rejects(new Error('fake error'));
356
+
357
+ const reachability = new Reachability(webex);
358
+
359
+ const result = await reachability.getReachabilityResults();
360
+
361
+ assert.isUndefined(result);
362
+ });
363
+
364
+ it('returns results from local storage, stripping any internal data', async () => {
365
+ await runCheck(
366
+ // mock storage:
367
+ {
368
+ cluster1: {
369
+ udp: {reachable: 'true', latencyInMilliseconds: '100'},
370
+ tcp: {reachable: 'false'},
371
+ xtls: {untested: 'true'},
372
+ },
373
+ cluster2: {
374
+ udp: {reachable: 'true', latencyInMilliseconds: '200'},
375
+ tcp: {reachable: 'false'},
376
+ xtls: {untested: 'true'},
377
+ isVideoMesh: true,
378
+ },
379
+ cluster3: {
380
+ udp: {reachable: 'false'},
381
+ tcp: {reachable: 'true', latencyInMilliseconds: '100', clientMediaIPs: ['10.10.10.10']},
382
+ xtls: {untested: 'true'},
383
+ isVideoMesh: true,
384
+ someOtherField: 'any value',
385
+ },
386
+ cluster4: {
387
+ udp: {reachable: 'false', latencyInMilliseconds: '300'},
388
+ tcp: {reachable: 'false', untested: 'true'},
389
+ xtls: {untested: 'true'},
390
+ someOtherField: 'any value',
391
+ },
392
+ },
393
+ // expected result (same as above, but with isVideoMesh and someOtherField stripped out):
394
+ {
395
+ cluster1: {
396
+ udp: {reachable: 'true', latencyInMilliseconds: '100'},
397
+ tcp: {reachable: 'false'},
398
+ xtls: {untested: 'true'},
399
+ },
400
+ cluster2: {
401
+ udp: {reachable: 'true', latencyInMilliseconds: '200'},
402
+ tcp: {reachable: 'false'},
403
+ xtls: {untested: 'true'},
404
+ },
405
+ cluster3: {
406
+ udp: {reachable: 'false'},
407
+ tcp: {reachable: 'true', latencyInMilliseconds: '100', clientMediaIPs: ['10.10.10.10']},
408
+ xtls: {untested: 'true'},
409
+ },
410
+ cluster4: {
411
+ udp: {reachable: 'false', latencyInMilliseconds: '300'},
412
+ tcp: {reachable: 'false', untested: 'true'},
413
+ xtls: {untested: 'true'},
414
+ },
415
+ }
416
+ );
417
+ });
418
+ });
@@ -64,7 +64,7 @@ describe('Roap', () => {
64
64
  setRoapSeq: sinon.stub(),
65
65
  config: {experimental: {enableTurnDiscovery: false}},
66
66
  locusMediaRequest: {fake: true},
67
- webex: { meetings: { reachability: { isAnyClusterReachable: () => true}}},
67
+ webex: { meetings: { reachability: { isAnyPublicClusterReachable: () => true}}},
68
68
  };
69
69
 
70
70
  sinon.stub(MeetingUtil, 'getIpVersion').returns(IP_VERSION.unknown);
@@ -66,6 +66,7 @@ describe('plugin-meetings/roap', () => {
66
66
  JSON.stringify({
67
67
  clusterId: {
68
68
  udp: 'test',
69
+ isVideoMesh: false,
69
70
  },
70
71
  })
71
72
  );
@@ -54,7 +54,7 @@ describe('TurnDiscovery', () => {
54
54
  }),
55
55
  updateMediaConnections: sinon.stub(),
56
56
  webex: {meetings: {reachability: {
57
- isAnyClusterReachable: () => Promise.resolve(false),
57
+ isAnyPublicClusterReachable: () => Promise.resolve(false),
58
58
  }}},
59
59
  isMultistream: false,
60
60
  locusMediaRequest: { fake: true },
@@ -257,8 +257,8 @@ describe('TurnDiscovery', () => {
257
257
  });
258
258
 
259
259
  it('resolves with undefined when cluster is reachable', async () => {
260
- const prev = testMeeting.webex.meetings.reachability.isAnyClusterReachable;
261
- testMeeting.webex.meetings.reachability.isAnyClusterReachable = () => Promise.resolve(true);
260
+ const prev = testMeeting.webex.meetings.reachability.isAnyPublicClusterReachable;
261
+ testMeeting.webex.meetings.reachability.isAnyPublicClusterReachable = () => Promise.resolve(true);
262
262
  const result = await new TurnDiscovery(mockRoapRequest).doTurnDiscovery(testMeeting);
263
263
 
264
264
  const {turnServerInfo, turnDiscoverySkippedReason} = result;
@@ -267,7 +267,7 @@ describe('TurnDiscovery', () => {
267
267
  assert.equal(turnDiscoverySkippedReason, 'reachability');
268
268
  assert.notCalled(mockRoapRequest.sendRoap);
269
269
  assert.notCalled(Metrics.sendBehavioralMetric);
270
- testMeeting.webex.meetings.reachability.isAnyClusterReachable = prev;
270
+ testMeeting.webex.meetings.reachability.isAnyPublicClusterReachable = prev;
271
271
  });
272
272
 
273
273
  it("resolves with undefined if we don't get a response within 10s", async () => {
@@ -379,15 +379,15 @@ describe('TurnDiscovery', () => {
379
379
 
380
380
  describe('isSkipped', () => {
381
381
  [
382
- {enabledInConfig: true, isAnyClusterReachable: true, expectedIsSkipped: true},
383
- {enabledInConfig: true, isAnyClusterReachable: false, expectedIsSkipped: false},
384
- {enabledInConfig: false, isAnyClusterReachable: true, expectedIsSkipped: true},
385
- {enabledInConfig: false, isAnyClusterReachable: false, expectedIsSkipped: true},
386
- ].forEach(({enabledInConfig, isAnyClusterReachable, expectedIsSkipped}) => {
387
- it(`returns ${expectedIsSkipped} when TURN discovery is ${enabledInConfig ? '' : 'not '} enabled in config and isAnyClusterReachable() returns ${isAnyClusterReachable ? 'true' : 'false'}`, async () => {
382
+ {enabledInConfig: true, isAnyPublicClusterReachable: true, expectedIsSkipped: true},
383
+ {enabledInConfig: true, isAnyPublicClusterReachable: false, expectedIsSkipped: false},
384
+ {enabledInConfig: false, isAnyPublicClusterReachable: true, expectedIsSkipped: true},
385
+ {enabledInConfig: false, isAnyPublicClusterReachable: false, expectedIsSkipped: true},
386
+ ].forEach(({enabledInConfig, isAnyPublicClusterReachable, expectedIsSkipped}) => {
387
+ it(`returns ${expectedIsSkipped} when TURN discovery is ${enabledInConfig ? '' : 'not '} enabled in config and isAnyPublicClusterReachable() returns ${isAnyPublicClusterReachable ? 'true' : 'false'}`, async () => {
388
388
  testMeeting.config.experimental.enableTurnDiscovery = enabledInConfig;
389
389
 
390
- sinon.stub(testMeeting.webex.meetings.reachability, 'isAnyClusterReachable').resolves(isAnyClusterReachable);
390
+ sinon.stub(testMeeting.webex.meetings.reachability, 'isAnyPublicClusterReachable').resolves(isAnyPublicClusterReachable);
391
391
 
392
392
  const td = new TurnDiscovery(mockRoapRequest);
393
393