Skip to content

Commit df13145

Browse files
committed
adding support for regions like china,germany
1 parent 4fbe74c commit df13145

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
5858
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.3\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
59+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.4\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Storage">
6262
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

src/ResourceManager/HDInsight/Commands.HDInsight.Test/HDInsightTestBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public virtual void SetupManagementClientForJobTests()
8585
.Verifiable();
8686

8787
var configurationResponse = new Dictionary<string, string>();
88+
configurationResponse.Add("fs.defaultFS", "wasb://[email protected]");
89+
configurationResponse.Add("fs.azure.account.key.xyz.blob.core.windows.net", "tempkey");
8890

8991
hdinsightManagementMock.Setup(c => c.GetClusterConfigurations(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
9092
.Returns(configurationResponse)

src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/JobTests.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2626
using Moq;
2727
using Xunit;
28+
using System.IO;
29+
using System.Text;
2830

2931
namespace Microsoft.Azure.Commands.HDInsight.Test
3032
{
@@ -228,6 +230,34 @@ public void GetJobWithIdProvided()
228230
f.WriteObject(It.Is<AzureHDInsightJob>(job => job.JobId.Equals(jobId))));
229231
}
230232

233+
[Fact]
234+
[Trait(Category.AcceptanceType, Category.CheckIn)]
235+
public void GetJobOutput()
236+
{
237+
string sampleOutput = "1";
238+
// Update HDInsight Management properties for Job.
239+
SetupManagementClientForJobTests();
240+
var jobId = "jobid_1984120_001";
241+
var cmdlet = GetJobOutputCommandDefinition();
242+
cmdlet.JobId = jobId;
243+
244+
MemoryStream jobOutput = new MemoryStream(Encoding.UTF8.GetBytes(sampleOutput));
245+
246+
var reader = new StreamReader(jobOutput);
247+
var text = reader.ReadToEnd();
248+
jobOutput.Seek(0, SeekOrigin.Begin);
249+
250+
hdinsightJobManagementMock.Setup(c => c.GetJobOutput(It.IsAny<string>(),It.IsAny<IStorageAccess>()))
251+
.Returns(jobOutput)
252+
.Verifiable();
253+
254+
cmdlet.ExecuteCmdlet();
255+
commandRuntimeMock.VerifyAll();
256+
commandRuntimeMock.Verify(
257+
f =>
258+
f.WriteObject(It.Is<string>(Output => Output.Equals(text))));
259+
}
260+
231261
[Fact]
232262
[Trait(Category.AcceptanceType, Category.CheckIn)]
233263
public void ListJobs()
@@ -383,6 +413,20 @@ public GetAzureHDInsightJobCommand GetJobCommandDefinition()
383413
return cmdlet;
384414
}
385415

416+
public GetAzureHDInsightJobOutputCommand GetJobOutputCommandDefinition()
417+
{
418+
var cmdlet = new GetAzureHDInsightJobOutputCommand
419+
{
420+
CommandRuntime = commandRuntimeMock.Object,
421+
HDInsightJobClient = hdinsightJobManagementMock.Object,
422+
HDInsightManagementClient = hdinsightManagementMock.Object,
423+
HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
424+
ClusterName = ClusterName
425+
};
426+
427+
return cmdlet;
428+
}
429+
386430
[Fact]
387431
[Trait(Category.AcceptanceType, Category.CheckIn)]
388432
public void WaitForJobCompletion_Sucess()

src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.HDInsight" version="2.0.7" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.HDInsight.Job" version="2.0.3" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.HDInsight.Job" version="2.0.4" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />

src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
</Reference>
130130
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
131131
<SpecificVersion>False</SpecificVersion>
132-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.3\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
132+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.4\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
133133
</Reference>
134134
<Reference Include="Microsoft.WindowsAzure.Storage">
135135
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/HDInsight/Commands.HDInsight/JobCommands/GetAzureHDInsightJobOutputCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ private static string Convert(Stream stream)
133133

134134
internal IStorageAccess GetDefaultStorageAccess(string resourceGroupName, string clusterName)
135135
{
136+
var StorageAccountSuffix = "";
137+
136138
if (DefaultContainer == null && DefaultStorageAccountName == null && DefaultStorageAccountKey == null)
137139
{
138140
var DefaultStorageAccount = GetDefaultStorageAccount(resourceGroupName, clusterName);
@@ -143,6 +145,7 @@ internal IStorageAccess GetDefaultStorageAccess(string resourceGroupName, string
143145
DefaultContainer = wasbAccount.StorageContainerName;
144146
DefaultStorageAccountName = wasbAccount.StorageAccountName;
145147
DefaultStorageAccountKey = wasbAccount.StorageAccountKey;
148+
StorageAccountSuffix = DefaultContext.Environment.StorageEndpointSuffix;
146149
}
147150
else
148151
{
@@ -151,7 +154,7 @@ internal IStorageAccess GetDefaultStorageAccess(string resourceGroupName, string
151154

152155
}
153156

154-
return new AzureStorageAccess(DefaultStorageAccountName, DefaultStorageAccountKey, DefaultContainer);
157+
return new AzureStorageAccess(DefaultStorageAccountName, DefaultStorageAccountKey, DefaultContainer,StorageAccountSuffix);
155158
}
156159
}
157160
}

src/ResourceManager/HDInsight/Commands.HDInsight/Models/Job/AzureHdInsightJobManagementClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void StopJob(string jobId)
141141
HdInsightJobManagementClient.JobManagement.KillJob(jobId);
142142
}
143143

144-
public Stream GetJobOutput(string jobid, IStorageAccess storageAccess)
144+
public virtual Stream GetJobOutput(string jobid, IStorageAccess storageAccess)
145145
{
146146
var joboutput = HdInsightJobManagementClient.JobManagement.GetJobOutput(jobid, storageAccess);
147147
return joboutput;

src/ResourceManager/HDInsight/Commands.HDInsight/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<packages>
33
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
44
<package id="Microsoft.Azure.Management.HDInsight" version="2.0.7" targetFramework="net45" />
5-
<package id="Microsoft.Azure.Management.HDInsight.Job" version="2.0.3" targetFramework="net45" />
5+
<package id="Microsoft.Azure.Management.HDInsight.Job" version="2.0.4" targetFramework="net45" />
66
<package id="WindowsAzure.Storage" version="6.0.0" targetFramework="net45" />
77
</packages>

0 commit comments

Comments
 (0)