Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation 3.0.2 - preview #4308

Merged
merged 8 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace Automation.Tests.Helpers
{
public class SourceControlDefinition
{
public SourceControlDefinition(string sourceControlName, string repoUrl, string branch, string folderPath, bool autoSync,
bool publishRunbook, string sourceType, string securityToken, string description,
string updateBranchName, bool updateAutoPublish)
{
SourceControlName = sourceControlName;
RepoUrl = repoUrl;
Branch = branch;
FolderPath = folderPath;
AutoSync = autoSync;
PublishRunbook = publishRunbook;
SourceType = sourceType;
SecurityToken = securityToken;
Description = description;
UpdateBranchName = updateBranchName;
UpdateAutoPublish = updateAutoPublish;
}

public string SourceControlName { get; set; }

public string RepoUrl { get; set; }

public string Branch { get; set; }

public string FolderPath { get; set; }

public string SourceType { get; set; }

public string SecurityToken { get; set; }

public string Description { get; set; }

public string UpdateBranchName { get; set; }

public bool AutoSync { get; set; }

public bool PublishRunbook { get; set; }

public bool UpdateAutoPublish { get; set; }

public static SourceControlDefinition TestSimpleSourceControlDefinition = new SourceControlDefinition(
"swaggerSourceControl",
"https://miaromero.visualstudio.com/_git/Marvin",
"master",
"/FolderOne",
false,
true,
"VsoGit",
"nzbxgndni3haxhy27mpyyocwlupsuj66o3fiu3xlhsybf62ffsoa",
"test creating a Source Control",
"BranchTwo",
false
);
}
}
114 changes: 108 additions & 6 deletions src/SDKs/Automation/Automation.Tests/ScenarioTests/AutomationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Automation.Tests.ScenarioTests

public class AutomationTest
{
[Fact]
[Fact(Skip = "Waiting on webservice deployment")]
public void CanCreateUpdateDeleteRunbook()
{
using (var context = MockContext.Start(GetType().FullName))
Expand Down Expand Up @@ -46,10 +46,8 @@ public void CanCreateUpdateDeleteRunbook()

var runbookContentV2 = RunbookDefinition.TestFasterWorkflowV2.PsScript;
testFixture.UpdateRunbookContent(runbookName, runbookContentV2);

var updatedContent = testFixture.GetRunbookContent(runbookName);
var reader = new StreamReader(updatedContent);
Assert.Equal(runbookContentV2, reader.ReadToEnd());
string updatedContent = testFixture.GetRunbookContent(runbookName);
Assert.Equal(runbookContentV2, updatedContent);

testFixture.DeleteRunbook(runbookName);

Expand Down Expand Up @@ -271,7 +269,7 @@ public void CanCreateUpdateDeleteDscConfiguration()
}
}

[Fact]
[Fact(Skip = "Waiting on webservice deployment")]
public void CanCreateUpdateDeleteDscNodeConfiguration()
{
using (var context = MockContext.Start(GetType().FullName))
Expand Down Expand Up @@ -374,6 +372,110 @@ public void CanCreateUpdateDeleteAutomationModules()
}
}

