Skip to content

Commit

Permalink
Add Remote File Share tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyang-li committed Mar 22, 2024
1 parent 355b0b4 commit b404b11
Show file tree
Hide file tree
Showing 13 changed files with 1,665 additions and 236 deletions.
3 changes: 2 additions & 1 deletion location_matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"centraluseuap",
"westeurope",
"northeurope",
"eastus"
"eastus",
"westus2"
]
}
8 changes: 8 additions & 0 deletions src/Function/STFRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogge
testSuiteResponse.Endpoints.Add("PrivatePort", response.StatusCode);
log.LogInformation("PrivatePort: " + response.StatusCode.ToString());

response = Helper.SendRequest(client, windowsAppUrl + "/FileShare", HttpMethod.Post);
testSuiteResponse.Endpoints.Add("FileShare", response.StatusCode);
log.LogInformation("FileShare: " + response.StatusCode.ToString());

string jsonString = JsonConvert.SerializeObject(testSuiteResponse, Formatting.Indented);
log.LogInformation(jsonString);

Expand Down Expand Up @@ -183,6 +187,10 @@ public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogge
testSuiteResponse.Endpoints.Add("PingPeeredVm", response.StatusCode);
log.LogInformation("PingPeeredVm: " + response.StatusCode.ToString());

response = Helper.SendRequest(client, linuxAppUrl + "/FileShare", HttpMethod.Post);
testSuiteResponse.Endpoints.Add("FileShare", response.StatusCode);
log.LogInformation("FileShare: " + response.StatusCode.ToString());

string jsonString = JsonConvert.SerializeObject(testSuiteResponse, Formatting.Indented);
log.LogInformation(jsonString);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Azure.Storage.Blobs.Specialized;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SwiftTestingFrameworkAPI.Utils;
using System;
using System.IO;

