protected BaseWorkflowExecutor(IDictionary <string, string> configSettings = null, MockQueryClient queryClient = null) { ManagementClient = new MockManagementClient(); QueryClient = queryClient; InfrastructureAgent = new MockInfrastructureAgentWrapper(); Coordinator = new MockInfrastructureCoordinatorFactory(ManagementClient, configSettings, queryClient, InfrastructureAgent).Create() as WindowsAzureInfrastructureCoordinator; NotificationContext = new MockManagementNotificationContext(); CompletedEvent = new ManualResetEvent(false); TestExecutionTimeInSeconds = 300; }
private static async Task EvaluateImpactAsync(string jobId, JobType jobType) { var instancesAndReasons1 = new[] { "WF_IN_0", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_4", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_8", ImpactReason.ConfigurationUpdate.ToString(), }; var qc = new MockQueryClient(GetNodeList()); var jobImpactManager = new JobImpactManager(GetConfigSection(), qc); var notification = GetNotification(jobId, 0, instancesAndReasons1, jobType); var jobImpact = await jobImpactManager.EvaluateJobImpactAsync(notification).ConfigureAwait(false); Verify.AreEqual(jobImpact, JobImpactTranslationMode.Default, "Verifying published impact since no history is stored"); var instancesAndReasons2 = new[] { "WF_IN_1", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_5", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_9", ImpactReason.ConfigurationUpdate.ToString(), }; notification = GetNotification(jobId, 1, instancesAndReasons2, jobType); // at this time, we should reuse the saved history jobImpact = await jobImpactManager.EvaluateJobImpactAsync(notification).ConfigureAwait(false); Verify.AreEqual(jobImpact, JobImpactTranslationMode.Optimized, "Verifying published impact since there wasn't a reboot of nodes previously"); jobImpact = await jobImpactManager.EvaluateJobImpactAsync(notification).ConfigureAwait(false); Verify.AreEqual(jobImpact, JobImpactTranslationMode.Optimized, "Verifying invoking again (within validity time) shouldn't change result"); // simulate nodes going down await Task.Delay(TimeSpan.FromSeconds(2)).ConfigureAwait(false); qc.Nodes = GetNodeList(DateTimeOffset.UtcNow); // for the next UD, since the nodes have gone down, don't use history var instancesAndReasons3 = new[] { "WF_IN_2", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_6", ImpactReason.ConfigurationUpdate.ToString(), "WF_IN_10", ImpactReason.ConfigurationUpdate.ToString(), }; notification = GetNotification(jobId, 2, instancesAndReasons3, jobType); jobImpact = await jobImpactManager.EvaluateJobImpactAsync(notification).ConfigureAwait(false); Verify.AreEqual(jobImpact, JobImpactTranslationMode.Default, "Verifying published impact since nodes have rebooted after previous evaluation"); }