Skip to content

Commit f71f391

Browse files
committed
test: add tests for service account name
Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
1 parent da1cadf commit f71f391

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

pkg/cmd/scaffold_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ func TestScaffoldOutput(t *testing.T) {
5555
},
5656
expected: "multiple_image_secrets.yml",
5757
},
58+
{
59+
name: "service account name is provided",
60+
opts: ScaffoldOptions{
61+
from: "ghcr.io/foo/example-app:v0.1.0",
62+
replicas: 2,
63+
executor: "containerd-shim-spin",
64+
serviceAccountName: "my-service-account",
65+
},
66+
expected: "service_account_name.yml",
67+
},
68+
{
69+
name: "service account with HPA autoscaler",
70+
opts: ScaffoldOptions{
71+
from: "ghcr.io/foo/example-app:v0.1.0",
72+
executor: "containerd-shim-spin",
73+
autoscaler: "hpa",
74+
cpuLimit: "100m",
75+
memoryLimit: "128Mi",
76+
replicas: 2,
77+
maxReplicas: 3,
78+
targetCPUUtilizationPercentage: 60,
79+
targetMemoryUtilizationPercentage: 60,
80+
serviceAccountName: "my-service-account",
81+
},
82+
expected: "hpa_service_account.yml",
83+
},
5884
{
5985
name: "HPA autoscaler support",
6086
opts: ScaffoldOptions{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: core.spinkube.dev/v1alpha1
2+
kind: SpinApp
3+
metadata:
4+
name: example-app
5+
spec:
6+
image: "ghcr.io/foo/example-app:v0.1.0"
7+
executor: containerd-shim-spin
8+
enableAutoscaling: true
9+
serviceAccountName: my-service-account
10+
resources:
11+
limits:
12+
cpu: 100m
13+
memory: 128Mi
14+
---
15+
apiVersion: autoscaling/v2
16+
kind: HorizontalPodAutoscaler
17+
metadata:
18+
name: example-app-autoscaler
19+
spec:
20+
scaleTargetRef:
21+
apiVersion: apps/v1
22+
kind: Deployment
23+
name: example-app
24+
minReplicas: 2
25+
maxReplicas: 3
26+
metrics:
27+
- type: Resource
28+
resource:
29+
name: cpu
30+
target:
31+
type: Utilization
32+
averageUtilization: 60
33+
- type: Resource
34+
resource:
35+
name: memory
36+
target:
37+
type: Utilization
38+
averageUtilization: 60
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: core.spinkube.dev/v1alpha1
2+
kind: SpinApp
3+
metadata:
4+
name: example-app
5+
spec:
6+
image: "ghcr.io/foo/example-app:v0.1.0"
7+
executor: containerd-shim-spin
8+
replicas: 2
9+
serviceAccountName: my-service-account

0 commit comments

Comments
 (0)