Skip to content

Commit

Permalink
Converted scenariotests into unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srsiva committed Nov 3, 2016
1 parent ab48d96 commit d13fedd
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 3,733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<Compile Include="ScenarioTests\ListClusterTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScenarioTests\ScriptActionsOnRunningCluster.cs" />
<Compile Include="UnitTests\ClusterCreateTests.cs" />
<Compile Include="UnitTests\StorageAccountTests.cs" />
<Compile Include="UnitTests\MetastoreTests.cs" />
</ItemGroup>
Expand All @@ -30,15 +31,9 @@
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestAdJoinedIaasCreateGetDeleteCluster.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateDefaultFsAzureBlobClusterContainerNotSpecified.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateDuplicateCluster.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateDefaultFsAzureBlobClusterUsingClusterParameters.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateHumboldtClusterWithCustomVMSizes.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -137,6 +132,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>$(LibraryNugetPackageFolder)\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.ResourceManager">
Expand All @@ -153,4 +151,4 @@
<Name>HDInsightManagement</Name>
</ProjectReference>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -423,75 +423,5 @@ public void TestCreateLinuxSparkClusterWithComponentVersion()
Assert.Equal(result.State, AsyncOperationState.Succeeded);
}
}

[Fact]
public void TestCreateDefaultFsAzureBlobClusterUsingClusterParameters()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

using (var context = UndoContext.Current)
{
context.Start();

var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

var cluster = GetClusterSpecHelpers.GetAzureBlobDefaultFsCreateParametersIaas();
const string dnsname = "hdisdk-defaultfsazureblob";
const string operationState = "Running";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
Assert.Equal(dnsname, createresponse.Cluster.Name);
Assert.Equal(operationState, createresponse.Cluster.Properties.ClusterState);

var clusterConfig = client.Clusters.GetClusterConfigurations(resourceGroup, dnsname, "core-site");
string value;
clusterConfig.Configuration.TryGetValue("fs.defaultFS", out value);
Assert.True(value.StartsWith("wasb://"));

client.Clusters.Get(resourceGroup, dnsname);

var result = client.Clusters.Delete(resourceGroup, dnsname);
Assert.Equal(result.StatusCode, HttpStatusCode.OK);
Assert.Equal(result.State, AsyncOperationState.Succeeded);

}
}

[Fact]
public void TestCreateDefaultFsAzureBlobClusterContainerNotSpecified()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

using (var context = UndoContext.Current)
{
context.Start();

var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

var cluster = GetClusterSpecHelpers.GetAzureBlobDefaultFsCreateParametersIaas(specifyDefaultContainer:false);
const string dnsname = "hdisdk-defaultfsazureblob-nocontainer";
const string operationState = "Running";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
Assert.Equal(dnsname, createresponse.Cluster.Name);
Assert.Equal(operationState, createresponse.Cluster.Properties.ClusterState);

var clusterConfig = client.Clusters.GetClusterConfigurations(resourceGroup, dnsname, "core-site");
string value;
clusterConfig.Configuration.TryGetValue("fs.defaultFS", out value);
Assert.True(value.StartsWith("wasb://" + dnsname + "@"));

client.Clusters.Get(resourceGroup, dnsname);

var result = client.Clusters.Delete(resourceGroup, dnsname);
Assert.Equal(result.StatusCode, HttpStatusCode.OK);
Assert.Equal(result.State, AsyncOperationState.Succeeded);

}
}
}
}
Loading

0 comments on commit d13fedd

Please sign in to comment.