Browse Source

Fixing ingress for local rules (#897)

pull/906/head
Justin Kotalik 6 years ago
committed by GitHub
parent
commit
c50d480e37
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Microsoft.Tye.Hosting/HttpProxyService.cs
  2. 4
      test/E2ETest/TyeRunTests.cs
  3. 4
      test/E2ETest/testassets/generate/apps-with-ingress.1.18.yaml
  4. 7
      test/E2ETest/testassets/generate/apps-with-ingress.1.19.yaml
  5. 8
      test/E2ETest/testassets/projects/apps-with-ingress/ApplicationA/Startup.cs
  6. 3
      test/E2ETest/testassets/projects/apps-with-ingress/tye.yaml

2
src/Microsoft.Tye.Hosting/HttpProxyService.cs

@ -153,7 +153,7 @@ namespace Microsoft.Tye.Hosting
}
var uri = new UriBuilder(uris[next].Uri)
{
Path = rule.PreservePath ? $"{context.Request.Path}{context.Request.RouteValues["path"]}" : (string)context.Request.RouteValues["path"] ?? "/",
Path = rule.PreservePath ? $"{context.Request.Path}" : (string)context.Request.RouteValues["path"] ?? "/",
Query = context.Request.QueryString.Value
};

4
test/E2ETest/TyeRunTests.cs

@ -697,6 +697,10 @@ services:
Assert.StartsWith("Hello from Application A", await responseA.Content.ReadAsStringAsync());
Assert.StartsWith("Hello from Application B", await responseB.Content.ReadAsStringAsync());
// checking preservePath behavior
var responsePreservePath = await client.GetAsync(ingressUri + "/C/test");
Assert.Contains("Hit path /C/test", await responsePreservePath.Content.ReadAsStringAsync());
});
}

4
test/E2ETest/testassets/generate/apps-with-ingress.1.18.yaml

@ -145,6 +145,10 @@ spec:
serviceName: appb
servicePort: 80
path: /B(/|$)(.*)
- backend:
serviceName: appa
servicePort: 80
path: /()(C.*)
- host: a.example.com
http:
paths:

7
test/E2ETest/testassets/generate/apps-with-ingress.1.19.yaml

@ -151,6 +151,13 @@ spec:
number: 80
path: /B(/|$)(.*)
pathType: Prefix
- backend:
service:
name: appa
port:
number: 80
path: /()(C.*)
pathType: Prefix
- host: a.example.com
http:
paths:

8
test/E2ETest/testassets/projects/apps-with-ingress/ApplicationA/Startup.cs

@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Text.Json;
using Microsoft.AspNetCore.Builder;
@ -32,6 +32,12 @@ namespace ApplicationA
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello from Application A " + Environment.GetEnvironmentVariable("APP_INSTANCE") ?? Environment.GetEnvironmentVariable("HOSTNAME"));
await context.Response.WriteAsync(context.Request.Path);
});
endpoints.MapGet("/C/test", async context =>
{
await context.Response.WriteAsync("Hit path /C/test");
});
// This method returns the body content and query string back to the caller, to test that the ingress passes those properly

3
test/E2ETest/testassets/projects/apps-with-ingress/tye.yaml

@ -14,6 +14,9 @@ ingress:
service: appA
- path: /B
service: appB
- path: /C
service: appA
preservePath: true
- host: a.example.com
service: appA
- host: b.example.com

Loading…
Cancel
Save