Skip to content

Commit 018cbb7

Browse files
committed
Fixing small issue in ps1 file
1 parent 834355d commit 018cbb7

File tree

7 files changed

+25
-35
lines changed

7 files changed

+25
-35
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void StopAzureBackupJobTests()
5151
}
5252
public void GetRecoveryPointTests()
5353
{
54-
this.RunPowerShellTest("GetAzureRecoveryPointTest");
54+
this.RunPowerShellTest("Test-GetAzureRecoveryPoint");
5555
}
5656

5757
[Fact]

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function Test-GetAzureBackupProtectionPolicyTests
4444
}
4545
}
4646

47-
function GetAzureRecoveryPointTest
47+
function Test-GetAzureRecoveryPoint
4848
{
4949
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
5050
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
@@ -57,11 +57,12 @@ function GetAzureRecoveryPointTest
5757
$recoveryPoints = Get-AzureBackupRecoveryPoint -item $azureBackUpItem
5858
if (!($recoveryPoints -eq $null))
5959
{
60-
foreach($recoveryPoint in $recoveryPoints)
61-
{
62-
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
63-
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
64-
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
60+
foreach($recoveryPoint in $recoveryPoints)
61+
{
62+
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
63+
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
64+
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
65+
}
6566
}
6667
}
6768

@@ -118,7 +119,6 @@ function Test-EnableDisableAzureBackupProtectionTest
118119
sleep(20)
119120
$jobId2 = Enable-AzureBackupProtection -item $azureBackUpItem -Policy $policy
120121
}
121-
}
122122

123123
function BackUpAzureBackUpItemTest
124124
{

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureBackupJob.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public override void ExecuteCmdlet()
6161
{
6262
if (Job != null)
6363
{
64-
this.ResourceGroupName = Job.ResourceGroupName;
65-
this.ResourceName = Job.ResourceName;
64+
InitializeAzureBackupCmdlet(Job.ResourceGroupName, Job.ResourceName, Job.Location);
6665
}
6766

6867
base.ExecuteCmdlet();

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureBackupJobDetails.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,13 @@ public override void ExecuteCmdlet()
3939
{
4040
if (Job != null)
4141
{
42-
this.ResourceGroupName = Job.ResourceGroupName;
43-
this.ResourceName = Job.ResourceName;
42+
InitializeAzureBackupCmdlet(Job.ResourceGroupName, Job.ResourceName, Job.Location);
4443
}
4544

4645
base.ExecuteCmdlet();
4746

4847
ExecutionBlock(() =>
4948
{
50-
//if (Job != null && JobID != null)
51-
//{
52-
// throw new Exception("Please use either JobID filter or Job filter but not both.");
53-
//}
54-
5549
if (Job != null)
5650
{
5751
JobID = Job.InstanceId;

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/StopAzureBackukpJob.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,36 @@ public override void ExecuteCmdlet()
4545
{
4646
if (Job != null)
4747
{
48-
this.ResourceGroupName = Job.ResourceGroupName;
49-
this.ResourceName = Job.ResourceName;
48+
InitializeAzureBackupCmdlet(Job.ResourceGroupName, Job.ResourceName, Job.Location);
5049
}
5150

5251
base.ExecuteCmdlet();
5352

5453
ExecutionBlock(() =>
5554
{
56-
//if (JobID != null && Job != null)
57-
//{
58-
// throw new Exception("Please use either JobID filter or Job filter but not both.");
59-
//}
60-
6155
if (Job != null)
6256
{
6357
JobID = Job.InstanceId;
6458
}
6559

6660
WriteDebug("JobID is: " + JobID);
67-
Task<OperationResponse> cancelTask = AzureBackupClient.Job.StopAsync(JobID, GetCustomRequestHeaders(), CmdletCancellationToken);
61+
OperationResponse cancelTask = AzureBackupClient.Job.StopAsync(JobID, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
6862

69-
if (cancelTask.IsFaulted)
63+
var opStatus = AzureBackupClient.OperationStatus.GetAsync(cancelTask.OperationId.ToString(), GetCustomRequestHeaders()).Result;
64+
while (opStatus.OperationStatus != "Completed")
65+
{
66+
WriteDebug("Waiting for the task to complete");
67+
opStatus = AzureBackupClient.OperationStatus.GetAsync(cancelTask.OperationId.ToString(), GetCustomRequestHeaders()).Result;
68+
}
69+
// TODO:
70+
if (opStatus.OperationResult == "Failed")
7071
{
71-
WriteObject(cancelTask.Exception);
72+
var errorRecord = new ErrorRecord(new Exception("Cannot cancel job."), opStatus.Message, ErrorCategory.InvalidOperation, null);
73+
WriteError(errorRecord);
7274
}
7375
else
7476
{
75-
OperationResponse opResponse = cancelTask.Result;
76-
// TODO
77-
// Call and wait until this completes.
78-
WriteDebug("OpID is : " + opResponse.OperationId);
77+
WriteDebug("Triggered cancellation of job with JobID: " + JobID);
7978
}
8079
});
8180
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/WaitAzureBackupJob.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public override void ExecuteCmdlet()
5050
WriteDebug("Type of input paramter is List<AzureBackupJob>");
5151
foreach (AzureBackupJob jobToWait in ((Job as PSObject).ImmediateBaseObject as List<AzureBackupJob>))
5252
{
53-
this.ResourceGroupName = jobToWait.ResourceGroupName;
54-
this.ResourceName = jobToWait.ResourceName;
55-
this.Location = jobToWait.Location;
53+
InitializeAzureBackupCmdlet(jobToWait.ResourceGroupName, jobToWait.ResourceName, jobToWait.Location);
5654

5755
specifiedJobs.Add(jobToWait.InstanceId);
5856
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)