Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverting single execution client changes (re-run single agent flow) for 137 #7603

Merged
merged 6 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
"loc.messages.OnlyWindowsOsSupported": "This task is supported only on Windows agents and cannot be used on other platforms.",
"loc.messages.MultiConfigNotSupportedWithOnDemand": "On demand runs are not supported with Multi-Configuration option. Please use 'None' or 'Multi-agent' parallelism option.",
"loc.messages.disabledRerun": "Disabling the rerun of failed tests as the rerun threshold provided is %s",
"loc.messages.UpgradeAgentMessage": "Please upgrade your agent version. https://github.com/Microsoft/vsts-agent/releases",
"loc.messages.VsTestVersionEmpty": "VsTestVersion is null or empty",
"loc.messages.UserProvidedSourceFilter": "Source filter: %s"
"loc.messages.UpgradeAgentMessage": "Please upgrade your vsts-agent version. https://github.com/Microsoft/vsts-agent/releases",
"loc.messages.VsTestVersionEmpty": "VsTestVersion is null or empty"
}
65 changes: 60 additions & 5 deletions Tasks/VsTestV2/distributedtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as ci from './cieventlogger';
import { TestSelectorInvoker } from './testselectorinvoker';
import { writeFileSync } from 'fs';
import { TaskResult } from 'vso-node-api/interfaces/TaskAgentInterfaces';
import * as uuid from 'uuid';
const uuid = require('uuid');

const testSelector = new TestSelectorInvoker();

