committed by
GitHub
16 changed files with 249 additions and 17 deletions
@ -0,0 +1,7 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
// See the LICENSE file in the project root for more information.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
[assembly: InternalsVisibleTo("Microsoft.Tye.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] |
|||
@ -0,0 +1,43 @@ |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Tye; |
|||
using Test.Infrastructure; |
|||
using Xunit; |
|||
using Xunit.Abstractions; |
|||
|
|||
namespace E2ETest |
|||
{ |
|||
public class ApplicationTests |
|||
{ |
|||
private readonly TestOutputLogEventSink _sink; |
|||
|
|||
public ApplicationTests(ITestOutputHelper output) |
|||
{ |
|||
_sink = new TestOutputLogEventSink(output); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task EnvironmentVariablesOnlySetForDirectDependencies() |
|||
{ |
|||
using var projectDirectory = TestHelpers.CopyTestProjectDirectory(Path.Combine("multirepo")); |
|||
var yamlFile = Path.Combine(projectDirectory.DirectoryPath, "results", "tye.yaml"); |
|||
|
|||
// Debug targets can be null if not specified, so make sure calling host.Start does not throw.
|
|||
var outputContext = new OutputContext(_sink, Verbosity.Debug); |
|||
var application = await ApplicationFactory.CreateAsync(outputContext, new FileInfo(yamlFile)); |
|||
|
|||
var app = application.ToHostingApplication(); |
|||
var dictionary = new Dictionary<string, string>(); |
|||
app.PopulateEnvironment(app.Services["results"], (s1, s2) => dictionary[s1] = s2); |
|||
|
|||
// Just the WORKER is defined.
|
|||
Assert.Equal(8, dictionary.Count); |
|||
|
|||
Assert.Equal("http", dictionary["SERVICE__WORKER__PROTOCOL"]); |
|||
// No POSTGRES or REDIS
|
|||
Assert.False(dictionary.ContainsKey("SERVICE__POSTGRES__PROTOCOL")); |
|||
Assert.False(dictionary.ContainsKey("SERVICE__REDIS__PROTOCOL")); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
kind: Deployment |
|||
apiVersion: apps/v1 |
|||
metadata: |
|||
name: results |
|||
labels: |
|||
app.kubernetes.io/name: 'results' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
matchLabels: |
|||
app.kubernetes.io/name: results |
|||
template: |
|||
metadata: |
|||
labels: |
|||
app.kubernetes.io/name: 'results' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
containers: |
|||
- name: results |
|||
image: results:1.0.0 |
|||
imagePullPolicy: Always |
|||
env: |
|||
- name: ASPNETCORE_URLS |
|||
value: 'http://*' |
|||
- name: PORT |
|||
value: '80' |
|||
- name: SERVICE__WORKER__PROTOCOL |
|||
value: 'http' |
|||
- name: SERVICE__WORKER__PORT |
|||
value: '80' |
|||
- name: SERVICE__WORKER__HOST |
|||
value: 'worker' |
|||
ports: |
|||
- containerPort: 80 |
|||
... |
|||
--- |
|||
kind: Service |
|||
apiVersion: v1 |
|||
metadata: |
|||
name: results |
|||
labels: |
|||
app.kubernetes.io/name: 'results' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
selector: |
|||
app.kubernetes.io/name: results |
|||
type: ClusterIP |
|||
ports: |
|||
- name: http |
|||
protocol: TCP |
|||
port: 80 |
|||
targetPort: 80 |
|||
... |
|||
--- |
|||
kind: Deployment |
|||
apiVersion: apps/v1 |
|||
metadata: |
|||
name: worker |
|||
labels: |
|||
app.kubernetes.io/name: 'worker' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
matchLabels: |
|||
app.kubernetes.io/name: worker |
|||
template: |
|||
metadata: |
|||
labels: |
|||
app.kubernetes.io/name: 'worker' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
containers: |
|||
- name: worker |
|||
image: worker:1.0.0 |
|||
imagePullPolicy: Always |
|||
env: |
|||
- name: ASPNETCORE_URLS |
|||
value: 'http://*' |
|||
- name: PORT |
|||
value: '80' |
|||
- name: CONNECTIONSTRINGS__REDIS |
|||
valueFrom: |
|||
secretKeyRef: |
|||
name: 'binding-production-redis-secret' |
|||
key: 'connectionstring' |
|||
- name: CONNECTIONSTRINGS__POSTGRES |
|||
valueFrom: |
|||
secretKeyRef: |
|||
name: 'binding-production-postgres-secret' |
|||
key: 'connectionstring' |
|||
ports: |
|||
- containerPort: 80 |
|||
... |
|||
--- |
|||
kind: Service |
|||
apiVersion: v1 |
|||
metadata: |
|||
name: worker |
|||
labels: |
|||
app.kubernetes.io/name: 'worker' |
|||
app.kubernetes.io/part-of: 'VotingSample' |
|||
spec: |
|||
selector: |
|||
app.kubernetes.io/name: worker |
|||
type: ClusterIP |
|||
ports: |
|||
- name: http |
|||
protocol: TCP |
|||
port: 80 |
|||
targetPort: 80 |
|||
... |
|||
@ -1,6 +1,6 @@ |
|||
name: VotingSample |
|||
services: |
|||
- name: include |
|||
- name: worker |
|||
include: ../worker/tye.yaml |
|||
- name: results |
|||
project: results.csproj |
|||
|
|||
Loading…
Reference in new issue