Skip to content

Commit 352a613

Browse files
Merge from 'release'
2 parents 12dd95d + c0d7f43 commit 352a613

File tree

125 files changed

+159851
-18427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+159851
-18427
lines changed

src/Common/Commands.Common/AzureLongRunningJob.cs

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,59 @@
2626

2727
namespace Microsoft.Azure.Commands.Common
2828
{
29-
public class AzureLongRunningJob<T> : Job, ICommandRuntime where T : AzurePSCmdlet
29+
/// <summary>
30+
/// Abstract class for uniform processing of jobs
31+
/// </summary>
32+
public abstract class AzureLongRunningJob : Job
33+
{
34+
protected AzureLongRunningJob(string command, string name) : base(command, name)
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Run a cmdlet execution as a Job - this is intended to run in a background thread
40+
/// </summary>
41+
/// <param name="state">The Job record that will track the progress of this job </param>
42+
public abstract void RunJob(object state);
43+
44+
/// <summary>
45+
/// Return cmdlet runtime that will report results to this job
46+
/// </summary>
47+
/// <returns>An IcommandRuntime that reports results to this job</returns>
48+
public abstract ICommandRuntime GetJobRuntime();
49+
50+
/// <summary>
51+
/// Mark the job as started
52+
/// </summary>
53+
public abstract bool TryStart();
54+
55+
/// <summary>
56+
/// Mark the job as Blocked
57+
/// </summary>
58+
public abstract bool TryBlock();
59+
60+
61+
/// <summary>
62+
/// Complete the job (will mark job as Completed or Failed, depending on the execution details)
63+
/// </summary>
64+
public abstract void Complete();
65+
66+
/// <summary>
67+
/// Mark the Job as Failed
68+
/// </summary>
69+
public abstract void Fail();
70+
71+
/// <summary>
72+
/// Stop the job
73+
/// </summary>
74+
public abstract void Cancel();
75+
}
76+
77+
/// <summary>
78+
/// Cmdlet-specific Implementation class for long running jobs
79+
/// </summary>
80+
/// <typeparam name="T">The type of the cmdlet being executed</typeparam>
81+
public class AzureLongRunningJob<T> : AzureLongRunningJob, ICommandRuntime where T : AzurePSCmdlet
3082
{
3183
string _status = "Running";
3284
T _cmdlet;
@@ -204,7 +256,7 @@ public static U CopyCmdlet<U>(U cmdlet) where U : AzurePSCmdlet
204256
/// Run a cmdlet execution as a Job - this is intended to run in a background thread
205257
/// </summary>
206258
/// <param name="state">The Job record that will track the progress of this job </param>
207-
public virtual void RunJob(object state)
259+
public override void RunJob(object state)
208260
{
209261
if (TryStart())
210262
{
@@ -240,7 +292,7 @@ public virtual void RunJob(object state)
240292
/// Return cmdlet runtime that will report results to this job
241293
/// </summary>
242294
/// <returns>An IcommandRuntime that reports results to this job</returns>
243-
public virtual ICommandRuntime GetJobRuntime()
295+
public override ICommandRuntime GetJobRuntime()
244296
{
245297
return this as ICommandRuntime;
246298
}
@@ -308,7 +360,7 @@ internal string GetShouldMethodFailureReaon(T cmdlet, ShouldMethodStreamItem met
308360
/// <summary>
309361
/// Mark the task as started
310362
/// </summary>
311-
public bool TryStart()
363+
public override bool TryStart()
312364
{
313365
bool result = false;
314366
lock (_lockObject)
@@ -327,7 +379,7 @@ public bool TryStart()
327379
/// <summary>
328380
/// Mark the task as blocked
329381
/// </summary>
330-
public bool TryBlock()
382+
public override bool TryBlock()
331383
{
332384
bool result = false;
333385
lock (_lockObject)
@@ -346,7 +398,7 @@ public bool TryBlock()
346398
/// <summary>
347399
/// Mark the job as Failed
348400
/// </summary>
349-
public void Fail()
401+
public override void Fail()
350402
{
351403
lock (_lockObject)
352404
{
@@ -358,7 +410,7 @@ public void Fail()
358410
/// <summary>
359411
/// Mark the job as successfully complete
360412
/// </summary>
361-
public void Complete()
413+
public override void Complete()
362414
{
363415
lock (_lockObject)
364416
{
@@ -379,7 +431,7 @@ public void Complete()
379431
/// <summary>
380432
/// Mark the job as cancelled
381433
/// </summary>
382-
public void Cancel()
434+
public override void Cancel()
383435
{
384436
lock (_lockObject)
385437
{
@@ -788,8 +840,7 @@ private bool InvokeShouldMethodAndWaitForResults(Func<Cmdlet, bool> shouldMethod
788840
try
789841
{
790842
stateChangedEventHandler(null, new JobStateEventArgs(this.JobStateInfo));
791-
792-
if (!gotResultEvent.IsSet && this.TryBlock())
843+
if (!gotResultEvent.IsSet)
793844
{
794845
WriteDebug(string.Format(Resources.TraceBlockLROThread, methodType));
795846
ShouldMethodInvoker methodInvoker = new ShouldMethodInvoker
@@ -801,16 +852,18 @@ private bool InvokeShouldMethodAndWaitForResults(Func<Cmdlet, bool> shouldMethod
801852
};
802853

803854
BlockedActions.Enqueue(new ShouldMethodStreamItem(methodInvoker));
804-
805-
gotResultEvent.Wait();
806-
WriteDebug(string.Format(Resources.TraceUnblockLROThread, shouldMethod));
807-
TryStart();
808-
lock (resultsLock)
855+
if (this.TryBlock())
809856
{
810-
if (closureSafeExceptionThrownOnCmdletThread == null) // stateChangedEventHandler didn't set the results? = ok to clobber results?
857+
gotResultEvent.Wait();
858+
WriteDebug(string.Format(Resources.TraceUnblockLROThread, shouldMethod));
859+
TryStart();
860+
lock (resultsLock)
811861
{
812-
closureSafeExceptionThrownOnCmdletThread = methodInvoker.ThrownException;
813-
methodResult = methodInvoker.MethodResult;
862+
if (closureSafeExceptionThrownOnCmdletThread == null) // stateChangedEventHandler didn't set the results? = ok to clobber results?
863+
{
864+
closureSafeExceptionThrownOnCmdletThread = methodInvoker.ThrownException;
865+
methodResult = methodInvoker.MethodResult;
866+
}
814867
}
815868
}
816869
}

src/Common/Commands.Common/Extensions/CmdletExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static void SafeCopyValue<T>(this FieldInfo field, T source, T target)
184184
/// <typeparam name="T">The cmdlet type</typeparam>
185185
/// <param name="source">The cmdlet to copy the parameter set name from</param>
186186
/// <param name="target">The cmdlet to copy to</param>
187-
public static void SafeCopyParameterSet<T>(this T source, T target) where T: AzurePSCmdlet
187+
public static void SafeCopyParameterSet<T>(this T source, T target) where T : AzurePSCmdlet
188188
{
189189
if (source != null && target != null)
190190
{

src/ResourceManager/ContainerRegistry/AzureRM.ContainerRegistry.psd1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.3.0'
15+
ModuleVersion = '1.0.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -80,7 +80,16 @@ CmdletsToExport = 'New-AzureRmContainerRegistry', 'Get-AzureRmContainerRegistry'
8080
'Remove-AzureRmContainerRegistry',
8181
'Get-AzureRmContainerRegistryCredential',
8282
'Update-AzureRmContainerRegistryCredential',
83-
'Test-AzureRmContainerRegistryNameAvailability'
83+
'Test-AzureRmContainerRegistryNameAvailability',
84+
'Get-AzureRmContainerRegistryReplication',
85+
'New-AzureRmContainerRegistryReplication',
86+
'Remove-AzureRmContainerRegistryReplication',
87+
'New-AzureRmContainerRegistryWebhook',
88+
'Get-AzureRmContainerRegistryWebhook',
89+
'Update-AzureRmContainerRegistryWebhook',
90+
'Test-AzureRmContainerRegistryWebhook',
91+
'Remove-AzureRmContainerRegistryWebhook',
92+
'Get-AzureRmContainerRegistryWebhookEvent'
8493

8594
# Variables to export from this module
8695
# VariablesToExport = @()

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry.Test/Commands.ContainerRegistry.Test.csproj

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@
5252
<Reference Include="Microsoft.Azure.Common.NetFramework">
5353
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5454
</Reference>
55-
<Reference Include="Microsoft.Azure.Management.ContainerRegistry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerRegistry.1.2.0-preview\lib\net45\Microsoft.Azure.Management.ContainerRegistry.dll</HintPath>
57-
<Private>True</Private>
55+
<Reference Include="Microsoft.Azure.Management.ContainerRegistry, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerRegistry.2.0.0\lib\net452\Microsoft.Azure.Management.ContainerRegistry.dll</HintPath>
5857
</Reference>
5958
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6059
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
@@ -80,18 +79,16 @@
8079
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
8180
</Reference>
8281
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
83-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.8\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
82+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
8483
</Reference>
8584
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
86-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.7\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
85+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
8786
</Reference>
8887
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
89-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.12\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
90-
<Private>True</Private>
88+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.3.0\lib\net452\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
9189
</Reference>
92-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
93-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.6.0\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
94-
<Private>True</Private>
90+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
91+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.7.2\lib\net452\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
9592
</Reference>
9693
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
9794
<SpecificVersion>False</SpecificVersion>
@@ -203,6 +200,12 @@
203200
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerRegistry.Test.ScenarioTests.ContainerRegistryTests\TestAzureContainerRegistryNameAvailability.json">
204201
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205202
</None>
203+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerRegistry.Test.ScenarioTests.ContainerRegistryTests\TestAzureContainerRegistryReplication.json">
204+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205+
</None>
206+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerRegistry.Test.ScenarioTests.ContainerRegistryTests\TestAzureContainerRegistryWebhook.json">
207+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208+
</None>
206209
</ItemGroup>
207210
<ItemGroup>
208211
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry.Test/ScenarioTests/Common.ps1

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gets container registry name
1818
#>
1919
function Get-RandomRegistryName
2020
{
21-
return getAssetName
21+
return 'reg' + (getAssetName)
2222
}
2323

2424
<#
@@ -27,7 +27,25 @@ Gets resource group name
2727
#>
2828
function Get-RandomResourceGroupName
2929
{
30-
return getAssetName
30+
return 'rg' + (getAssetName)
31+
}
32+
33+
<#
34+
.SYNOPSIS
35+
Gets webhook name
36+
#>
37+
function Get-RandomReplicationName
38+
{
39+
return 'rep' + (getAssetName)
40+
}
41+
42+
<#
43+
.SYNOPSIS
44+
Gets webhook name
45+
#>
46+
function Get-RandomWebhookName
47+
{
48+
return 'wh' + (getAssetName)
3149
}
3250

3351
<#
@@ -58,3 +76,31 @@ function Get-ProviderLocation($provider)
5876

5977
return "West US"
6078
}
79+
80+
function Assert-Error
81+
{
82+
param([ScriptBlock] $script, [string] $message)
83+
84+
$originalErrorCount = $error.Count
85+
$originalErrorActionPreference = $ErrorActionPreference
86+
$ErrorActionPreference = "SilentlyContinue"
87+
try
88+
{
89+
&$script
90+
}
91+
finally
92+
{
93+
$ErrorActionPreference = $originalErrorActionPreference
94+
}
95+
96+
$result = $Error[0] -like "*$($message)*"
97+
98+
If(!$result)
99+
{
100+
Write-Output "expected error $($message), actual error $($Error[0])"
101+
}
102+
103+
Assert-True {$result}
104+
105+
$Error.Clear()
106+
}

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry.Test/ScenarioTests/ContainerRegistryTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,19 @@ public void TestAzureContainerRegistryNameAvailability()
4949
{
5050
TestController.NewInstance.RunPowerShellTest("Test-AzureContainerRegistryNameAvailability");
5151
}
52+
53+
[Fact]
54+
[Trait(Category.AcceptanceType, Category.CheckIn)]
55+
public void TestAzureContainerRegistryReplication()
56+
{
57+
TestController.NewInstance.RunPowerShellTest("Test-AzureContainerRegistryReplication");
58+
}
59+
60+
[Fact]
61+
[Trait(Category.AcceptanceType, Category.CheckIn)]
62+
public void TestAzureContainerRegistryWebhook()
63+
{
64+
TestController.NewInstance.RunPowerShellTest("Test-AzureContainerRegistryWebhook");
65+
}
5266
}
5367
}

0 commit comments

Comments
 (0)