Expand Down Expand Up @@ -60,15 +60,16 @@ export class DistributedTest {

// Temporary solution till this logic can move to the test platform itself
if (this.inputDataContract.UsingXCopyTestPlatformPackage) {
envVars = utils.Helper.setProfilerVariables(envVars);
envVars = this.setProfilerVariables(envVars);
}

// Pass the acess token as an environment variable for security purposes
utils.Helper.addToProcessEnvVars(envVars, 'DTA.AccessToken', tl.getEndpointAuthorization('SystemVssConnection', true).parameters.AccessToken);
utils.Helper.addToProcessEnvVars(envVars, 'DTA.AccessToken', this.inputDataContract.AccessToken);
this.inputDataContract.AccessToken = null;

// Invoke DtaExecutionHost with the input json file
const inputFilePath = utils.Helper.GenerateTempFile('input_' + uuid.v1() + '.json');
utils.Helper.removeEmptyNodes(this.inputDataContract);
DistributedTest.removeEmptyNodes(this.inputDataContract);

try {
writeFileSync(inputFilePath, JSON.stringify(this.inputDataContract));
Expand Down Expand Up @@ -98,10 +99,29 @@ export class DistributedTest {
return code;
}

// Utility function used to remove empty or spurious nodes from the input json file
public static removeEmptyNodes(obj: any) {
if (obj === null || obj === undefined ) {
return;
}
if (typeof obj !== 'object' && typeof obj !== undefined) {
return;
}
const keys = Object.keys(obj);
for (var index in Object.keys(obj)) {
if (obj[keys[index]] && obj[keys[index]] != {}) {
DistributedTest.removeEmptyNodes(obj[keys[index]]);
}
if (obj[keys[index]] == undefined || obj[keys[index]] == null || (typeof obj[keys[index]] == "object" && Object.keys(obj[keys[index]]).length == 0)) {
tl.debug(`Removing node ${keys[index]} as its value is ${obj[keys[index]]}.`);
delete obj[keys[index]];
}
}
}

private createTestSourcesFile(): string {
try {
let sourceFilter = tl.getDelimitedInput('testAssemblyVer2', '\n', true);
console.log(tl.loc('UserProvidedSourceFilter', sourceFilter.toString()));

if (this.inputDataContract.TestSelectionSettings.TestSelectionType.toLowerCase() !== 'testassemblies') {
sourceFilter = ['**\\*', '!**\\obj\\*'];
Expand Down Expand Up @@ -130,6 +150,41 @@ export class DistributedTest {
}
}

private setProfilerVariables(envVars: { [key: string]: string; }) : { [key: string]: string; } {
const vsTestPackageLocation = tl.getVariable(constants.VsTestToolsInstaller.PathToVsTestToolVariable);

// get path to Microsoft.IntelliTrace.ProfilerProxy.dll (amd64)
let amd64ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\amd64\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (amd64ProfilerProxy && amd64ProfilerProxy.length !== 0) {

envVars['COR_PROFILER_PATH_64'] = amd64ProfilerProxy[0];
} else {
// Look in x64 also for Microsoft.IntelliTrace.ProfilerProxy.dll (x64)
amd64ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\x64\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (amd64ProfilerProxy && amd64ProfilerProxy.length !== 0) {

envVars['COR_PROFILER_PATH_64'] = amd64ProfilerProxy[0];
} else {
utils.Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1043, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

utils.Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1042, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

// get path to Microsoft.IntelliTrace.ProfilerProxy.dll (x86)
const x86ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\x86\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (x86ProfilerProxy && x86ProfilerProxy.length !== 0) {
envVars['COR_PROFILER_PATH_32'] = x86ProfilerProxy[0];
} else {
utils.Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1044, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

return envVars;
}

private inputDataContract: inputdatacontract.InputDataContract;
private dtaPid: number;
}
56 changes: 0 additions & 56 deletions Tasks/VsTestV2/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as Q from 'q';
import * as models from './models';
import * as os from 'os';
import * as ci from './cieventlogger';
import * as constants from './constants';

const str = require('string');
const uuid = require('uuid');
Expand Down Expand Up @@ -205,41 +204,6 @@ export class Helper {
return argument;
}

public static setProfilerVariables(envVars: { [key: string]: string; }) : { [key: string]: string; } {
const vsTestPackageLocation = tl.getVariable(constants.VsTestToolsInstaller.PathToVsTestToolVariable);

// get path to Microsoft.IntelliTrace.ProfilerProxy.dll (amd64)
let amd64ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\amd64\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (amd64ProfilerProxy && amd64ProfilerProxy.length !== 0) {

envVars.COR_PROFILER_PATH_64 = amd64ProfilerProxy[0];
} else {
// Look in x64 also for Microsoft.IntelliTrace.ProfilerProxy.dll (x64)
amd64ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\x64\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (amd64ProfilerProxy && amd64ProfilerProxy.length !== 0) {

envVars.COR_PROFILER_PATH_64 = amd64ProfilerProxy[0];
} else {
Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1043, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1042, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

// get path to Microsoft.IntelliTrace.ProfilerProxy.dll (x86)
const x86ProfilerProxy = tl.findMatch(vsTestPackageLocation, '**\\x86\\Microsoft.IntelliTrace.ProfilerProxy.dll');
if (x86ProfilerProxy && x86ProfilerProxy.length !== 0) {
envVars.COR_PROFILER_PATH_32 = x86ProfilerProxy[0];
} else {
Helper.publishEventToCi(constants.AreaCodes.TOOLSINSTALLERCACHENOTFOUND, tl.loc('testImpactAndCCWontWork'), 1044, false);
tl.warning(tl.loc('testImpactAndCCWontWork'));
}

return envVars;
}

// set the console code page to "UTF-8"
public static setConsoleCodePage() {
tl.debug("Changing active code page to UTF-8");
Expand All @@ -263,24 +227,4 @@ export class Helper {
tl.debug(`Failed to upload file ${file} with error ${err}`);
}
}

// Utility function used to remove empty or spurious nodes from the input json file
public static removeEmptyNodes(obj: any) {
if (obj === null || obj === undefined ) {
return;
}
if (typeof obj !== 'object' && typeof obj !== undefined) {
return;
}
const keys = Object.keys(obj);
for (var index in Object.keys(obj)) {
if (obj[keys[index]] && obj[keys[index]] != {}) {
Helper.removeEmptyNodes(obj[keys[index]]);
}
if (obj[keys[index]] == undefined || obj[keys[index]] == null || (typeof obj[keys[index]] == "object" && Object.keys(obj[keys[index]]).length == 0)) {
tl.debug(`Removing node ${keys[index]} as its value is ${obj[keys[index]]}.`);
delete obj[keys[index]];
}
}
}
}
18 changes: 7 additions & 11 deletions Tasks/VsTestV2/inputdatacontract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export interface InputDataContract {
AgentName : string;
AccessToken : string;
AccessTokenType : string;
CollectionUri : string;
RunIdentifier : string;
TeamProject : string;
Expand All @@ -16,11 +15,13 @@ export interface InputDataContract {
DistributionSettings : DistributionSettings;
ExecutionSettings : ExecutionSettings;
Logging : Logging;
TiaBaseLineBuildIdFile : string;
UseNewCollector : boolean;
}

export interface TestReportingSettings {
TestRunTitle : string;
TestResultsDirectory : string;
TestResultDirectory : string;
}

export interface TestSelectionSettings {
Expand All @@ -39,14 +40,12 @@ export interface TestPlanTestSuiteSettings {
}

export interface TfsSpecificSettings {
BuildDefinitionId : number;
ReleaseDefinitionId : number;
DefinitionId : number;
BuildId : number;
BuildUri : string;
ReleaseId : number;
ReleaseUri : string;
ReleaseEnvironmentUri : string;
WorkFolder : string;
}

export interface TestSpecificSettings {
Expand Down Expand Up @@ -81,19 +80,16 @@ export interface DistributionSettings {
}

export interface ExecutionSettings {
DefaultTestBatchSize : number;
AssemblyLevelParallelism : boolean;
CodeCoverageEnabled : boolean;
PathToCustomTestAdapters : string;
CustomTestAdapters : string;
ExecutionMode : string;
IgnoreTestFailures : boolean;
ProceedAfterAbortedTestCase : boolean;
SettingsFile : string;
AdditionalConsoleParameters : string;
OverridenParameters : string;
RerunSettings : RerunSettings;
RunTestsInIsolation : boolean;
TiaSettings : TiaSettings;
TempFolder : string;
VideoDataCollectorEnabled : boolean;
}

Expand All @@ -104,7 +100,7 @@ export interface TiaSettings {
SourcesDirectory : string;
FileLevel : boolean;
FilterPaths : string;
UserMapFile : string;
UserMapFile : string;
IsPrFlow : boolean;
}

Expand Down
Loading