@@ -31,13 +31,14 @@ public class NewClusterTests : HDInsightTestBase
31
31
private const string StorageKey = "O9EQvp3A3AjXq/W27rst1GQfLllhp01qlJMJfSU1hVW2K42gUeiUUn2D8zX2lU3taiXSSfqkZlcPv+nQcYUxYw==" ;
32
32
private const int ClusterSize = 4 ;
33
33
34
- private readonly PSCredential _httpCred ;
34
+ private readonly PSCredential _httpCred , _sshCred ;
35
35
36
36
public NewClusterTests ( Xunit . Abstractions . ITestOutputHelper output )
37
37
{
38
38
ServiceManagemenet . Common . Models . XunitTracingInterceptor . AddToContext ( new ServiceManagemenet . Common . Models . XunitTracingInterceptor ( output ) ) ;
39
39
base . SetupTestsForManagement ( ) ;
40
40
_httpCred = new PSCredential ( "hadoopuser" , string . Format ( "Password1!" ) . ConvertToSecureString ( ) ) ;
41
+ _sshCred = new PSCredential ( "sshuser" , string . Format ( "Password1!" ) . ConvertToSecureString ( ) ) ;
41
42
cmdlet = new NewAzureHDInsightClusterCommand
42
43
{
43
44
CommandRuntime = commandRuntimeMock . Object ,
@@ -130,5 +131,95 @@ public void CanCreateNewHDInsightCluster()
130
131
clusterout . OperatingSystemType == OSType . Windows ) ) ,
131
132
Times . Once ) ;
132
133
}
134
+
135
+ [ Fact ]
136
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
137
+ public void CanCreateNewHDInsightCluster_Linux ( )
138
+ {
139
+ cmdlet . ClusterName = ClusterName ;
140
+ cmdlet . ResourceGroupName = ResourceGroupName ;
141
+ cmdlet . ClusterSizeInNodes = ClusterSize ;
142
+ cmdlet . Location = Location ;
143
+ cmdlet . HttpCredential = _httpCred ;
144
+ cmdlet . DefaultStorageAccountName = StorageName ;
145
+ cmdlet . DefaultStorageAccountKey = StorageKey ;
146
+ cmdlet . ClusterType = ClusterType ;
147
+ cmdlet . SshCredential = _sshCred ;
148
+ cmdlet . OSType = OSType . Linux ;
149
+
150
+ var cluster = new Cluster
151
+ {
152
+ Id = "id" ,
153
+ Name = ClusterName ,
154
+ Location = Location ,
155
+ Properties = new ClusterGetProperties
156
+ {
157
+ ClusterVersion = "3.1" ,
158
+ ClusterState = "Running" ,
159
+ ClusterDefinition = new ClusterDefinition
160
+ {
161
+ ClusterType = ClusterType
162
+ } ,
163
+ QuotaInfo = new QuotaInfo
164
+ {
165
+ CoresUsed = 24
166
+ } ,
167
+ OperatingSystemType = OSType . Linux
168
+ }
169
+ } ;
170
+ var coreConfigs = new Dictionary < string , string >
171
+ {
172
+ { "fs.defaultFS" , "wasb://giyertestcsmv2@" + StorageName } ,
173
+ {
174
+ "fs.azure.account.key." + StorageName ,
175
+ StorageKey
176
+ }
177
+ } ;
178
+ var gatewayConfigs = new Dictionary < string , string >
179
+ {
180
+ { "restAuthCredential.isEnabled" , "true" } ,
181
+ { "restAuthCredential.username" , _httpCred . UserName } ,
182
+ { "restAuthCredential.password" , _httpCred . Password . ConvertToString ( ) }
183
+ } ;
184
+
185
+ var configurations = new Dictionary < string , Dictionary < string , string > >
186
+ {
187
+ { "core-site" , coreConfigs } ,
188
+ { "gateway" , gatewayConfigs }
189
+ } ;
190
+ var serializedConfig = JsonConvert . SerializeObject ( configurations ) ;
191
+ cluster . Properties . ClusterDefinition . Configurations = serializedConfig ;
192
+
193
+ var getresponse = new ClusterGetResponse { Cluster = cluster } ;
194
+
195
+ hdinsightManagementMock . Setup ( c => c . CreateNewCluster ( ResourceGroupName , ClusterName , It . Is < ClusterCreateParameters > (
196
+ parameters =>
197
+ parameters . ClusterSizeInNodes == ClusterSize &&
198
+ parameters . DefaultStorageAccountName == StorageName &&
199
+ parameters . DefaultStorageAccountKey == StorageKey &&
200
+ parameters . Location == Location &&
201
+ parameters . UserName == _httpCred . UserName &&
202
+ parameters . Password == _httpCred . Password . ConvertToString ( ) &&
203
+ parameters . ClusterType == ClusterType &&
204
+ parameters . OSType == OSType . Linux &&
205
+ parameters . SshUserName == _sshCred . UserName &&
206
+ parameters . SshPassword == _sshCred . Password . ConvertToString ( ) ) ) )
207
+ . Returns ( getresponse )
208
+ . Verifiable ( ) ;
209
+
210
+ cmdlet . ExecuteCmdlet ( ) ;
211
+
212
+ commandRuntimeMock . VerifyAll ( ) ;
213
+ commandRuntimeMock . Verify ( f => f . WriteObject ( It . Is < AzureHDInsightCluster > (
214
+ clusterout =>
215
+ clusterout . ClusterState == "Running" &&
216
+ clusterout . ClusterType == ClusterType &&
217
+ clusterout . ClusterVersion == "3.1" &&
218
+ clusterout . CoresUsed == 24 &&
219
+ clusterout . Location == Location &&
220
+ clusterout . Name == ClusterName &&
221
+ clusterout . OperatingSystemType == OSType . Linux ) ) ,
222
+ Times . Once ) ;
223
+ }
133
224
}
134
225
}
0 commit comments