Skip to content

Commit

Permalink
Merge branch 'master' into fix14852
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkKharitonov authored Jul 17, 2021
2 parents 6368b47 + 43c1554 commit 380b963
Show file tree
Hide file tree
Showing 26 changed files with 586 additions and 526 deletions.
2 changes: 2 additions & 0 deletions Tasks/AzureIoTEdgeV2/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export default class Constants {
public static folderNameModules = "modules";
public static folderNameConfig = "config";
public static iotedgedev = "iotedgedev";
public static iotedgehubdev = "iotedgehubdev";
public static iotedgedevLockVersionKey = "IOTEDGEDEV_VERSION";
public static iotedgehubdevLockVersionKey = "IOTEDGEHUBDEV_VERSION";
public static iotedgedevDefaultVersion = "3.0.0";
public static iotedgedevEnv = {
registryServer: "CONTAINER_REGISTRY_SERVER",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 4,
"Patch": 8
"Patch": 9
},
"preview": false,
"showEnvironmentVariables": true,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 4,
"Patch": 8
"Patch": 9
},
"preview": false,
"showEnvironmentVariables": true,
Expand Down
37 changes: 28 additions & 9 deletions Tasks/AzureIoTEdgeV2/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,44 @@ export default class Util {
}

let cmds: Cmd[] = [];
let version = Constants.iotedgedevDefaultVersion;
if (tl.getVariable(Constants.iotedgedevLockVersionKey)) {
version = tl.getVariable(Constants.iotedgedevLockVersionKey);
}
tl.debug(`The specified iotedgedev version is: ${version}`);
let edgeDevVersion = Constants.iotedgedevDefaultVersion;
let lockSimVersion = tl.getVariable(Constants.iotedgehubdevLockVersionKey);
// if no version is specified, iotedgedev installs default simulator version

// install pre reqs
if (tl.osType() === Constants.osTypeLinux) {
cmds = [
{ path: `sudo`, arg: `apt-get update`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `-H pip3 install wheel --upgrade`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `pip3 install importlib-metadata==2.1.1`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `apt-get install -y python3-setuptools`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `pip3 install ${Constants.iotedgedev}~=${version}`, execOption: Constants.execSyncSilentOption },
]

let lockVersion = tl.getVariable(Constants.iotedgedevLockVersionKey);
if (lockVersion) {
edgeDevVersion = lockVersion;
}
cmds.push({ path: `sudo`, arg: `pip3 install ${Constants.iotedgedev}==${edgeDevVersion}`, execOption: Constants.execSyncSilentOption });

if (lockSimVersion) {
cmds.push({ path: `sudo`, arg: `pip3 uninstall ${Constants.iotedgehubdev} -y`, execOption: Constants.execSyncSilentOption });
cmds.push({ path: `sudo`, arg: `pip3 install ${Constants.iotedgehubdev}==${lockSimVersion}`, execOption: Constants.execSyncSilentOption });
}
} else if (tl.osType() === Constants.osTypeWindows) {
cmds = [
{ path: `pip`, arg: `install ${Constants.iotedgedev}~=${version}`, execOption: Constants.execSyncSilentOption },
]
if (tl.getVariable(Constants.iotedgedevLockVersionKey)) {
edgeDevVersion = tl.getVariable(Constants.iotedgedevLockVersionKey);
}
cmds.push({path: `pip`, arg: `install ${Constants.iotedgedev}==${edgeDevVersion}`, execOption: Constants.execSyncSilentOption },)

if (lockSimVersion) {
cmds.push({ path: `pip`, arg: `uninstall ${Constants.iotedgehubdev} -y`, execOption: Constants.execSyncSilentOption },);
cmds.push({ path: `pip`, arg: `install ${Constants.iotedgehubdev}==${lockSimVersion}`, execOption: Constants.execSyncSilentOption },);
}
}

tl.debug(`The specified iotedgedev version is: ${edgeDevVersion}`);
tl.debug(`The specified iotedgehubdev version is: ${lockSimVersion}`);