[Fact]
public void CanCreateUpdateDeleteSourceControl()
{
using (var context = MockContext.Start(GetType().FullName))
{
using (var testFixture = new AutomationTestBase(context))
{

var sourceControlName = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceControlName;
var repoUrl = SourceControlDefinition.TestSimpleSourceControlDefinition.RepoUrl;
var branch = SourceControlDefinition.TestSimpleSourceControlDefinition.Branch;
var folderPath = SourceControlDefinition.TestSimpleSourceControlDefinition.FolderPath;
var autoSync = SourceControlDefinition.TestSimpleSourceControlDefinition.AutoSync;
var publishRunbook = SourceControlDefinition.TestSimpleSourceControlDefinition.PublishRunbook;
var sourceType = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceType;
var securityToken = SourceControlDefinition.TestSimpleSourceControlDefinition.SecurityToken;
var description = SourceControlDefinition.TestSimpleSourceControlDefinition.Description;
var updateBranchName = SourceControlDefinition.TestSimpleSourceControlDefinition.UpdateBranchName;
var updateAutoPublish = SourceControlDefinition.TestSimpleSourceControlDefinition.UpdateAutoPublish;

var sourceControl = testFixture.CreateSourceControl(sourceControlName, repoUrl, branch, folderPath, autoSync, publishRunbook,
sourceType, securityToken, description);

var retrievedSourceControl = testFixture.GetSourceControl(sourceControlName);

Assert.NotNull(retrievedSourceControl);
Assert.Equal(retrievedSourceControl.RepoUrl, sourceControl.RepoUrl);
Assert.Equal(retrievedSourceControl.Branch, sourceControl.Branch);
Assert.Equal(retrievedSourceControl.FolderPath, sourceControl.FolderPath);
Assert.Equal(retrievedSourceControl.AutoSync, sourceControl.AutoSync);
Assert.Equal(retrievedSourceControl.PublishRunbook, sourceControl.PublishRunbook);
Assert.Equal(retrievedSourceControl.SourceType, sourceControl.SourceType);
Assert.Equal(retrievedSourceControl.Description, sourceControl.Description);

var updatedSourceControl = testFixture.UpdateSourceControl(sourceControlName, updateBranchName, updateAutoPublish);

Assert.NotNull(updatedSourceControl);
Assert.Equal(updatedSourceControl.Branch, updateBranchName);
Assert.Equal(updatedSourceControl.AutoSync, updateAutoPublish);

var sourceControlList = testFixture.GetSourceControls();

Assert.NotNull(sourceControlList);
Assert.Single(sourceControlList.ToList());
sourceControl = sourceControlList.ToList()[0];
Assert.Equal(sourceControlName, sourceControl.Name);

testFixture.DeleteSourceControl(sourceControlName);

Assert.Throws<ErrorResponseException>(() =>
{
sourceControl = testFixture.GetSourceControl(sourceControlName);
});
}
}
}

[Fact(Skip = "Waiting on webservice deployment")]
public void CanCreateSourceControlSyncJob()
{
using (var context = MockContext.Start(GetType().FullName))
{
using (var testFixture = new AutomationTestBase(context))
{
var sourceControlName = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceControlName;
var repoUrl = SourceControlDefinition.TestSimpleSourceControlDefinition.RepoUrl;
var branch = SourceControlDefinition.TestSimpleSourceControlDefinition.Branch;
var folderPath = SourceControlDefinition.TestSimpleSourceControlDefinition.FolderPath;
var autoSync = SourceControlDefinition.TestSimpleSourceControlDefinition.AutoSync;
var publishRunbook = SourceControlDefinition.TestSimpleSourceControlDefinition.PublishRunbook;
var sourceControlType = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceType;
var securityToken = SourceControlDefinition.TestSimpleSourceControlDefinition.SecurityToken;
var description = SourceControlDefinition.TestSimpleSourceControlDefinition.Description;
var updateBranchName = SourceControlDefinition.TestSimpleSourceControlDefinition.UpdateBranchName;
var syncJobId = TestUtilities.GenerateGuid("jobId");

var sourceControl = testFixture.CreateSourceControl(sourceControlName, repoUrl, branch, folderPath, autoSync, publishRunbook,
sourceControlType, securityToken, description);

var retrievedSourceControl = testFixture.GetSourceControl(sourceControlName);
Assert.NotNull(retrievedSourceControl);

var syncJob = testFixture.CreateSourceControlSyncJob(sourceControlName, syncJobId);

var retrievedSyncJob = testFixture.GetSourceControlSyncJob(sourceControlName, syncJobId);

Assert.NotNull(retrievedSyncJob);
Assert.Equal(retrievedSyncJob.SyncJobId, syncJobId.ToString());
Assert.Equal(retrievedSyncJob.CreationTime, syncJob.CreationTime);
Assert.Equal(retrievedSyncJob.ProvisioningState, syncJob.ProvisioningState);
Assert.Equal(retrievedSyncJob.StartTime, syncJob.StartTime);
Assert.Equal(retrievedSyncJob.EndTime, syncJob.EndTime);
Assert.Equal(retrievedSyncJob.StartType, syncJob.StartType);

var syncJobList = testFixture.GetSourceControlSyncJobs(sourceControlName);

Assert.NotNull(syncJobList);
Assert.Single(syncJobList.ToList());
syncJob = syncJobList.ToList()[0];
Assert.Equal(syncJob.SyncJobId, syncJob.SyncJobId);
}
}
}