namespace SwiftTestingFrameworkAPI.Controllers
{
[ApiController]
[Route("FileShare")]
public class RemoteFileShareController : ControllerBase
{
private readonly ILogger<RemoteFileShareController> _logger;
private const string TestName = "FileShare";

public RemoteFileShareController(ILogger<RemoteFileShareController> logger)
{
_logger = logger;
}

[HttpGet]
public TestResponse GetInfo()
{
string testDetails = "Write to file share mount through Vnet Integration";
return new TestResponse(Constants.ApiVersion, TestName, string.Empty, testDetails, string.Empty);
}

[HttpPost]
public ObjectResult WriteToFileShare()
{
TestResponse testResponse;
try
{
System.IO.File.WriteAllText(Constants.MountFilePath, "Hello world!");
testResponse = new TestResponse(Constants.ApiVersion, TestName, "Success", "Write to remote file share successful.", string.Empty);
return StatusCode(200, testResponse);
}
catch (Exception ex)
{
//Replace with AntaresEventProvider or email send functionality
testResponse = new TestResponse(Constants.ApiVersion, TestName, "Failure", string.Empty, ex.Message + ex.StackTrace);
return StatusCode(555, testResponse);
}
}
}
}
1 change: 1 addition & 0 deletions src/SwiftTestingFrameworkAPI/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class Constants
public const string SqlDatabaseConnectionStringName = "SQLAZURECONNSTR_Database";
public const string PrivateSiteHostname = "{0}-privateapp.azurewebsites.net";
public const string PrivateSiteScmHostname = "{0}-privateapp.scm.azurewebsites.net";
public const string MountFilePath = "/mounts/remote/testfile.txt";
}
}
211 changes: 197 additions & 14 deletions templates/stf-centraluseuap.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@
"storageAccountName": "[concat(replace(parameters('projectName'), '-', ''), 'stor')]",
"funcStorageAccountName": "[concat(replace(parameters('projectName'), '-', ''), 'fstor')]",
"keyVaultName": "[concat(parameters('projectName'), '-vault')]",
"secretName": "secret1",
"secretValue": "secretValue",
"secretResourceId": "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secretName'))]",
"secret1Name": "secret1",
"secret1Value": "secretValue",
"storageKeySecretName": "storageKey",
"secret1ResourceId": "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secret1Name'))]",
"storageKeySecretResourceId": "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('storageKeySecretName'))]",
"storagePrivateEndpointConnName": "[concat(parameters('projectName'), '-stor-pe')]",
"sitePrivateEndpointConnName": "[concat(parameters('projectName'), '-site-pe')]",
"filePrivateEndpointConnName": "[concat(parameters('projectName'), '-file-pe')]",
"blobPrivateZoneName": "privatelink.blob.core.windows.net",
"sitePrivateZoneName": "privatelink.azurewebsites.net",
"filePrivateZoneName": "privatelink.file.core.windows.net",
"administratorLogin": "swiftadmin",
"administratorLoginPassword": "iis6!dfu"
"administratorLoginPassword": "iis6!dfu",
"mountPath": "/mounts/remote"
},
"resources": [
{
Expand Down Expand Up @@ -656,6 +661,21 @@
"provisioningState": "Succeeded"
}
},
{
"type": "Microsoft.Network/privateDnsZones",
"apiVersion": "2018-09-01",
"name": "[variables('filePrivateZoneName')]",
"location": "global",
"properties": {
"maxNumberOfRecordSets": 25000,
"maxNumberOfVirtualNetworkLinks": 1000,
"maxNumberOfVirtualNetworkLinksWithRegistration": 100,
"numberOfRecordSets": 3,
"numberOfVirtualNetworkLinks": 0,
"numberOfVirtualNetworkLinksWithRegistration": 0,
"provisioningState": "Succeeded"
}
},
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2018-09-01",
Expand Down Expand Up @@ -688,6 +708,22 @@
}
}
},
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2018-09-01",
"name": "[concat(variables('filePrivateZoneName'), '/n33a3tkelqvqk')]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('filePrivateZoneName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]"
],
"properties": {
"registrationEnabled": false,
"virtualNetwork": {
"id": "[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]"
}
}
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-11-01",
Expand Down Expand Up @@ -752,6 +788,37 @@
}
}
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-11-01",
"name": "[variables('filePrivateEndpointConnName')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]"
],
"location": "[parameters('location')]",
"properties": {
"privateLinkServiceConnections": [
{
"name": "[variables('filePrivateEndpointConnName')]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"groupIds": [
"file"
],
"privateLinkServiceConnectionState": {
"status": "Approved",
"description": "Auto-Approved",
"actionsRequired": "None"
}
}
}
],
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vNetName'), variables('vNetSubnetName'))]"
}
}
},
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-11-01",
Expand Down Expand Up @@ -788,6 +855,24 @@
]
}
},
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-11-01",
"name": "[concat(variables('filePrivateEndpointConnName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Network/privateEndpoints', variables('filePrivateEndpointConnName'))]"
],
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privatelink-file-core-windows-net",
"properties": {
"privateDnsZoneId": "[resourceId('Microsoft.Network/privateDnsZones', variables('filePrivateZoneName'))]"
}
}
]
}
},
{
"name": "[variables('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
Expand All @@ -799,13 +884,38 @@
"kind": "StorageV2",
"properties": {
"publicNetworkAccess": "Disabled",
"allowBlobPublicAccess": false
"allowBlobPublicAccess": false,
"networkAcls": {
"defaultAction": "Deny",
"bypass": "AzureServices"
}
},
"sku": {
"name": "Premium_LRS",
"tier": "Premium"
"name": "Standard_LRS"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2023-01-01",
"name": "[format('{0}/default/{1}', variables('storageAccountName'), 'windows')]",
"properties": {
"enabledProtocols": "SMB"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2023-01-01",
"name": "[format('{0}/default/{1}', variables('storageAccountName'), 'linux')]",
"properties": {
"enabledProtocols": "SMB"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"name": "[variables('funcStorageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
Expand Down Expand Up @@ -875,14 +985,26 @@
{
"type": "Microsoft.KeyVault/vaults/secrets",
"apiVersion": "2021-11-01-preview",
"name": "[format('{0}/{1}', variables('keyVaultName'), variables('secretName'))]",
"name": "[format('{0}/{1}', variables('keyVaultName'), variables('secret1Name'))]",
"properties": {
"value": "[variables('secretValue')]"
"value": "[variables('secret1Value')]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
]
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"apiVersion": "2021-11-01-preview",
"name": "[format('{0}/{1}', variables('keyVaultName'), variables('storageKeySecretName'))]",
"properties": {
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2018-11-01').keys[0].value]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-06-01",
Expand Down Expand Up @@ -1036,13 +1158,39 @@
"type": "config",
"apiVersion": "2018-11-01",
"properties": {
"secret1": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('secretResourceId')).secretUriWithVersion, ')')]",
"secret1": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('secret1ResourceId')).secretUriWithVersion, ')')]",
"storageKeySecret": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageKeySecretResourceId')).secretUriWithVersion, ')')]",
"WEBSITE_DNS_SERVER": "168.63.129.16",
"WEBSITE_VNET_ROUTE_ALL": "1",
"WEBSITE_CONTENTOVERVNET": "1",
"WEBSITE_CONTENTSHARE": "windows",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1)]",
"ResourceGroup": "[parameters('projectName')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('windowsAppName'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secretName'))]"
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secret1Name'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('storageKeySecretName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"name": "azurestorageaccounts",
"type": "config",
"apiVersion": "2022-09-01",
"properties": {
"remote": {
"type": "AzureFiles",
"accountName": "[variables('storageAccountName')]",
"shareName": "windows",
"mountPath": "[variables('mountPath')]",
"accessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2018-11-01').keys[0].value]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('windowsAppName'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('storageKeySecretName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
}
]
Expand Down Expand Up @@ -1082,7 +1230,16 @@
"connectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1)]",
"type": "Custom"
}
]
],
"azureStorageAccounts": {
"remote": {
"mountPath": "[variables('mountPath')]",
"accountName": "[variables('storageAccountName')]",
"type": "AzureFiles",
"shareName": "linux",
"accessKey": "listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1)"
}
}
},
"scmSiteAlsoStopped": false,
"clientAffinityEnabled": false,
Expand All @@ -1103,13 +1260,39 @@
"type": "config",
"apiVersion": "2018-11-01",
"properties": {
"secret1": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('secretResourceId')).secretUriWithVersion, ')')]",
"secret1": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('secret1ResourceId')).secretUriWithVersion, ')')]",
"storageKeySecret": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageKeySecretResourceId')).secretUriWithVersion, ')')]",
"WEBSITE_VNET_ROUTE_ALL": "1",
"WEBSITE_DNS_SERVER": "168.63.129.16",
"WEBSITE_CONTENTOVERVNET": "1",
"WEBSITE_CONTENTSHARE": "windows",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1)]",
"ResourceGroup": "[parameters('projectName')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('linuxAppName'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secretName'))]"
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('secret1Name'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('storageKeySecretName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"name": "azurestorageaccounts",
"type": "config",
"apiVersion": "2022-09-01",
"properties": {
"remote": {
"type": "AzureFiles",
"accountName": "[variables('storageAccountName')]",
"shareName": "linux",
"mountPath": "[variables('mountPath')]",
"accessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2018-11-01').keys[0].value]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('linuxAppName'))]",
"[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyvaultName'), variables('storageKeySecretName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
}
]
Expand Down
Loading

0 comments on commit b404b11

Please sign in to comment.