internal async Task TestDeletingUpdatedJob() { using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { var service = new AgentService(); var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath); //seting up a temp notebook job var notebook = AgentTestUtils.SetupNotebookJob(connectionResult).Result; //verifying that the notebook is created Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook)); var originalName = notebook.Name; //Changing the notebookName notebook.Name = "myTestNotebookJob" + Guid.NewGuid().ToString(); Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook)); await AgentNotebookHelper.UpdateNotebook( service, connectionResult.ConnectionInfo.OwnerUri, originalName, notebook, null, ManagementUtils.asRunType(0) ); Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook)); //cleaning up the job await AgentTestUtils.CleanupNotebookJob(connectionResult, notebook); } }
public static async Task <AgentNotebookInfo> SetupNotebookJob( TestConnectionResult connectionResult, AgentNotebookInfo notebook = null) { var service = new AgentService(); if (notebook == null) { notebook = GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master"); } string tempNotebookPath = CreateTemplateNotebookFile(); await AgentNotebookHelper.CreateNotebook( service, connectionResult.ConnectionInfo.OwnerUri, notebook, tempNotebookPath, ManagementUtils.asRunType(0) ); var createdNotebook = GetNotebook(connectionResult, notebook.Name); File.Delete(tempNotebookPath); return(createdNotebook); }
public static async Task CleanupNotebookJob(TestConnectionResult connectionResult, AgentNotebookInfo notebook) { var service = new AgentService(); await AgentNotebookHelper.DeleteNotebook( service, connectionResult.ConnectionInfo.OwnerUri, notebook, ManagementUtils.asRunType(0) ); }
public static bool VerifyNotebook(TestConnectionResult connectionResult, AgentNotebookInfo notebook) { var notebookList = AgentNotebookHelper.GetAgentNotebooks(connectionResult.ConnectionInfo).Result; foreach (AgentNotebookInfo n in notebookList) { if (NotebookObjectEquals(notebook, n)) { return(true); } } return(false); }
public static AgentNotebookInfo GetNotebook(TestConnectionResult connectionResult, string name) { var notebookList = AgentNotebookHelper.GetAgentNotebooks(connectionResult.ConnectionInfo).Result; foreach (AgentNotebookInfo n in notebookList) { if (n.Name == name) { return(n); } } return(null); }