try {
for (let cmd of cmds) {
let result = tl.execSync(cmd.path, cmd.arg, cmd.execOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"loc.input.help.preserveTimestamp": "Using the original source file, preserve the target file timestamp.",
"loc.input.label.retryCount": "Retry count to copy the file",
"loc.input.help.retryCount": "Specify the retry count to copy the file. It might help to resolve intermittent issues e.g. with UNC target paths on a remote host.",
"loc.input.label.delayBetweenRetries": "Delay between two retries.",
"loc.input.help.delayBetweenRetries": "Specify the delay between two retries. It might help to be more resilient to intermittent issues e.g. with UNC target paths on a remote host.",
"loc.input.label.ignoreMakeDirErrors": "Ignore errors during creation of target folder.",
"loc.input.help.ignoreMakeDirErrors": "Ignore errors which happen during creation of target folder. This could be useful to avoid issues with parallel execution of task by several agents with one target folder.",
"loc.messages.FoundNFiles": "found %d files",
Expand Down
29 changes: 4 additions & 25 deletions Tasks/CopyFilesV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('CopyFiles L0 Suite', function () {
after(() => { });

it('copy files from srcdir to destdir', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copyAllFiles.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -51,7 +50,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('copy files from srcdir to destdir with brackets in src path', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copyAllFilesWithBracketsInSrcPath.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -91,7 +89,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('copy files and subtract based on exclude pattern', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copySubtractExclude.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -122,55 +119,50 @@ describe('CopyFiles L0 Suite', function () {
});

it('fails if Contents not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfContentsNotSet.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();

assert(runner.failed, 'should have failed');
assert(runner.createdErrorIssue('Unhandled: Input required: Contents'), 'should have created error issue');
assert(runner.createdErrorIssue('Error: Input required: Contents'), 'should have created error issue');
done();
});

it('fails if SourceFolder not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfSourceFolderNotSet.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();

assert(runner.failed, 'should have failed');
assert(runner.createdErrorIssue('Unhandled: Input required: SourceFolder'), 'should have created error issue');
assert(runner.createdErrorIssue('Error: Input required: SourceFolder'), 'should have created error issue');
done();
});

it('fails if TargetFolder not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfTargetFolderNotSet.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();

assert(runner.failed, 'should have failed');
assert(runner.createdErrorIssue('Unhandled: Input required: TargetFolder'), 'should have created error issue');
assert(runner.createdErrorIssue('Error: Input required: TargetFolder'), 'should have created error issue');
done();
});

it('fails if SourceFolder not found', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfSourceFolderNotFound.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();

assert(runner.failed, 'should have failed');
assert(runner.createdErrorIssue(`Unhandled: Not found ${path.normalize('/srcDir')}`), 'should have created error issue');
assert(runner.createdErrorIssue(`Error: Not found ${path.normalize('/srcDir')}`), 'should have created error issue');
done();
});

it('fails if target file is a directory', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfTargetFileIsDir.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand All @@ -182,7 +174,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('skips if exists', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0skipsIfExists.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand All @@ -207,7 +198,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('overwrites if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0overwritesIfSpecified.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand All @@ -232,7 +222,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('preserves timestamp if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0preservesTimestampIfSpecified.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -260,7 +249,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('cleans if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0cleansIfSpecified.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -291,7 +279,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('cleans if specified and target is file', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0cleansIfSpecifiedAndTargetIsFile.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
Expand Down Expand Up @@ -319,8 +306,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('roots patterns', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0rootsPatterns.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();
Expand All @@ -341,8 +326,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('ignores errors during target folder creation if ignoreMakeDirErrors is true', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0IgnoresMakeDirError.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();
Expand All @@ -361,8 +344,6 @@ describe('CopyFiles L0 Suite', function () {
});

it('fails if there are errors during target folder creation if ignoreMakeDirErrors is false', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0FailsIfThereIsMkdirError.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();
Expand All @@ -375,8 +356,6 @@ describe('CopyFiles L0 Suite', function () {

if (process.platform == 'win32') {
it('overwrites readonly', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0overwritesReadonly.js');
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
runner.run();
Expand Down
Loading

0 comments on commit 380b963

Please sign in to comment.