public void CanCallTheExecHiveCommand_DoesNotUploadFile() { IHDInsightCertificateCredential creds = GetValidCredentials(); using (IRunspace runspace = this.GetPowerShellRunspace()) { AzureHDInsightClusterConnection connection = ConnectToCluster(runspace, creds); var storageHandlerSimulator = new AzureHDInsightStorageHandlerSimulator(); AzureHDInsightStorageHandlerSimulatorFactory.Instance = storageHandlerSimulator; IInvokeHiveCommand execHiveCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateInvokeHive(); execHiveCommand.JobDefinition = new AzureHDInsightHiveJobDefinition { File = "query.hql", JobName = "show tables" }; execHiveCommand.CurrentSubscription = GetCurrentSubscription(); execHiveCommand.Connection = connection; execHiveCommand.EndProcessing(); string outputContent = execHiveCommand.Output.Last(); Assert.AreEqual(5, execHiveCommand.Output.Count()); Assert.AreEqual("hivesampletable", outputContent); Assert.IsNull(storageHandlerSimulator.UploadedStream); Assert.IsNull(storageHandlerSimulator.Path); } }
public void CannotCallTheExecHiveCmdlet_WithoutConnecting() { try { IInvokeHiveCommand execHiveCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateInvokeHive(); execHiveCommand.JobDefinition = new AzureHDInsightHiveJobDefinition { Query = "show tables" }; execHiveCommand.Connection = null; } catch (ArgumentNullException argumentNullException) { Assert.AreEqual(argumentNullException.ParamName, "Connection"); } }
public void CanCallTheExecHiveCommandWithAFailedQuery() { IHDInsightCertificateCredential creds = GetValidCredentials(); using (IRunspace runspace = this.GetPowerShellRunspace()) { AzureHDInsightClusterConnection connection = ConnectToCluster(runspace, creds); IInvokeHiveCommand execHiveCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateInvokeHive(); execHiveCommand.CurrentSubscription = GetCurrentSubscription(); execHiveCommand.JobDefinition = new AzureHDInsightHiveJobDefinition { Query = "show tableaus", JobName = "Fail_this_job" }; execHiveCommand.Connection = connection; execHiveCommand.EndProcessing(); string outputContent = execHiveCommand.Output.Last(); Assert.AreEqual(5, execHiveCommand.Output.Count()); Assert.AreEqual(AzureHDInsightJobSubmissionClientSimulator.JobFailed, outputContent); } }
public void CanCallTheExecHiveCommand_UploadsFile() { IHDInsightCertificateCredential creds = GetValidCredentials(); using (IRunspace runspace = this.GetPowerShellRunspace()) { AzureHDInsightClusterConnection connection = ConnectToCluster(runspace, creds); var storageHandlerSimulator = new AzureHDInsightStorageHandlerSimulator(); AzureHDInsightStorageHandlerSimulatorFactory.Instance = storageHandlerSimulator; IInvokeHiveCommand execHiveCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateInvokeHive(); execHiveCommand.JobDefinition = new AzureHDInsightHiveJobDefinition { Query = "show tables", JobName = "show tables" }; execHiveCommand.CurrentSubscription = GetCurrentSubscription(); execHiveCommand.Connection = connection; execHiveCommand.EndProcessing(); string destinationPath = string.Format( CultureInfo.InvariantCulture, "http://{0}/{1}/user/{2}/", connection.Cluster.DefaultStorageAccount.StorageAccountName, connection.Cluster.DefaultStorageAccount.StorageContainerName, connection.Cluster.HttpUserName); string outputContent = execHiveCommand.Output.Last(); Assert.IsNotNull(storageHandlerSimulator.UploadedStream); storageHandlerSimulator.UploadedStream.Seek(0, SeekOrigin.Begin); string contents = new StreamReader(storageHandlerSimulator.UploadedStream).ReadToEnd(); Assert.AreEqual("show tables", contents); Assert.IsFalse(string.IsNullOrEmpty(storageHandlerSimulator.Path.OriginalString)); Assert.IsTrue(storageHandlerSimulator.Path.OriginalString.StartsWith(destinationPath, StringComparison.OrdinalIgnoreCase)); Assert.AreEqual(5, execHiveCommand.Output.Count()); Assert.AreEqual("hivesampletable", outputContent); } }
/// <summary> /// Initializes a new instance of the InvokeHiveCmdlet class. /// </summary> public InvokeHiveCmdlet() { this.command = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateInvokeHive(); this.hiveJobDefinitionCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateNewHiveDefinition(); }
/// <summary> /// Initializes a new instance of the InvokeHiveCmdlet class. /// </summary> public InvokeHiveCmdlet() { this.command = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateInvokeHive(); this.hiveJobDefinitionCommand = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateNewHiveDefinition(); }