Skip to content

Commit

Permalink
Merge branch 'master' into users/jcfiorenzano/add-buildkit-support-do…
Browse files Browse the repository at this point in the history
…cker-v0-v1
  • Loading branch information
jcfiorenzano authored Oct 7, 2021
2 parents b1409d4 + 40780fd commit dfea85b
Show file tree
Hide file tree
Showing 21 changed files with 701 additions and 872 deletions.
105 changes: 53 additions & 52 deletions Tasks/AzureAppServiceSettingsV1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/AzureAppServiceSettingsV1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/node": "^10.17.0",
"@types/q": "1.0.7",
"@types/uuid": "^8.3.0",
"azure-pipelines-tasks-azurermdeploycommon": "^2.0.4",
"azure-pipelines-tasks-azurermdeploycommon": "^2.1.1",
"moment": "2.21.0",
"q": "1.4.1",
"xml2js": "0.4.13"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureAppServiceSettingsV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 187,
"Minor": 194,
"Patch": 0
},
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureAppServiceSettingsV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 187,
"Minor": 194,
"Patch": 0
},
"minimumAgentVersion": "2.104.1",
Expand Down
14 changes: 13 additions & 1 deletion Tasks/JavaToolInstallerV0/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ describe('JavaToolInstaller L0 Suite', function () {
it('should run successfully when fetching JDK files from azure storage', function () {
this.timeout(20000);

const testPath: string = path.join(__dirname, 'L0DownloadArtifactsFromAzureStorage.js');
const testPath: string = path.join(__dirname, 'L0DownloadsJdkFromAzureStorage.js');
const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath);

testRunner.run();

assert(testRunner.succeeded, 'task should have succeeded.');
});

it('should run successfully when fetching JDK files from azure storage from subfolder', function () {
this.timeout(20000);

const testPath: string = path.join(__dirname, 'L0DownloadsJdkFromAzureStorageSubFolder.js');
const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath);

testRunner.run();

assert((testRunner.stdOutContained('jdkFileName: DestinationDirectory\\JDKname.tar.gz') || testRunner.stdOutContained('jdkFileName: DestinationDirectory/JDKname.tar.gz')) , 'JDK archive should unpack in the right destination directory');
assert(testRunner.succeeded, 'task should have succeeded.');
});

it('should fail when JavaToolInstaller is run with to destination folder specified', function () {
this.timeout(20000);

Expand Down
62 changes: 58 additions & 4 deletions Tasks/JavaToolInstallerV0/Tests/L0DownloadsJdkFromAzureStorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import msRestAzure = require('azure-pipelines-tasks-azure-arm-rest-v2/azure-arm-common');
import path = require('path');
import mockTask = require('azure-pipelines-task-lib/mock-task');

Expand All @@ -12,10 +13,13 @@ tr.setInput("jdkArchitectureOption", "x64");
tr.setInput("azureResourceManagerEndpoint", "ARM1");
tr.setInput("azureStorageAccountName", "storage1");
tr.setInput("azureContainerName", "container1");
tr.setInput("azureCommonVirtualFile", "");
tr.setInput("jdkDestinationDirectory", "javaJDK");
tr.setInput("azureCommonVirtualFile", "JDKname.tar.gz");
tr.setInput("jdkDestinationDirectory", "DestinationDirectory");
tr.setInput("cleanDestinationDirectory", "false");

process.env['AGENT_TOOLSDIRECTORY'] = '/tool';
process.env['AGENT_VERSION'] = '2.194.0';

process.env['ENDPOINT_URL_ID1'] = 'http://url';
process.env['ENDPOINT_AUTH_PARAMETER_connection1_username'] = 'dummyusername';
process.env['ENDPOINT_AUTH_PARAMETER_connection1_password'] = 'dummypassword';
Expand All @@ -29,7 +33,19 @@ process.env['ENDPOINT_DATA_ARM1_environmentAuthorityUrl'] = 'dummyurl';
process.env['ENDPOINT_DATA_ARM1_activeDirectoryServiceEndpointResourceId'] = 'dummyResourceId';
process.env['ENDPOINT_DATA_ARM1_subscriptionId'] = 'dummySubscriptionId';

tr.registerMock("azure-pipelines-tasks-azure-arm-rest/azure-arm-storage", {
const a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"stats": {
"DestinationDirectory\\JDKname.tar.gz": true,
"DestinationDirectory/JDKname.tar.gz": true,
},
"find": {
"DestinationDirectory": ["rootJDK/", "rootJDK/secondlevelJDK2"],
},
};

tr.setAnswers(a);

tr.registerMock("azure-pipelines-tasks-azure-arm-rest-v2/azure-arm-storage", {
StorageManagementClient: function (A, B) {
return {
storageAccounts: {
Expand All @@ -56,10 +72,48 @@ tr.registerMock("azure-pipelines-tasks-azure-arm-rest/azure-arm-storage", {
}
});

tr.registerMock("azure-pipelines-tasks-azure-arm-rest/azure-arm-common", {
tr.registerMock("azure-pipelines-tasks-azure-arm-rest-v2/azure-arm-common", {
ApplicationTokenCredentials: function(A,B,C,D,E,F,G) {
return {};
}
});

tr.registerMock('./AzureStorageArtifacts/AzureStorageArtifactDownloader',{
AzureStorageArtifactDownloader: function(A,B,C) {
return {
downloadArtifacts: function(A,B) {
return "pathFromDownloader";
}
}
}
})

const mtl = require("azure-pipelines-tool-lib/tool")
const mtlClone = Object.assign({}, mtl);

mtlClone.prependPath = function(variable1: string, variable2: string) {
return {};
};

tr.registerMock("azure-pipelines-tool-lib/tool", mtlClone);

const mfs = require('fs')
const mfsClone = Object.assign({}, mfs);

mfsClone.lstatSync = function(variable: string) {
return {
isDirectory: function() {
return true;
}
};
};

mfsClone.existsSync = function (variable: string) {
if (variable === "DestinationDirectory\\econdlevelJDK2" || variable === "DestinationDirectory/econdlevelJDK2") {
return false;
} else return true;
}

tr.registerMock('fs', mfsClone);

tr.run();
Loading

0 comments on commit dfea85b

Please sign in to comment.