public async Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("retention list"); Assert.Equal(0, exit); exit = runner.Exec("retention list", "-i retentionpolicy-missing"); Assert.Equal(1, exit); exit = runner.Exec("retention create", "--after 10h --delete-all-events"); Assert.Equal(0, exit); var id = runner.LastRunProcess.Output.Trim(); exit = runner.Exec("retention list", $"-i {id}"); Assert.Equal(0, exit); var policy = await connection.RetentionPolicies.FindAsync(id); Assert.Null(policy.RemovedSignalExpression); Assert.Equal(TimeSpan.FromHours(10), policy.RetentionTime); exit = runner.Exec("retention remove", $"-i {id}"); Assert.Equal(0, exit); exit = runner.Exec("retention list", $"-i {id}"); Assert.Equal(1, exit); }
public Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("user list"); Assert.Equal(0, exit); exit = runner.Exec("user list", "-n admin"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Equal("user-admin admin", output.Trim()); #if MULTIUSER_TESTS exit = runner.Exec("user create", "-n alice -d \"Alice Example\" -r \"User (read/write)\" -p test"); Assert.Equal(0, exit); var lines = new StringReader(runner.LastRunProcess.Output); lines.ReadLine(); // Skip password STDIN warning var id = lines.ReadLine()?.Split()[0]; Assert.NotNull(id); exit = runner.Exec("user remove", $"-i {id}"); Assert.Equal(0, exit); exit = runner.Exec("user list", "-n alice"); Assert.Equal(1, exit); #endif return(Task.CompletedTask); }
public async Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("feed list", "-n nuget.org"); Assert.Equal(0, exit); exit = runner.Exec("feed list", "-i feed-missing"); Assert.Equal(1, exit); AssertExistence(runner, "Example", false); exit = runner.Exec("feed create", "-n Example -l \"https://example.com\" -u Test -p Pass"); Assert.Equal(0, exit); AssertExistence(runner, "Example", true); var feed = (await connection.Feeds.ListAsync()).Single(f => f.Name == "Example"); Assert.Equal("Example", feed.Name); Assert.Equal("https://example.com", feed.Location); Assert.Equal("Test", feed.Username); Assert.Null(feed.NewPassword); exit = runner.Exec("feed remove", "-n Example"); Assert.Equal(0, exit); AssertExistence(runner, "Example", false); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec( "user create", "-n alice -d \"Alice Example\" -r \"User (read/write)\" -p test@1234"); Assert.Equal(0, exit); var id = runner.LastRunProcess.Output.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); Assert.NotNull(id); var user = await connection.Users.FindAsync(id); Assert.All(user.RoleIds, r => r.StartsWith("role-", StringComparison.OrdinalIgnoreCase)); exit = runner.Exec("user remove", $"-i {id}"); Assert.Equal(0, exit); exit = runner.Exec("user list", "-i {id}"); Assert.Equal(1, exit); }
public Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("signal list", "-i signal-none"); Assert.Equal(1, exit); exit = runner.Exec("signal list", "-t Warnings"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Equal("signal-m33302 Warnings", output.Trim()); exit = runner.Exec("signal remove", "-t Warnings"); Assert.Equal(0, exit); exit = runner.Exec("signal list", "-i signal-m33302"); Assert.Equal(1, exit); exit = runner.Exec("signal list", "-t Warnings"); Assert.Equal(0, exit); return(Task.CompletedTask); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("node health"); Assert.Equal(0, exit); Assert.StartsWith("HTTP 1.1 200 OK", runner.LastRunProcess !.Output); return(Task.CompletedTask); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("node demote --verbose --wait --confirm"); Assert.Equal(1, exit); Assert.Contains("No cluster node is in the leader role", runner.LastRunProcess !.Output); return(Task.CompletedTask); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("node list --json"); Assert.Equal(0, exit); Assert.Contains("\"Role\":", runner.LastRunProcess !.Output); Assert.Contains("\"Name\":", runner.LastRunProcess !.Output); Assert.Contains("\"StateDescription\":", runner.LastRunProcess !.Output); return(Task.CompletedTask); }
public async Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("sample setup", "--confirm"); Assert.Equal(0, exit); var sampleWorkspace = (await connection.Workspaces.ListAsync(shared: true)) .SingleOrDefault(w => w.Title == "Sample"); Assert.NotNull(sampleWorkspace); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var filename = _testDataFolder.ItemPath("license.txt"); File.WriteAllText(filename, "Ceci n'est pas une licence"); runner.Exec("license apply", $"--certificate=\"{filename}\""); Assert.Equal( "The command failed: 400 - The license format is invalid: data precedes any keys.", runner.LastRunProcess.Output.Trim()); return(Task.CompletedTask); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var inputFiles = Path.Combine("Data", "log-*.txt"); var exit = runner.Exec("ingest", $"-i {inputFiles}"); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(); Assert.Equal(4, events.Count); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("apikey create", "-t Test"); Assert.Equal(0, exit); exit = runner.Exec("apikey list", "-t Test --json --no-color"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Contains("\"AssignedPermissions\": [\"Ingest\"]", output); return(Task.CompletedTask); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("workspace list", "-i workspace-none"); Assert.Equal(1, exit); exit = runner.Exec("workspace list", "-t Example"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Equal("", output.Trim()); var items = ""; var dashboard = (await connection.Dashboards.ListAsync(shared: true)).First(); items += $" --dashboard={dashboard.Id}"; var query = (await connection.SqlQueries.ListAsync(shared: true)).First(); items += $" --query={query.Id}"; foreach (var signal in (await connection.Signals.ListAsync(shared: true)).Take(2)) { items += $" --signal={signal.Id}"; } exit = runner.Exec("workspace create", $"-t Example {items}"); Assert.Equal(0, exit); exit = runner.Exec("workspace list", "-t Example"); Assert.Equal(0, exit); output = runner.LastRunProcess.Output; Assert.Contains("Example", output.Trim()); var workspace = (await connection.Workspaces.ListAsync(shared: true)).Single(w => w.Title == "Example"); Assert.Single(workspace.Content.DashboardIds); Assert.Single(workspace.Content.QueryIds); Assert.Equal(2, workspace.Content.SignalIds.Count); exit = runner.Exec("workspace remove", "-t Example"); Assert.Equal(0, exit); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("signal create", "-t TestSignal -f \"@Exception is not null\" -c Column1 -c \"round(Property2, 1)\""); Assert.Equal(0, exit); var signals = await connection.Signals.ListAsync(shared : true); var testSignal = signals.First(x => x.Title == "TestSignal"); Assert.Equal("@Exception is not null", testSignal.Filters[0].Filter); Assert.Equal("Column1", testSignal.Columns[0].Expression); Assert.Equal("round(Property2, 1)", testSignal.Columns[1].Expression); }
static void AssertExistence(CliCommandRunner runner, string feedName, bool exists) { var exit = runner.Exec("feed list", $"-n {feedName}"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; if (exists) { Assert.Contains(feedName, output); } else { Assert.Equal("", output.Trim()); } }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var inputFile = Path.Combine("Data", "events.ndjson"); Assert.True(File.Exists(inputFile)); var exit = runner.Exec("ingest", $"--json -i {inputFile}"); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(); Assert.Equal(15, events.Count); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("log", "-m \"Hello, {Name}!\" -p Name=world"); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(render : true, filter : "Name = 'world'"); Assert.Single(events); var hello = events.Single(); Assert.Equal("Hello, world!", hello.RenderedMessage); }
public Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("user list"); Assert.Equal(0, exit); exit = runner.Exec("user list", "-n admin"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Equal("user-admin admin", output.Trim()); return(Task.CompletedTask); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("help", "--markdown", disconnected: true); Assert.Equal(0, exit); var markdown = runner.LastRunProcess !.Output; Assert.StartsWith("## Commands", markdown); var indexOfTemplateExport = markdown.IndexOf("### `template export`", StringComparison.Ordinal); var indexOfTemplateImport = markdown.IndexOf("### `template import`", StringComparison.Ordinal); Assert.NotEqual(indexOfTemplateExport, indexOfTemplateImport); Assert.True(indexOfTemplateExport < indexOfTemplateImport); return(Task.CompletedTask); }
public async Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var originalTitle = Guid.NewGuid().ToString("n"); var description = Guid.NewGuid().ToString("n"); var signal = await connection.Signals.TemplateAsync(); signal.OwnerId = null; signal.Title = originalTitle; signal.Description = description; await connection.Signals.AddAsync(signal); var exit = runner.Exec("template export", $"-o \"{_testDataFolder.Path}\""); Assert.Equal(0, exit); var exportedFilename = _testDataFolder.ItemPath($"signal-{originalTitle}.template"); Assert.True(File.Exists(exportedFilename)); var content = await File.ReadAllTextAsync(exportedFilename); var newTitle = Guid.NewGuid().ToString("n"); content = content.Replace(originalTitle, newTitle); await File.WriteAllTextAsync(exportedFilename, content); exit = runner.Exec("template import", $"-i \"{_testDataFolder.Path}\""); Assert.Equal(0, exit); var created = Assert.Single(await connection.Signals.ListAsync(shared: true), s => s.Title == newTitle); Assert.Equal(description, created !.Description); // Uses import state exit = runner.Exec("template import", $"-i \"{_testDataFolder.Path}\""); Assert.Equal(0, exit); var updated = Assert.Single(await connection.Signals.ListAsync(shared: true), s => s.Title == newTitle); Assert.Equal(created.Id, updated !.Id); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var inputFile = Path.Combine("Data", "levelled-events.txt"); Assert.True(File.Exists(inputFile)); var exit = runner.Exec("ingest", $"-i \"{inputFile}\"" + " -x \"{@l:token} {@m:line}\""); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(render : true); Assert.Equal(2, events.Count); Assert.Equal(1, events.Count(e => e.RenderedMessage == "Hello")); // Since @l is a token, no level mapping is applied Assert.Equal(1, events.Count(e => e.Level == "INFO")); Assert.Equal(1, events.Count(e => e.Level == "WARN")); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var inputFile = Path.Combine("Data", "serilog-events.txt"); Assert.True(File.Exists(inputFile)); var exit = runner.Exec("ingest", $"-i \"{inputFile}\"" + " -x \"{@t:timestamp} [{@l:level}] {@m:*}{:n}{@x:*}\""); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(); Assert.Equal(3, events.Count); // Since @l is a level, mapping to full/non-abbreviated names is performed Assert.Equal(1, events.Count(e => e.Level == "Error")); Assert.Equal(2, events.Count(e => e.Level == "Information")); Assert.Equal(1, events.Count(e => e.Exception != null && e.Exception.Contains("MyFlakyMethod()"))); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var create = runner.Exec("profile create", "-n Test -s https://seq.example.com -a 123", disconnected: true); Assert.Equal(0, create); Assert.Equal(0, runner.Exec("profile list", disconnected: true)); Assert.Contains("test (https://seq.example.com)", runner.LastRunProcess.Output); Assert.Equal(0, runner.Exec("config", disconnected: true)); Assert.Contains("profiles[test].serverUrl", runner.LastRunProcess.Output); Assert.Contains("https://seq.example.com", runner.LastRunProcess.Output); Assert.Contains("profiles[test].apiKey", runner.LastRunProcess.Output); Assert.Contains("123", runner.LastRunProcess.Output); var remove = runner.Exec("profile remove", "-n Test", disconnected: true); Assert.Equal(0, remove); return(Task.CompletedTask); }
public Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("dashboard list"); Assert.Equal(0, exit); var id = runner.LastRunProcess.Output.Split(' ')[0]; exit = runner.Exec("dashboard render", $"-i {id} -c \"All Events\" --last 1d --by 1h"); Assert.Equal(0, exit); var lines = new StringReader(runner.LastRunProcess.Output); var firstLine = lines.ReadLine(); Assert.Equal("\"time\",\"count\"", firstLine); return(Task.CompletedTask); }
public async Task ExecuteAsync( SeqConnection connection, ILogger logger, CliCommandRunner runner) { var inputFile = Path.Combine("Data", "events.clef"); Assert.True(File.Exists(inputFile)); var exit = runner.Exec("ingest", $"--json -i {inputFile}"); Assert.Equal(0, exit); var events = await connection.Events.ListAsync(); Assert.Equal(15, events.Count); Assert.Equal(1, events.Count(e => e.Level == "WARN")); Assert.Equal(2, events.Count(e => e.Level == "Error")); Assert.Equal(1, events.Count(e => e.Level == "Trace")); Assert.Equal(1, events.Count(e => e.Level == "Debug")); Assert.Equal(10, events.Count(e => e.Level == "Information")); }
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec( "user create", "-n carol -r \"Administrator\" -p test@1234 --no-password-change"); Assert.Equal(0, exit); exit = runner.Exec( "apikey create", "-t Setup --permissions=Setup,Write --connect-username=carol --connect-password=\"test@1234\""); Assert.Equal(0, exit); exit = runner.Exec("apikey list", "-t Setup --json --no-color"); Assert.Equal(0, exit); var output = runner.LastRunProcess.Output; Assert.Contains("\"AssignedPermissions\": [\"Setup\", \"Write\"]", output); return(Task.CompletedTask); }