private void EnsureModuleReachesSuccessProvisioningState(string moduleName, AutomationTestBase testFixture, out Module module)
{
// Wait for the module Provisioing state to reach Succeeded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ protected void CreateAutomationClient(MockContext context)
{
var handler = new RecordedDelegatingHandler();
this.automationClient = context.GetServiceClient<AutomationClient>(false, handler);
this.automationClient.ResourceGroupName = ResourceGroupName;
this.automationClient.AutomationAccountName = AutomationAccountName;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CanGetMachineRunById()
{
this.CreateAutomationClient(context);

var run = this.automationClient.SoftwareUpdateConfigurationMachineRuns.GetById(runId);
var run = this.automationClient.SoftwareUpdateConfigurationMachineRuns.GetById(ResourceGroupName, AutomationAccountName, runId);
Assert.NotNull(run);
Assert.Equal(runId.ToString(), run.Name);
}
Expand All @@ -30,7 +30,7 @@ public void CanGetAllMachineRuns()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.List();
var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.List(ResourceGroupName, AutomationAccountName);
Assert.NotNull(runs.Value);
Assert.Equal(27, runs.Value.Count);
}
Expand All @@ -44,7 +44,7 @@ public void CanGetAllRunsByCorrelationId()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.ListByCorrelationId(correlationId);
var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.ListByCorrelationId(ResourceGroupName, AutomationAccountName, correlationId);
Assert.NotNull(runs.Value);
Assert.Equal(2, runs.Value.Count);
}
Expand All @@ -58,10 +58,10 @@ public void CanGetAllRunsByStatus()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.ListByStatus(status);
var runs = this.automationClient.SoftwareUpdateConfigurationMachineRuns.ListByStatus(ResourceGroupName, AutomationAccountName, status);
Assert.NotNull(runs.Value);
Assert.Equal(4, runs.Value.Count);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CanGetRunById()
{
this.CreateAutomationClient(context);

var run = this.automationClient.SoftwareUpdateConfigurationRuns.GetById(runId);
var run = this.automationClient.SoftwareUpdateConfigurationRuns.GetById(ResourceGroupName, AutomationAccountName, runId);
Assert.NotNull(run);
Assert.Equal(runId.ToString(), run.Name);
}
Expand All @@ -30,7 +30,7 @@ public void CanGetAllRuns()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationRuns.List();
var runs = this.automationClient.SoftwareUpdateConfigurationRuns.List(ResourceGroupName, AutomationAccountName);
Assert.NotNull(runs.Value);
Assert.Equal(15, runs.Value.Count);
}
Expand All @@ -44,7 +44,7 @@ public void CanGetAllRunsByConfigurationName()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByConfigurationName(configName);
var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByConfigurationName(ResourceGroupName, AutomationAccountName, configName);
Assert.NotNull(runs.Value);
Assert.Equal(6, runs.Value.Count);
}
Expand All @@ -58,7 +58,7 @@ public void CanGetAllRunsByOs()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByOsType(os);
var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByOsType(ResourceGroupName, AutomationAccountName, os);
Assert.NotNull(runs.Value);
Assert.Equal(17, runs.Value.Count);
}
Expand All @@ -72,7 +72,7 @@ public void CanGetAllRunsByStatus()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByStatus(status);
var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByStatus(ResourceGroupName, AutomationAccountName, status);
Assert.NotNull(runs.Value);
Assert.Equal(2, runs.Value.Count);
}
Expand All @@ -86,10 +86,10 @@ public void CanGetAllRunsByStartTime()
{
this.CreateAutomationClient(context);

var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByStartTime(startTime);
var runs = this.automationClient.SoftwareUpdateConfigurationRuns.ListByStartTime(ResourceGroupName, AutomationAccountName, startTime);
Assert.NotNull(runs.Value);
Assert.Equal(3, runs.Value.Count);
}
}
}
}
}
Loading