Skip to content

Commit

Permalink
feat(meetings): do ip version detection in parallel with reachability (
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-bazyl authored and parv_gour committed Sep 27, 2024
1 parent b4e6e19 commit 235090c
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/@webex/plugin-meetings/src/reachability/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export default class Reachability extends EventsScope {
public async gatherReachability(): Promise<ReachabilityResults> {
// Fetch clusters and measure latency
try {
// kick off ip version detection. For now we don't await it, as we're doing it
// to gather the timings and send them with our reachability metrics
// @ts-ignore
this.webex.internal.device.ipNetworkDetector.detect();

const {clusters, joinCookie} = await this.getClusters();

// @ts-ignore
Expand Down Expand Up @@ -537,6 +542,16 @@ export default class Reachability extends EventsScope {
tcp: this.getStatistics(results, 'tcp', false),
xtls: this.getStatistics(results, 'xtls', false),
},
ipver: {
// @ts-ignore
firstIpV4: this.webex.internal.device.ipNetworkDetector.firstIpV4,
// @ts-ignore
firstIpV6: this.webex.internal.device.ipNetworkDetector.firstIpV6,
// @ts-ignore
firstMdns: this.webex.internal.device.ipNetworkDetector.firstMdns,
// @ts-ignore
totalTime: this.webex.internal.device.ipNetworkDetector.totalTime,
},
};
Metrics.sendBehavioralMetric(
BEHAVIORAL_METRICS.REACHABILITY_COMPLETED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ describe('gatherReachability', () => {
JSON.stringify({old: 'joinCookie'})
);

webex.internal.device.ipNetworkDetector = {
supportsIpV4: false,
supportsIpV6: false,
firstIpV4: -1,
firstIpV6: -1,
firstMdns: -1,
totalTime: -1,
detect: sinon.stub().resolves(),
};

clock = sinon.useFakeTimers();

mockClusterReachabilityInstances = {};
Expand Down Expand Up @@ -1034,6 +1044,15 @@ describe('gatherReachability', () => {
enableTlsReachability: true,
};

// the metrics related to ipver are not tested in these tests and are all the same, so setting them up here
const expectedMetricsFull = {
...expectedMetrics,
ipver_firstIpV4: -1,
ipver_firstIpV6: -1,
ipver_firstMdns: -1,
ipver_totalTime: -1,
};

const receivedEvents = {
done: 0,
firstResultAvailable: {
Expand Down Expand Up @@ -1118,11 +1137,89 @@ describe('gatherReachability', () => {
assert.calledWith(
Metrics.sendBehavioralMetric,
'js_sdk_reachability_completed',
expectedMetrics
expectedMetricsFull
);
})
);

it(`starts ip network version detection and includes the results in the metrics`, async () => {
webex.config.meetings.experimental = {
enableTcpReachability: true,
enableTlsReachability: true,
};
webex.internal.device.ipNetworkDetector = {
supportsIpV4: true,
supportsIpV6: true,
firstIpV4: 10,
firstIpV6: 20,
firstMdns: 30,
totalTime: 40,
detect: sinon.stub().resolves(),
};

const receivedEvents = {
done: 0,
};

const reachability = new Reachability(webex);

reachability.on('reachability:done', () => {
receivedEvents.done += 1;
});

// simulate having just 1 cluster, we don't need more for this test
reachability.reachabilityRequest.getClusters = sinon.stub().returns({
clusters: {
publicCluster: {
udp: ['udp-url'],
tcp: [],
xtls: [],
isVideoMesh: false,
},
},
joinCookie: {id: 'id'},
});

const resultPromise = reachability.gatherReachability();

await testUtils.flushPromises();

// trigger mock result events from ClusterReachability instance
mockClusterReachabilityInstances['publicCluster'].emitFakeResult('udp', {
result: 'reachable',
clientMediaIPs: ['1.2.3.4'],
latencyInMilliseconds: 100,
});

await resultPromise;

// check events emitted by Reachability class
assert.equal(receivedEvents['done'], 1);

// and that ip network detection was started
assert.calledOnceWithExactly(webex.internal.device.ipNetworkDetector.detect);

// finally, check the metrics - they should contain values from ipNetworkDetector
assert.calledWith(Metrics.sendBehavioralMetric, 'js_sdk_reachability_completed', {
vmn_udp_min: -1,
vmn_udp_max: -1,
vmn_udp_average: -1,
public_udp_min: 100,
public_udp_max: 100,
public_udp_average: 100,
public_tcp_min: -1,
public_tcp_max: -1,
public_tcp_average: -1,
public_xtls_min: -1,
public_xtls_max: -1,
public_xtls_average: -1,
ipver_firstIpV4: webex.internal.device.ipNetworkDetector.firstIpV4,
ipver_firstIpV6: webex.internal.device.ipNetworkDetector.firstIpV6,
ipver_firstMdns: webex.internal.device.ipNetworkDetector.firstMdns,
ipver_totalTime: webex.internal.device.ipNetworkDetector.totalTime,
});
});

it('keeps updating reachability results after the 3s public cloud timeout expires', async () => {
webex.config.meetings.experimental = {
enableTcpReachability: true,
Expand Down

0 comments on commit 235090c

Please sign in to comment.