protected BaseWorkflowExecutor( IDictionary <string, string> configSettings = null, MockPolicyAgentService policyAgentService = null, MockRepairManager repairManager = null) { PolicyAgentService = policyAgentService ?? new MockPolicyAgentService(); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); var policyAgentClient = new PolicyAgentClient(env, PolicyAgentService, activityLogger); RepairManager = repairManager ?? new MockRepairManagerFactory().Create() as MockRepairManager; Coordinator = new MockInfrastructureCoordinatorFactory( configSettings, policyAgentClient, RepairManager).Create() as AzureParallelInfrastructureCoordinator; CompletedEvent = new ManualResetEvent(false); TestExecutionTimeInSeconds = 300; }
public static int GetDoc(string[] args) { CoordinatorEnvironment env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); Uri zeroSdkUri = null; if (args.Length >= 2) { zeroSdkUri = new Uri(args[1], UriKind.Absolute); } var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var pac = new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger, zeroSdkUri), activityLogger); IPolicyAgentDocumentForTenant doc = pac.GetDocumentAsync(Guid.NewGuid(), CancellationToken.None).GetAwaiter().GetResult(); Constants.TraceType.ConsoleWriteLine("Doc: {0}", doc); foreach (ITenantJob job in doc.Jobs) { Constants.TraceType.ConsoleWriteLine(job.ToJson()); } foreach (RoleInstanceHealthInfo health in doc.RoleInstanceHealthInfos) { Constants.TraceType.ConsoleWriteLine(health.ToJson()); } return(0); }
private Reconciler CreateReconciler() { var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", configSection, string.Empty, new MockInfrastructureAgentWrapper()); return(new Reconciler(env, policyAgentClient, repairManager, new RepairActionProvider(configSection))); }
public JobClassifierTest() { configSection = new ConfigSection(Constants.TraceType, configStore, "IS"); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", configSection, string.Empty, new MockInfrastructureAgentWrapper()); jobClassifier = new JobClassifier(env); }
public ReconcilerTest() { configSection = new ConfigSection(Constants.TraceType, configStore, "IS/Reconciler"); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", configSection, string.Empty, new MockInfrastructureAgentWrapper()); policyAgentClient = new PolicyAgentClient(env, new MockPolicyAgentService(), activityLogger); }
public void TestInitialize() { this.configStore = new MockConfigStore(); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(TraceType, this.configStore, ConfigSectionName), string.Empty, new MockInfrastructureAgentWrapper()); this.translator = new ImpactTranslator(env); }
private static PolicyAgentClient CreatePolicyAgentClient() { CoordinatorEnvironment env = new CoordinatorEnvironment( ToolName, new NullConfigSection(), string.Empty, null); var traceType = new TraceType(ToolName); var activityLogger = new ActivityLoggerFactory().Create(traceType); var policyAgentServiceWrapper = new PolicyAgentServiceWrapper(env, activityLogger, new Uri("http://169.254.169.254:80/mrzerosdk")); var policyAgentClient = new PolicyAgentClient(env, policyAgentServiceWrapper, activityLogger); return(policyAgentClient); }
public void Initialize() { configStore = new MockConfigStore(); configStore.AddKeyValue("InfrastructureService", "Azure.ProcessRemovedNodesRetryIntervalInSeconds", "1"); env = new CoordinatorEnvironment( "fabric:/IS", new ConfigSection(Constants.TraceType, configStore, "InfrastructureService"), string.Empty, new MockInfrastructureAgentWrapper()); rm = new DelegatedRepairManager <MockRepairTask>(); rm.UpdateRepairExecutionStateAsyncHandler = t => Task.FromResult(0L); rm.RemoveNodeStateAsyncHandler = (n, timeout, token) => { throw new InvalidOperationException(); }; }
/// <remarks> /// If <see cref="configSettings"/> is null, a default value is used. /// </remarks> public MockInfrastructureCoordinatorFactory( IDictionary <string, string> configSettings = null, IPolicyAgentClient policyAgentClient = null, IRepairManager repairManager = null) { this.configSettings = configSettings != null ? new Dictionary <string, string>(configSettings, StringComparer.OrdinalIgnoreCase) : new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); this.policyAgentClient = policyAgentClient ?? new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger), activityLogger); this.repairManager = repairManager ?? new MockRepairManager(); }
public static int AcknowledgeJob(string[] args) { CoordinatorEnvironment env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); Uri zeroSdkUri = null; if (args.Length >= 2) { zeroSdkUri = new Uri(args[1], UriKind.Absolute); } int incarnationNumber = int.Parse(args[2]); Guid jobId = Guid.Parse(args[3]); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var pac = new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger, zeroSdkUri), activityLogger); var jobResponseMap = new Dictionary <Guid, JobStepResponseEnum> { { jobId, JobStepResponseEnum.Acknowledged } }; try { pac.SendJobResponseAsync( Guid.NewGuid(), incarnationNumber, jobResponseMap, "{0} by operator command".ToString(JobStepResponseEnum.Acknowledged), CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine("{0} job response sent successfully", JobStepResponseEnum.Acknowledged); } catch (ManagementException ex) { Console.WriteLine("Error in management protocol while sending job response. Exception: {0}", ex); return(-1); } return(0); }
public IInfrastructureCoordinator Create() { string configSectionName = typeof(MockInfrastructureCoordinatorFactory).Name + "ConfigSection"; const string ConfigJobPollingIntervalInSecondsKeyName = Parallel.Constants.ConfigKeys.JobPollingIntervalInSeconds; var configStore = new MockConfigStore(); // loop faster in the ProcessManagementNotification loop of WindowsAzureInfrastructureCoordinator configStore.AddKeyValue(configSectionName, ConfigJobPollingIntervalInSecondsKeyName, "1"); foreach (var pair in configSettings) { configStore.AddKeyValue(configSectionName, pair.Key, pair.Value); } var partitionId = Guid.NewGuid(); var jobBlockingPolicyManager = new MockJobBlockingPolicyManager(); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var configSection = new ConfigSection(Constants.TraceType, configStore, configSectionName); var allowActionMap = new AllowActionMap(); var env = new CoordinatorEnvironment("fabric:/System/InfrastructureService/Mock", configSection, "mytenant", new MockInfrastructureAgentWrapper()); var coordinatorCommandProcessor = new CoordinatorCommandProcessor(env, policyAgentClient, jobBlockingPolicyManager, allowActionMap); var coordinator = new AzureParallelInfrastructureCoordinator( env, "mytenant", policyAgentClient, repairManager, new MockHealthClient(), coordinatorCommandProcessor, jobBlockingPolicyManager, new DefaultActionPolicyFactory(env, jobBlockingPolicyManager, allowActionMap), activityLogger, partitionId, 0); return(coordinator); }