Exemplo n.º 1
0
        public TyeRunTests(ITestOutputHelper output)
        {
            _output = output;
            _sink   = new TestOutputLogEventSink(output);

            _options = new JsonSerializerOptions()
            {
                PropertyNameCaseInsensitive = true,
                PropertyNamingPolicy        = JsonNamingPolicy.CamelCase,
                WriteIndented = true,
            };

            _options.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
        }
Exemplo n.º 2
0
 public TyeBuildTests(ITestOutputHelper output)
 {
     this.output = output;
     sink        = new TestOutputLogEventSink(output);
 }
Exemplo n.º 3
0
 public ApplicationTests(ITestOutputHelper output)
 {
     _sink = new TestOutputLogEventSink(output);
 }
Exemplo n.º 4
0
 public TyePurgeTests(ITestOutputHelper output)
 {
     _output = output;
     _sink   = new TestOutputLogEventSink(output);
 }
Exemplo n.º 5
0
        private async Task RunHostingApplication(ApplicationBuilder application, string[] args, TestOutputLogEventSink sink, Func <Uri, Task> execute)
        {
            using var host = new TyeHost(application.ToHostingApplication(), args)
                  {
                      Sink = sink,
                  };

            await StartHostAndWaitForReplicasToStart(host);

            var serviceApi = new Uri(host.DashboardWebApplication !.Addresses.First());

            try
            {
                await execute(serviceApi !);
            }
            finally
            {
                using (var client = new HttpClient())
                {
                    // If we failed, there's a good chance the service isn't running. Let's get the logs either way and put
                    // them in the output.
                    foreach (var s in host.Application.Services.Values)
                    {
                        var request  = new HttpRequestMessage(HttpMethod.Get, new Uri(serviceApi, $"/api/v1/logs/{s.Description.Name}"));
                        var response = await client.SendAsync(request);

                        var text = await response.Content.ReadAsStringAsync();

                        _output.WriteLine($"Logs for service: {s.Description.Name}");
                        _output.WriteLine(text);
                    }
                }

                await host.StopAsync();
            }
        }