Skip to content

Commit

Permalink
Prepare sample funnel target service scaling test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragemil committed Oct 26, 2023
1 parent 76f5bea commit 75547e7
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# JetBrains Rider
**/.idea/

**/out/
1 change: 1 addition & 0 deletions publisher/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Update="LeanCode.IntegrationTestHelpers" Version="$(CoreLibVersion)" />
<PackageReference Update="LeanCode.Logging" Version="$(CoreLibVersion)" />

<PackageReference Update="MassTransit.RabbitMQ" Version="8.1.1" />
<PackageReference Update="MassTransit.SignalR" Version="8.1.1" />

<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0-rc.1.23421.29" />
Expand Down
24 changes: 24 additions & 0 deletions publisher/LeanCode.Pipe.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.Pipe.TestClient.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.Pipe.IntegrationTests", "test\LeanCode.Pipe.IntegrationTests\LeanCode.Pipe.IntegrationTests.csproj", "{05F2BDCE-B093-4D4A-BC36-B7F6F12103AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.Pipe.Funnel.TestApp1", "test\LeanCode.Pipe.Funnel.TestApp1\LeanCode.Pipe.Funnel.TestApp1.csproj", "{A95EBB5F-D7CD-48D4-9624-F43A486D0D68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.Pipe.Funnel.TestAppFunnel", "test\LeanCode.Pipe.Funnel.TestAppFunnel\LeanCode.Pipe.Funnel.TestAppFunnel.csproj", "{6D361069-9CD4-44DA-914A-80A62458B04F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "funnel_scaling", "funnel_scaling", "{2A218F39-75C1-4EE1-8614-D67AB30574F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.Pipe.Funnel.ScaledServiceTests", "test\LeanCode.Pipe.Funnel.ScaledServiceTests\LeanCode.Pipe.Funnel.ScaledServiceTests.csproj", "{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -52,6 +60,18 @@ Global
{05F2BDCE-B093-4D4A-BC36-B7F6F12103AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05F2BDCE-B093-4D4A-BC36-B7F6F12103AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05F2BDCE-B093-4D4A-BC36-B7F6F12103AC}.Release|Any CPU.Build.0 = Release|Any CPU
{A95EBB5F-D7CD-48D4-9624-F43A486D0D68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A95EBB5F-D7CD-48D4-9624-F43A486D0D68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A95EBB5F-D7CD-48D4-9624-F43A486D0D68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A95EBB5F-D7CD-48D4-9624-F43A486D0D68}.Release|Any CPU.Build.0 = Release|Any CPU
{6D361069-9CD4-44DA-914A-80A62458B04F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D361069-9CD4-44DA-914A-80A62458B04F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D361069-9CD4-44DA-914A-80A62458B04F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D361069-9CD4-44DA-914A-80A62458B04F}.Release|Any CPU.Build.0 = Release|Any CPU
{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{75B2B837-B392-4DC1-8CF7-C1B2C4E03312} = {401E8BD4-C7D7-48F2-8899-EA9859247BD7}
Expand All @@ -60,5 +80,9 @@ Global
{F1830D31-AA1D-409B-B78E-FC2BB88B7DF8} = {401E8BD4-C7D7-48F2-8899-EA9859247BD7}
{38F1AA50-B16E-47A7-925A-AB574E9120FF} = {CBE053F8-6853-4FFC-A931-84A210C5FF2C}
{05F2BDCE-B093-4D4A-BC36-B7F6F12103AC} = {CBE053F8-6853-4FFC-A931-84A210C5FF2C}
{2A218F39-75C1-4EE1-8614-D67AB30574F0} = {CBE053F8-6853-4FFC-A931-84A210C5FF2C}
{A95EBB5F-D7CD-48D4-9624-F43A486D0D68} = {2A218F39-75C1-4EE1-8614-D67AB30574F0}
{6D361069-9CD4-44DA-914A-80A62458B04F} = {2A218F39-75C1-4EE1-8614-D67AB30574F0}
{531D5FD5-9C72-4F24-B9E7-E53CFBF20B57} = {2A218F39-75C1-4EE1-8614-D67AB30574F0}
EndGlobalSection
EndGlobal
61 changes: 61 additions & 0 deletions publisher/funnel_cluster_tests_env/Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
load('ext://helm_resource', 'helm_resource', 'helm_repo')

allow_k8s_contexts('k3d-testapp')
default_registry('k3d-testapp-registry.local.lncd.pl:21345')

helm_repo('bitnami', 'https://charts.bitnami.com/bitnami')
helm_resource('rabbit', 'bitnami/rabbitmq', flags=['--set=auth.password=user'])

local_resource(
'build-testappfunnel',
'dotnet publish -o out/testapp_funnel ../test/LeanCode.Pipe.Funnel.TestAppFunnel',
deps=['../src', '../test/LeanCode.Pipe.Funnel.TestAppFunnel'],
ignore=['../**/obj', '../**/bin'],
)

local_resource(
'build-testapp1',
'dotnet publish -o out/testapp1 ../test/LeanCode.Pipe.Funnel.TestApp1',
deps=['src', '../test/LeanCode.Pipe.Funnel.TestApp1'],
ignore=['../**/obj', '../**/bin'],
)

local_resource(
'build-scaled-service-tests',
'dotnet publish -o out/scaled_service_tests ../test/LeanCode.Pipe.Funnel.ScaledServiceTests',
deps=[
'../src',
'../test/LeanCode.Pipe.Funnel.TestAppFunnel',
'../test/LeanCode.Pipe.Funnel.TestApp1',
'../test/LeanCode.Pipe.Funnel.ScaledServiceTests' ],
ignore=['../**/obj', '../**/bin'],
)

docker_build(
'testapp_funnel',
'.',
dockerfile='testapp_funnel.dockerfile',
only = ['out/testapp_funnel'],
)

docker_build(
'testapp1',
'.',
dockerfile='testapp1.dockerfile',
only = ['out/testapp1'],
)

docker_build(
'scaled_service_tests',
'.',
dockerfile='scaled_service_tests.dockerfile',
only = ['out/scaled_service_tests'],
)

k8s_yaml('k8s/testapp_funnel.yaml')
k8s_yaml('k8s/testapp1.yaml')
k8s_yaml('k8s/scaled_service_tests.yaml')

k8s_resource('testapp-funnel', resource_deps=['rabbit'])
k8s_resource('testapp1', resource_deps=['rabbit'])
k8s_resource('scaled-service-tests', resource_deps=['testapp-funnel', 'testapp1'])
43 changes: 43 additions & 0 deletions publisher/funnel_cluster_tests_env/k8s/k3d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: k3d.io/v1alpha5
kind: Simple
metadata:
name: testapp
image: docker.io/rancher/k3s:v1.28.2-k3s1
servers: 1
agents: 0
kubeAPI:
host: "testapp-cluster.local.lncd.pl"
hostIP: "127.0.0.1"
hostPort: "6445"
ports:
- port: 80:80
nodeFilters:
- loadbalancer
- port: 443:443
nodeFilters:
- loadbalancer
- port: 1433:1433
nodeFilters:
- loadbalancer
- port: 5432:5432
nodeFilters:
- loadbalancer
- port: 10000:10000
nodeFilters:
- loadbalancer
registries:
create:
name: k3d-testapp-registry.local.lncd.pl
host: "0.0.0.0"
hostPort: "21345"
options:
k3d:
wait: true
k3s:
extraArgs:
- arg: --disable=traefik,metrics-server
nodeFilters:
- server:*
kubeconfig:
updateDefaultKubeconfig: true
switchCurrentContext: true
15 changes: 15 additions & 0 deletions publisher/funnel_cluster_tests_env/k8s/scaled_service_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: batch/v1
kind: Job
metadata:
name: scaled-service-tests
labels:
app: scaled-service-tests
spec:
template:
spec:
restartPolicy: Never
containers:
- name: scaled-service-tests
image: scaled_service_tests
ports:
- containerPort: 22
100 changes: 100 additions & 0 deletions publisher/funnel_cluster_tests_env/k8s/testapp1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: v1
kind: Service
metadata:
name: testapp1-svc
labels:
app: testapp1
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
clusterIP: None
selector:
app: testapp1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: testapp1
labels:
app: testapp1
spec:
selector:
matchLabels:
app: testapp1
serviceName: testapp1-svc
replicas: 2
template:
metadata:
labels:
app: testapp1
spec:
containers:
- name: testapp1
image: testapp1
ports:
- containerPort: 8080
- containerPort: 22
livenessProbe:
httpGet:
path: /health/live
port: 8080
readinessProbe:
httpGet:
path: /health/ready
port: 8080
#---
#apiVersion: v1
#kind: Service
#metadata:
# name: testapp1-0
# labels:
# app: testapp1
#spec:
# type: ClusterIP
# ports:
# - port: 80
# targetPort: 8080
# protocol: TCP
# selector:
# app: testapp1-0
#---
#apiVersion: v1
#kind: Service
#metadata:
# name: testapp1-1
# labels:
# app: testapp1
#spec:
# type: ClusterIP
# ports:
# - port: 80
# targetPort: 8080
# protocol: TCP
# selector:
# app: testapp1-1
#---
#apiVersion: networking.k8s.io/v1
#kind: Ingress
#metadata:
# name: testapp1-ingress
#spec:
# rules:
# - host: testapp1.local.lncd.pl
# http:
# paths:
# - path: /0
# backend:
# service:
# name: testapp1-0
# port:
# number: 80
# pathType: ImplementationSpecific
# - path: /1
# backend:
# service:
# name: testapp1-1
# port:
# number: 80
# pathType: ImplementationSpecific
100 changes: 100 additions & 0 deletions publisher/funnel_cluster_tests_env/k8s/testapp_funnel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: v1
kind: Service
metadata:
name: testapp-funnel-svc
labels:
app: testapp-funnel
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
clusterIP: None
selector:
app: testapp-funnel
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: testapp-funnel
labels:
app: testapp-funnel
spec:
selector:
matchLabels:
app: testapp-funnel
serviceName: testapp-funnel-svc
replicas: 2
template:
metadata:
labels:
app: testapp-funnel
spec:
containers:
- name: leanpipe-funnel
image: testapp_funnel
ports:
- containerPort: 8080
- containerPort: 22
livenessProbe:
httpGet:
path: /health/live
port: 8080
readinessProbe:
httpGet:
path: /health/ready
port: 8080
#---
#apiVersion: v1
#kind: Service
#metadata:
# name: testapp-funnel-0
# labels:
# app: testapp-funnel
#spec:
# type: ClusterIP
# ports:
# - port: 80
# targetPort: 8080
# protocol: TCP
# selector:
# app: testapp-funnel-0
#---
#apiVersion: v1
#kind: Service
#metadata:
# name: testapp-funnel-1
# labels:
# app: testapp-funnel
#spec:
# type: ClusterIP
# ports:
# - port: 80
# targetPort: 8080
# protocol: TCP
# selector:
# app: testapp-funnel-1
#---
#apiVersion: networking.k8s.io/v1
#kind: Ingress
#metadata:
# name: testapp-funnel-ingress
#spec:
# rules:
# - host: testappfunnel.local.lncd.pl
# http:
# paths:
# - path: /0
# backend:
# service:
# name: testapp-funnel-0
# port:
# number: 80
# pathType: ImplementationSpecific
# - path: /1
# backend:
# service:
# name: testapp-funnel-1
# port:
# number: 80
# pathType: ImplementationSpecific
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0

USER $APP_UID

WORKDIR /LeanCode.Pipe.Funnel.ScaledServiceTests
COPY --chown=$APP_UID out/scaled_service_tests /home/app/bin
ENTRYPOINT ["dotnet", "test", "/home/app/bin/ScaledServiceTests.dll"]
9 changes: 9 additions & 0 deletions publisher/funnel_cluster_tests_env/testapp1.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0

USER $APP_UID

ENV ASPNETCORE_ENVIRONMENT=Development

WORKDIR /LeanCode.Pipe.Funnel.TestApp1
COPY --chown=$APP_UID out/testapp1 /home/app/bin
ENTRYPOINT ["dotnet", "/home/app/bin/TestApp1.dll"]
Loading

0 comments on commit 75547e7

Please sign in to comment.