public Task <TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken) { log.Id = LogObjects.Count + 1; LogObjects.Add(log.Id, log); LogLines.Add(log.Id, new List <string>()); return(Task.FromResult(log)); }
public void ShouldRemoveMachinesBelongingToMultiplePoolsInsteadOfDeleting() { CommandLineArgs.Add("-workerpool=SomePool"); CommandLineArgs.Add("-health-status=Unhealthy"); Repository.WorkerPools.FindByName("SomePool") .Returns( new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } ); var workerList = MakeWorkerList(2, new List <ReferenceCollection> { new ReferenceCollection(new List <string> { "WorkerPools-001", "WorkerPools-002" }), new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); cleanPoolCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", workerList.Count, "SomePool", MachineModelHealthStatus.Unhealthy.ToString())); LogLines.Should().Contain("Note: Some of these machines belong to multiple pools. Instead of being deleted, these machines will be removed from the SomePool pool."); LogLines.Should().Contain($"Removing {workerList[0].Name} {workerList[0].Status} (ID: {workerList[0].Id}) from SomePool"); Assert.That(workerList[0].WorkerPoolIds.Count, Is.EqualTo(1), "The machine should have been removed from the SomePool pool."); Repository.Workers.Received().Modify(workerList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[1].Name, workerList[1].Status, workerList[1].Id)); Repository.Workers.Received().Delete(workerList[1]); }
public void RefreshPluginData() { try { var found = false; foreach (var plugin in MainViewModel.Instance.Plugins) { if (!plugin.StartsWith(Global.LibdcpluginLogging)) { continue; } var a = plugin.Split(','); LogFile = a[1]; found = true; } if (!found) { LogFile = string.Empty; IsLogging = false; LogLines.Clear(); } } catch (Exception) { LogFile = string.Empty; IsLogging = false; LogLines.Clear(); } }
public void ShouldCleanPool() { CommandLineArgs.Add("-workerpool=SomePool"); CommandLineArgs.Add("-health-status=Unhealthy"); Repository.WorkerPools.FindByName("SomePool") .Returns( new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } ); var workerList = MakeWorkerList(2, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001"), new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); cleanPoolCommand.Execute(CommandLineArgs.ToArray()).GetAwaiter().GetResult(); LogLines.Should().Contain(string.Format("Found {0} machines in {1} with the status {2}", workerList.Count, "SomePool", MachineModelHealthStatus.Unhealthy.ToString())); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[0].Name, workerList[0].Status, workerList[0].Id)); Repository.Workers.Received().Delete(workerList[0]); LogLines.Should().Contain(string.Format("Deleting {0} {1} (ID: {2})", workerList[1].Name, workerList[1].Status, workerList[1].Id)); Repository.Workers.Received().Delete(workerList[1]); }
public async Task ShouldGetListOfWorkerWithNoArgs() { Repository.WorkerPools.FindAll().Returns(new List <WorkerPoolResource> { new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" }, new WorkerPoolResource { Name = "SomeOtherPool", Id = "WorkerPools-002" } }); var workerList = MakeWorkerList(3, new List <MachineModelStatus> { MachineModelStatus.Online, MachineModelStatus.Offline, MachineModelStatus.Offline }, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001"), new ReferenceCollection("WorkerPools-002"), new ReferenceCollection("WorkerPools-002") }); Repository.Workers.FindAll().Returns(workerList); await listWorkersCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Workers: 3"); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[0].Name, workerList[0].Status.ToString(), workerList[0].Id, "SomePool")); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[1].Name, workerList[1].Status.ToString(), workerList[1].Id, "SomeOtherPool")); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[2].Name, workerList[2].Status.ToString(), workerList[2].Id, "SomeOtherPool")); }
public async Task ShouldGetListOfMachinesWithNoArgs() { Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll().Returns(new List <MachineResource> { new MachineResource { Name = "PC01234", Id = "Machines-001", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Machines: 2"); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01234", MachineModelStatus.Online.ToString(), "Machines-001", "Development")); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01466", MachineModelStatus.Online.ToString(), "Machines-002", "Development")); }
public async Task ShouldGetListOfWorkersWithPoolArgs() { CommandLineArgs.Add("-workerpool=SomePool"); Repository.WorkerPools.FindAll().Returns(new List <WorkerPoolResource> { new WorkerPoolResource { Name = "SomePool", Id = "WorkerPools-001" } }); var workerList = MakeWorkerList(1, new List <MachineModelStatus> { MachineModelStatus.Online }, new List <ReferenceCollection> { new ReferenceCollection("WorkerPools-001") }); Repository.Workers.FindMany(Arg.Any <Func <WorkerResource, bool> >()).Returns(workerList); await listWorkersCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Workers: 1"); LogLines.Should().Contain(string.Format(MachineLogFormat, workerList[0].Name, workerList[0].Status.ToString(), workerList[0].Id, "SomePool")); }
public async Task ShouldCreateNewChannel() { Repository.Client.RootDocument.Returns(new RootResource { Links = new LinkCollection().Add("Channels", "DOES_NOT_MATTER") }); var projectName = $"Project-{Guid.NewGuid()}"; var project = new ProjectResource() { Links = new LinkCollection().Add("Channels", "DOES_NOT_MATTER") }; Repository.Projects.FindByName(projectName).Returns(project); var lifecycleName = $"Lifecycle-{Guid.NewGuid()}"; Repository.Lifecycles.FindOne(Arg.Any <Func <LifecycleResource, bool> >()).Returns(new LifecycleResource()); Repository.Projects.GetChannels(Arg.Any <ProjectResource>()) .Returns(new ResourceCollection <ChannelResource>(Enumerable.Empty <ChannelResource>(), new LinkCollection())); var channelName = $"Channel-{Guid.NewGuid()}"; CommandLineArgs.Add($"--channel={channelName}"); CommandLineArgs.Add($"--project={projectName}"); CommandLineArgs.Add($"--lifecycle={lifecycleName}"); await createChannelCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"[Information] Channel {channelName} created"); }
public async Task ShouldGetListOfMachinesWithEnvironmentArgs() { CommandLineArgs.Add("-environment=Development"); Repository.Environments.FindAll().Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindMany(Arg.Any <Func <MachineResource, bool> >()).Returns(new List <MachineResource> { new MachineResource { Name = "PC01234", Id = "Machines-001", Status = MachineModelStatus.Online, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("[Information] Machines: 1"); LogLines.Should().Contain(string.Format(MachineLogFormat, "PC01234", MachineModelStatus.Online.ToString(), "Machines-001", "Development")); LogLines.Should().NotContain(string.Format(MachineLogFormat, "PC01466", MachineModelStatus.Online.ToString(), "Machines-002", "Development")); LogLines.Should().NotContain(string.Format(MachineLogFormat, "PC01996", MachineModelStatus.Offline.ToString(), "Machines-003", "Development")); }
protected override Task <int> Handle(int lambdaEvent, MiddyNetContext context) { LogLines.Add(FunctionLog); ContextLogLines.AddRange(context.AdditionalContext.Select(kv => $"{kv.Key}-{kv.Value}")); Exceptions.AddRange(context.MiddlewareExceptions); return(Task.FromResult(0)); }
/// <summary> /// Calls the LogLines event handler with GUI thread safety. /// </summary> /// <param name="e">The event arguments.</param> protected virtual void OnLogLines(LogLinesEventArgs e) { if (LogLines != null) { // Call with GUI thread safety LogLines.GetInvocationList().InvokeEventGUIThreadSafe(this, e); } }
public async Task ShouldUpdateExistingChannel() { var channelName = SetupExistingChannel(); await createChannelCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Channel {channelName} updated"); }
public void Clear() { LogLine temp; while (LogLines.TryDequeue(out temp)) { } Console.WriteLine("Cleared the logs"); }
public async Task ShouldNotFailWhenTenantIsRemoved() { CommandLineArgs.Add("--project=ProjectA"); await listLatestDeploymentsCommands.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain(" - Tenant: tenant1"); LogLines.Should().Contain(" - Tenant: <Removed>"); }
private async Task GenerateScriptsInternalAsync(string commandValue) { LogLines.Clear(); DacDbHistorySchemaControllerBuilder builder = new DacDbHistorySchemaControllerBuilder(this.Configuration, this.LogLines); DbHistorySchemaController controller = null; DacSchemaReader reader = null; FileStream sourceStream = null; switch (_sourceType) { case EndPointType.FilePath: sourceStream = new FileStream(_source, FileMode.Open, FileAccess.Read); reader = new DacSchemaReader(sourceStream, true, this.LogLines); break; case EndPointType.ConnectionString: reader = new DacSchemaReader(_source, this.LogLines); break; case EndPointType.FolderPath: throw new InvalidOperationException("Source cannot be of type folder"); } try { switch (_destinationType) { case EndPointType.FilePath: controller = builder.Build(reader, new FileScriptDestinationWriter(Destination, this.Configuration, this.LogLines)); break; case EndPointType.ConnectionString: controller = builder.Build(reader, new DbScriptDestinationWriter(Destination, this.LogLines)); break; case EndPointType.FolderPath: controller = builder.Build(reader, new FolderScriptDestinationWriter(new DestinationConfiguration() { Common = this.Configuration, Destination = Destination }, this.LogLines)); break; } if (controller != null) { controller.GenerateHistorySchemaObjects(); } } finally { if (sourceStream != null) { sourceStream.Dispose(); } } }
public void Create_2_LogEntries_From_A_CollectionOfLines() { var loglines = new LogLines(); loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); Assert.AreEqual(2, target.Lines.Count); }
public async Task ShouldGetListOfEnvironments() { SetupEnvironments(); await listEnvironmentsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Environments: 2"); LogLines.Should().Contain(" - Dev (ID: devenvid)"); LogLines.Should().Contain(" - Prod (ID: prodenvid)"); }
public Task <int> After(int lambdaResponse, MiddyNetContext context) { LogLines.Add($"{MiddlewareAfterLog}-{position}"); if (Failing) { throw new MiddlewareException(); } return(Task.FromResult(0)); }
public async Task ShouldGetListOfWorkerPools() { SetupPools(); await listWorkerPoolsCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("WorkerPools: 2"); LogLines.Should().Contain(" - default (ID: defaultid)"); LogLines.Should().Contain(" - windows (ID: windowsid)"); }
public void Sort_LogEntries_BasedOn_Date() { var loglines = new LogLines(); loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); var testvalue = target.SortedLines(); Assert.AreEqual("2020/09/16 09:44", testvalue.Values[0].getDateTime()); }
public Task <TaskLog> AppendLogContentAsync(Guid scopeIdentifier, string hubName, Guid planId, int logId, Stream uploadStream, CancellationToken cancellationToken) { var reader = new StreamReader(uploadStream); var text = reader.ReadToEnd(); var addedLines = text.Split("\n"); var lines = LogLines.GetValueOrDefault(logId); lines.AddRange(addedLines); return(Task.FromResult(LogObjects.GetValueOrDefault(logId))); }
private void OnLogTextChanged(RawContentsChangedEventArgs args) { Debug.WriteLine("RawContentChanged event fired"); LogLines.Clear(); LogLines.AddRange(args.NewText .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) .Select(line => new LogLine(line.Trim(), LogHighlight.None))); RawContentChanged?.Invoke(this, args); }
public Task Before(int lambdaEvent, MiddyNetContext context) { LogLines.Add($"{MiddlewareBeforeLog}-{position}"); context.AdditionalContext.Add($"{ContextKeyLog}-{position}", $"{ContextLog}-{position}"); if (Failing) { throw new MiddlewareException(); } return(Task.CompletedTask); }
public async Task ShouldGetListOfDeployments() { var argsWithNumber = new List <string>(CommandLineArgs) { "--number=1" }; await listDeploymentsCommands.Execute(argsWithNumber.ToArray()).ConfigureAwait(false); LogLines.Should().Contain(" - Project: ProjectA"); LogLines.Should().NotContain(" - Project: ProjectB"); }
public void Sort_Two_LogEntries_For_The_Same_In_The_Order_They_Appear_In_TheLogs() { var loglines = new LogLines(); testline = "[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): 2"; loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add(testline); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); var testvalue = target.SortedLines(); Assert.AreEqual(testline, testvalue.Values[2].getLine()); }
public async Task ShouldGetListOfMachinesWithMachineHealthStatusArgs() { CommandLineArgs.Add("--health-status=HasWarnings"); (await Repository.LoadRootDocument()).Version = "3.5.0"; Repository.Environments.FindAll() .Returns(new List <EnvironmentResource> { new EnvironmentResource { Name = "Development", Id = "Environments-001" } }); Repository.Machines.FindAll() .Returns(new List <MachineResource> { new MachineResource { Name = "PC0123", Id = "Machines-001", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.Unavailable, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01466", Id = "Machines-002", Status = MachineModelStatus.Online, HealthStatus = MachineModelHealthStatus.HasWarnings, EnvironmentIds = new ReferenceCollection("Environments-001") }, new MachineResource { Name = "PC01996", Id = "Machines-003", Status = MachineModelStatus.Offline, HealthStatus = MachineModelHealthStatus.Healthy, EnvironmentIds = new ReferenceCollection("Environments-001") } }); await listMachinesCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Machines: 1"); LogLines.Should() .Contain(string.Format(MachineLogFormat, "PC01466", MachineModelHealthStatus.HasWarnings.ToString(), "Machines-002", "Development")); }
public async Task ShouldDeleteOverrideForEnvironment() { CommandLineArgs.Add("-project=OctoFx"); CommandLineArgs.Add("-environment=Production"); project.AutoDeployReleaseOverrides.Add(new AutoDeployReleaseOverrideResource(environment.Id, release.Id)); await deleteAutoDeployOverrideCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain("Deleted auto deploy release override for the project OctoFx to the environment Production"); await Repository.Projects.ReceivedWithAnyArgs().Modify(null).ConfigureAwait(false); Assert.True(!savedProject.AutoDeployReleaseOverrides.Any()); }
public async Task <Core.Model.ScanResult> DoScan() { Clear(); LogLines.Add(new Core.Model.LogLine() { Message = $"Started scan at {DateTime.Now.ToLongTimeString()}", Value = string.Empty, LogLineType = Core.Model.LogLineTypeEnum.Info }); BaseFolder = ScanOptions.BaseFolderPath; CheckBaseFolder(ScanOptions.BaseFolderPath); CancellationToken = new System.Threading.CancellationTokenSource(); Cancelled = false; var clock = new System.Diagnostics.Stopwatch(); clock.Restart(); var f = await Task.Run(() => ScanFolder(BaseFolder)); if (!Cancelled) { ScanResult.WambyFolderInfo = f; ScanResult.AllFolders = ScanResult.WambyFolderInfo.Folders. Where(p => p.IsFolder).SelectManyRecursive(p => p.Folders).ToList(); ScanResult.AllFolders.Add(ScanResult.WambyFolderInfo); if (ScanResult.WambyFolderInfo.Files.Count > 0) { ScanResult.AllFolders.Add(AddCurrentFolderFileSummary(ScanResult.WambyFolderInfo)); } var allfiles = ScanResult.AllFolders.SelectMany(p => p.Files); ScanResult.AllFiles.AddRange(allfiles); var totalDeepLenght = ScanResult.WambyFolderInfo.DeepLenght; var totalDeepFilesCount = ScanResult.WambyFolderInfo.DeepFilesCount; ScanResult.AllFolders.ForEach(p => { p.DeepLenghtPercent = p.DeepLenght / totalDeepLenght; p.DeepFilesCountPercent = p.DeepFilesCount / totalDeepFilesCount; }); } clock.Stop(); ScanResult.ElapsedTime = clock.Elapsed; LogLines.Add(new Core.Model.LogLine() { Message = $"Finished scan. Ellapsed time: {ScanResult.ElapsedTime.TotalSeconds.ToString("n2")} sec.", Value = string.Empty, LogLineType = Core.Model.LogLineTypeEnum.Info }); return(ScanResult); }
public async Task DefaultOutput_CreateNewWorkerPool() { var newPool = Guid.NewGuid().ToString(); CommandLineArgs.Add($"--name={newPool}"); Repository.WorkerPools.FindByName(Arg.Any <string>()).Returns((WorkerPoolResource)null); Repository.WorkerPools.Create(Arg.Any <WorkerPoolResource>()) .Returns(new WorkerPoolResource { Id = Guid.NewGuid().ToString(), Name = newPool }); await createWorkerPoolCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Creating worker pool: {newPool}"); }
public async Task DefaultOutput_CreateNewEnvironment() { var newEnv = Guid.NewGuid().ToString(); CommandLineArgs.Add($"--name={newEnv}"); Repository.Environments.FindByName(Arg.Any <string>()).Returns((EnvironmentResource)null); Repository.Environments.Create(Arg.Any <EnvironmentResource>()) .Returns(new EnvironmentResource { Id = Guid.NewGuid().ToString(), Name = newEnv }); await createEnvironmentCommand.Execute(CommandLineArgs.ToArray()).ConfigureAwait(false); LogLines.Should().Contain($"Creating environment: {newEnv}"); }