diff --git a/experiments.json b/experiments.json index 60b0742537a3..69bfb177fd1d 100644 --- a/experiments.json +++ b/experiments.json @@ -1 +1,14 @@ -[] +[ + { + "name": "AlwaysDisplayTestExplorer - experiment", + "salt": "AlwaysDisplayTestExplorer", + "min": 80, + "max": 100 + }, + { + "name": "AlwaysDisplayTestExplorer - control", + "salt": "AlwaysDisplayTestExplorer", + "min": 0, + "max": 20 + } +] diff --git a/src/client/common/crypto.ts b/src/client/common/crypto.ts index 1d599737d46e..c0115ddf8b9f 100644 --- a/src/client/common/crypto.ts +++ b/src/client/common/crypto.ts @@ -6,6 +6,7 @@ import { createHash } from 'crypto'; import { injectable } from 'inversify'; +import { traceError } from './logger'; import { ICryptoUtils, IHashFormat } from './types'; /** @@ -15,6 +16,13 @@ import { ICryptoUtils, IHashFormat } from './types'; export class CryptoUtils implements ICryptoUtils { public createHash(data: string, hashFormat: E): IHashFormat[E] { const hash = createHash('sha512').update(data).digest('hex'); - return hashFormat === 'number' ? parseInt(hash, 16) : hash as any; + if (hashFormat === 'number') { + const result = parseInt(hash, 16); + if (isNaN(result)) { + traceError(`Number hash for data '${data}' is NaN`); + } + return result as any; + } + return hash as any; } } diff --git a/src/client/common/experimentGroups.ts b/src/client/common/experimentGroups.ts index 104d0ead8e78..3df5140f537c 100644 --- a/src/client/common/experimentGroups.ts +++ b/src/client/common/experimentGroups.ts @@ -4,5 +4,5 @@ export const LSEnabled = 'LS - enabled'; // Experiment to check whether to always display the test explorer. export enum AlwaysDisplayTestExplorerGroups { control = 'AlwaysDisplayTestExplorer - control', - enabled = 'AlwaysDisplayTestExplorer - enabled' + experiment = 'AlwaysDisplayTestExplorer - experiment' } diff --git a/src/client/testing/main.ts b/src/client/testing/main.ts index 7d495cd3d1f3..fc71ecaa22a1 100644 --- a/src/client/testing/main.ts +++ b/src/client/testing/main.ts @@ -74,7 +74,7 @@ export class UnitTestManagementService implements ITestManagementService, Dispos } public checkExperiments() { const experiments = this.serviceContainer.get(IExperimentsManager); - if (experiments.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)) { + if (experiments.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)) { const commandManager = this.serviceContainer.get(ICommandManager); commandManager.executeCommand('setContext', 'testsDiscovered', true).then(noop, noop); } else { diff --git a/src/test/testing/main.unit.test.ts b/src/test/testing/main.unit.test.ts index ea28b9830bd8..7f38e6ad6b72 100644 --- a/src/test/testing/main.unit.test.ts +++ b/src/test/testing/main.unit.test.ts @@ -47,22 +47,22 @@ suite('Unit Tests - ManagementService', () => { }); test('Execute command if in experiment', async () => { - when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).thenReturn(true); + when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).thenReturn(true); await testManagementService.activate(instance(mock(JediSymbolProvider))); verify(commandManager.executeCommand('setContext', 'testsDiscovered', true)).once(); - verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).once(); + verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).once(); verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.control)).never(); verify(experiment.sendTelemetryIfInExperiment(anything())).never(); }); test('If not in experiment, check and send Telemetry for control group and do not execute command', async () => { - when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).thenReturn(false); + when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).thenReturn(false); await testManagementService.activate(instance(mock(JediSymbolProvider))); verify(commandManager.executeCommand('setContext', 'testsDiscovered', anything())).never(); - verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).once(); + verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).once(); verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.control)).never(); verify(experiment.sendTelemetryIfInExperiment(AlwaysDisplayTestExplorerGroups.control)).once(); });