Skip to content

Commit b19f6e9

Browse files
author
Andrey Fedyashov
committed
follow up fixes due to AZ migration
1 parent cdefb96 commit b19f6e9

File tree

4 files changed

+295
-1
lines changed

4 files changed

+295
-1
lines changed

src/ResourceManager/StorageSync/Commands.StorageSync/Az.StorageSync.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ RequiredModules = @(@{ModuleName = 'Az.Profile'; ModuleVersion = '0.7.0'; })
6363
# TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
66-
# FormatsToProcess = ''
66+
FormatsToProcess = '.\Microsoft.Azure.Commands.StorageSync.Evaluation.format.ps1xml'
6767

6868
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6969
NestedModules = @('.\Microsoft.Azure.Commands.StorageSync.dll')

src/ResourceManager/StorageSync/Commands.StorageSync/Commands.StorageSync.Netcore.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@
5353
<Content Include="help\**\*" CopyToOutputDirectory="PreserveNewest" />
5454
</ItemGroup>
5555

56+
<ItemGroup>
57+
<None Update="Microsoft.Azure.Commands.StorageSync.Evaluation.format.ps1xml">
58+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59+
</None>
60+
</ItemGroup>
61+
5662
</Project>
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
param(
2+
[Parameter(Mandatory=$true)]
3+
$Configuraton)
4+
5+
$ErrorActionPreference = "Stop"
6+
$scriptpath = $MyInvocation.MyCommand.Path
7+
$scriptDirectory = Split-Path $scriptpath
8+
$scriptFileName = Split-Path $scriptpath -Leaf
9+
10+
if (gcm Invoke-AzureRmStorageSyncCompatibilityCheck -ErrorAction SilentlyContinue)
11+
{
12+
throw "Invoke-AzureRmStorageSyncCompatibilityCheck is already available. Cannot continue with module debugging."
13+
}
14+
15+
$azProfilePath = Join-Path $scriptDirectory "..\..\..\..\src\Package\$Configuraton\ResourceManager\AzureResourceManager\Az.Profile\Az.Profile.psd1"
16+
Import-Module $azProfilePath -Verbose
17+
18+
$azStorageSyncPath = Join-Path $scriptDirectory "..\..\..\..\src\Package\$Configuraton\ResourceManager\AzureResourceManager\Az.StorageSync\Az.StorageSync.psd1"
19+
Import-Module $azStorageSyncPath -Verbose
20+
21+
$VerbosePreference='Continue'
22+
23+
function prompt { return "PS> " }
24+
25+
Write-Verbose 'Your debugger is attached to current PowerShell instance'
26+
Write-Verbose 'To recreate a test data set and perform an evaluation run'
27+
Write-Verbose ' Perform-Test -Full'
28+
Write-Verbose 'To perform an evaluation for an already created dataset run'
29+
Write-Verbose ' Perform-Test'
30+
Write-Verbose 'Use Get-DataSetLocation to find location of the dataset'
31+
32+
function Get-Configuration
33+
{
34+
Get-Content -Raw -Path (Join-Path $scriptDirectory "config.json") | ConvertFrom-Json
35+
}
36+
37+
function Build-CharacterTable
38+
{
39+
param ($Configuration)
40+
41+
$blacklistOfCodePoints = $Configuration.BlacklistOfCodePoints
42+
$whitelistOfCodePointRanges = $Configuration.WhitelistOfCodePointRanges
43+
44+
$arraySize = 0x10FFFF + 1
45+
$blacklistedCodePointsTable = new-object bool[] $arraySize
46+
for ($i = 0; $i -lt $arraySize; $i += 1)
47+
{
48+
$blacklistedCodePointsTable[$i] = $blacklistOfCodePoints.Contains($i) -or
49+
($whitelistOfCodePointRanges.Where({ ($_.Start -le $i) -and ($_.End -ge $i) }).Count -eq 0);
50+
}
51+
return $blacklistedCodePointsTable
52+
}
53+
54+
function CreateItem
55+
{
56+
param ($path, $name, $itemType)
57+
58+
$fullpath = Join-Path $path $name
59+
60+
try
61+
{
62+
if (Test-Path $fullpath)
63+
{
64+
return
65+
}
66+
67+
if (!(Test-Path $path))
68+
{
69+
New-Item -Path $path -ItemType Directory | Out-Null
70+
}
71+
72+
New-Item -Path $path -Name $name -ItemType $itemType | Out-Null
73+
}
74+
catch
75+
{
76+
throw "Couldn't handle path:$path, name:$name, itemType:$itemType"
77+
}
78+
}
79+
80+
function CreateItemsWithInvalidCharacters
81+
{
82+
param ($path, $configuration, $blockedCharactersTable, $itemType)
83+
84+
Write-Verbose "Creating items of type $itemType with invalid characters"
85+
$skippedCodePoints = 0
86+
$succeededCodePoints = 0
87+
for ($i = 0; $i -lt $blockedCharactersTable.Count; $i += 1)
88+
{
89+
$isBlocked = $blockedCharactersTable[$i];
90+
if ($isBlocked)
91+
{
92+
$invalid_character_or_surrogate_pair = "<unavailable>"
93+
try
94+
{
95+
$invalid_character_or_surrogate_pair = [char]::ConvertFromUtf32($i)
96+
if ($invalid_character_or_surrogate_pair.Length -gt 1)
97+
{
98+
CreateItem -path $path -name ("{1}invalidSurrogatePair_occurence1_{0}_occurence2_{0}" -f $invalid_character_or_surrogate_pair, $itemType) -itemType $itemType
99+
}
100+
else
101+
{
102+
CreateItem -path $path -name ("{1}invalidChar_occurence1_{0}_occurence2_{0}" -f $invalid_character_or_surrogate_pair, $itemType) -itemType $itemType
103+
}
104+
$succeededCodePoints += 1
105+
}
106+
catch
107+
{
108+
Write-Warning ("Skipping blocked codepoint #{0} as hex 0x{0:X} '{1}' : blocked '{2}'. Error: {3}" -f $i, $invalid_character_or_surrogate_pair, $isBlocked, $_)
109+
$skippedCodePoints += 1
110+
}
111+
}
112+
}
113+
114+
Write-Verbose "Created $succeededCodePoints items, skipped $skippedCodePoints"
115+
}
116+
117+
function Ensure-RobocopySampleLocation
118+
{
119+
$sampleDir = Join-Path $env:TEMP "robocopy-sample"
120+
121+
if (Test-Path $sampleDir)
122+
{
123+
Remove-Item $sampleDir -Recurse | Out-Null
124+
}
125+
126+
New-Item $sampleDir -ItemType Directory | Out-Null
127+
128+
return $sampleDir
129+
}
130+
131+
function CreateDirectoryWithRobocopy
132+
{
133+
param ($targetDir)
134+
135+
$sampleDir = Ensure-RobocopySampleLocation
136+
137+
Write-Verbose ". robocopy.exe $sampleDir $targetDir /MIR"
138+
139+
. robocopy.exe $sampleDir $targetDir /MIR
140+
}
141+
142+
function Get-DataSetLocation
143+
{
144+
return Join-Path $env:TEMP "EvalToolDataSet"
145+
}
146+
147+
function Clear-DataSetLocation
148+
{
149+
CreateDirectoryWithRobocopy -targetDir (Get-DataSetLocation)
150+
}
151+
152+
function Perform-Test
153+
{
154+
param ([switch]$Full, [switch]$SkipInvalidCharacters, [switch]$TrailingSlash, [switch]$AlternateSlash)
155+
156+
$dataSetLocation = Get-DataSetLocation
157+
$dataSetLocationForTest = $dataSetLocation
158+
159+
$slashCharacter = if ($AlternateSlash) { "/" } else { "\" }
160+
161+
if ($TrailingSlash)
162+
{
163+
$dataSetLocationForTest = "$($dataSetLocation)$($slashCharacter)"
164+
}
165+
166+
if ($AlternateSlash)
167+
{
168+
$dataSetLocationForTest = $dataSetLocationForTest.Replace("\", $slashCharacter)
169+
$dataSetLocationForTest = $dataSetLocationForTest.Replace("/", $slashCharacter)
170+
}
171+
172+
if ($Full)
173+
{
174+
Write-Verbose "Getting configuration"
175+
$configuration = Get-Configuration
176+
177+
if (! $SkipInvalidCharacters)
178+
{
179+
Write-Verbose "Creating blocked character table"
180+
$table = Build-CharacterTable -Configuration $configuration
181+
182+
Write-Verbose "Creating invalid files"
183+
$pathForInvalidFileNameCharacters = Join-Path $dataSetLocation "InvalidFileNameCharacters"
184+
CreateItemsWithInvalidCharacters -path $pathForInvalidFileNameCharacters -configuration $configuration -blockedCharactersTable $table -itemType File
185+
186+
Write-Verbose "Creating invalid dirs"
187+
$pathForInvalidDirNameCharacters = Join-Path $dataSetLocation "InvalidDirNameCharacters"
188+
CreateItemsWithInvalidCharacters -path $pathForInvalidDirNameCharacters -configuration $configuration -blockedCharactersTable $table -itemType Directory
189+
}
190+
else
191+
{
192+
Write-Verbose "Skip invalid characters dataset creation"
193+
}
194+
195+
Write-Verbose "Creating directory violating depth requirement"
196+
$pathWithInvalidDepth = "x\" * 300
197+
CreateDirectoryWithRobocopy -targetDir (Join-Path (Get-DataSetLocation) $pathWithInvalidDepth)
198+
199+
Write-Verbose "Creating directory violating max path requirement"
200+
$pathWithInvalidFileName = "maximum path length validation\" * 70
201+
CreateDirectoryWithRobocopy -targetDir (Join-Path (Get-DataSetLocation) $pathWithInvalidFileName)
202+
}
203+
else
204+
{
205+
if (!(Test-Path $dataSetLocation))
206+
{
207+
throw "Cannot access: $dataSetLocation"
208+
}
209+
}
210+
211+
Write-Verbose "Invoking evaluation tool with path $dataSetLocation"
212+
$result = Invoke-AzStorageSyncCompatibilityCheck -Path $dataSetLocationForTest -SkipSystemChecks
213+
214+
# displaying report
215+
$result | Format-Custom
216+
217+
# handling check results
218+
$results = $result.Results
219+
Write-Verbose "Number of results: $($results.Count)"
220+
221+
$reportLocation = Join-Path $env:TEMP "EvalReport.csv"
222+
Write-Verbose "Exporting as CSV at $reportLocation"
223+
$results | Select-Object -Property Type, Path, Level, Description, Result | Export-Csv -Path $reportLocation -NoTypeInformation -Encoding Utf8
224+
225+
Write-Verbose "Done"
226+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28010.2036
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.StorageSync.Netcore", "Commands.StorageSync\Commands.StorageSync.Netcore.csproj", "{EE1767F4-8E0F-424E-9588-9082A521BB90}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{F5988A53-297A-499C-8FB8-A8CE4CCB6A32} = {F5988A53-297A-499C-8FB8-A8CE4CCB6A32}
9+
{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F} = {475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}
10+
{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6} = {9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}
11+
EndProjectSection
12+
EndProject
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Profile.Netcore", "..\Profile\Commands.Profile\Commands.Profile.Netcore.csproj", "{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}"
14+
EndProject
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tools.Common.Netcore", "..\..\..\tools\Tools.Common\Tools.Common.Netcore.csproj", "{F5988A53-297A-499C-8FB8-A8CE4CCB6A32}"
16+
EndProject
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StaticAnalysis.Netcore", "..\..\..\tools\StaticAnalysis\StaticAnalysis.Netcore.csproj", "{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}"
18+
EndProject
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.StorageSync.Test.Netcore", "Commands.StorageSync.Test\Commands.StorageSync.Test.Netcore.csproj", "{DE6F6163-4D2A-444A-81F0-BA0EA957FBF1}"
20+
ProjectSection(ProjectDependencies) = postProject
21+
{39BCFA32-3717-4CFF-A76B-FA76C3410876} = {39BCFA32-3717-4CFF-A76B-FA76C3410876}
22+
{EE1767F4-8E0F-424E-9588-9082A521BB90} = {EE1767F4-8E0F-424E-9588-9082A521BB90}
23+
EndProjectSection
24+
EndProject
25+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.TestPrerequisites", "..\..\TestPrerequisites\Common.Test.Prerequisites\Common.TestPrerequisites.csproj", "{39BCFA32-3717-4CFF-A76B-FA76C3410876}"
26+
EndProject
27+
Global
28+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
29+
Debug|Any CPU = Debug|Any CPU
30+
Release|Any CPU = Release|Any CPU
31+
EndGlobalSection
32+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
33+
{EE1767F4-8E0F-424E-9588-9082A521BB90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{EE1767F4-8E0F-424E-9588-9082A521BB90}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{EE1767F4-8E0F-424E-9588-9082A521BB90}.Release|Any CPU.ActiveCfg = Debug|Any CPU
36+
{EE1767F4-8E0F-424E-9588-9082A521BB90}.Release|Any CPU.Build.0 = Debug|Any CPU
37+
{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}.Release|Any CPU.ActiveCfg = Debug|Any CPU
40+
{9946CDDD-AFE3-4479-8A0A-7AC66C707FB6}.Release|Any CPU.Build.0 = Debug|Any CPU
41+
{F5988A53-297A-499C-8FB8-A8CE4CCB6A32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{F5988A53-297A-499C-8FB8-A8CE4CCB6A32}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{F5988A53-297A-499C-8FB8-A8CE4CCB6A32}.Release|Any CPU.ActiveCfg = Debug|Any CPU
44+
{F5988A53-297A-499C-8FB8-A8CE4CCB6A32}.Release|Any CPU.Build.0 = Debug|Any CPU
45+
{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}.Release|Any CPU.ActiveCfg = Debug|Any CPU
48+
{475F75DA-134E-4A4A-A6E7-B332B0FB4D4F}.Release|Any CPU.Build.0 = Debug|Any CPU
49+
{DE6F6163-4D2A-444A-81F0-BA0EA957FBF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{DE6F6163-4D2A-444A-81F0-BA0EA957FBF1}.Release|Any CPU.ActiveCfg = Debug|Any CPU
51+
{39BCFA32-3717-4CFF-A76B-FA76C3410876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52+
{39BCFA32-3717-4CFF-A76B-FA76C3410876}.Debug|Any CPU.Build.0 = Debug|Any CPU
53+
{39BCFA32-3717-4CFF-A76B-FA76C3410876}.Release|Any CPU.ActiveCfg = Debug|Any CPU
54+
{39BCFA32-3717-4CFF-A76B-FA76C3410876}.Release|Any CPU.Build.0 = Debug|Any CPU
55+
EndGlobalSection
56+
GlobalSection(SolutionProperties) = preSolution
57+
HideSolutionNode = FALSE
58+
EndGlobalSection
59+
GlobalSection(ExtensibilityGlobals) = postSolution
60+
SolutionGuid = {5E94E971-36C8-4CCD-B3E8-83C9297D605D}
61+
EndGlobalSection
62+
EndGlobal

0 commit comments

Comments
 (0)