Skip to content

Commit ae8c804

Browse files
committed
add resource quota for testing ns
Signed-off-by: IvanHunters <[email protected]>
1 parent c0d5e52 commit ae8c804

4 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎hack/e2e-apps/vminstance.bats‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ spec:
1818
EOF
1919
sleep 5
2020
kubectl -n tenant-test wait hr vm-disk-$name --timeout=5s --for=condition=ready
21-
kubectl -n tenant-test wait dv vm-disk-$name --timeout=150s --for=condition=ready
22-
kubectl -n tenant-test wait pvc vm-disk-$name --timeout=100s --for=jsonpath='{.status.phase}'=Bound
21+
kubectl -n tenant-test wait dv vm-disk-$name --timeout=250s --for=condition=ready
22+
kubectl -n tenant-test wait pvc vm-disk-$name --timeout=200s --for=jsonpath='{.status.phase}'=Bound
2323
}
2424

2525
@test "Create a VM Instance" {

‎hack/e2e-install-cozystack.bats‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ EOF
123123

124124
@test "Configure Tenant and wait for applications" {
125125
# Patch root tenant and wait for its releases
126+
126127
kubectl patch tenants/root -n tenant-root --type merge -p '{"spec":{"host":"example.org","ingress":true,"monitoring":true,"etcd":true,"isolated":true, "seaweedfs": true}}'
127128

128129
timeout 60 sh -ec 'until kubectl get hr -n tenant-root etcd ingress monitoring seaweedfs tenant-root >/dev/null 2>&1; do sleep 1; done'
@@ -188,9 +189,22 @@ spec:
188189
ingress: false
189190
isolated: true
190191
monitoring: false
191-
resourceQuotas: {}
192+
resourceQuotas:
193+
cpu: "60"
194+
memory: "64Gi"
195+
storage: "100Gi"
192196
seaweedfs: false
193197
EOF
194198
kubectl wait hr/tenant-test -n tenant-root --timeout=1m --for=condition=ready
195199
kubectl wait namespace tenant-test --timeout=20s --for=jsonpath='{.status.phase}'=Active
200+
# Wait for ResourceQuota to appear and assert values
201+
timeout 60 sh -ec 'until [ "$(kubectl get quota -n tenant-test --no-headers 2>/dev/null | wc -l)" -ge 1 ]; do sleep 1; done'
202+
kubectl get quota -n tenant-test \
203+
-o jsonpath='{range .items[*]}{.spec.hard.requests\.memory}{" "}{.spec.hard.requests\.storage}{"\n"}{end}' \
204+
| grep -qx '68719476736 100Gi'
205+
206+
# Assert LimitRange defaults for containers
207+
kubectl get limitrange -n tenant-test \
208+
-o jsonpath='{range .items[*].spec.limits[*]}{.default.cpu}{" "}{.default.memory}{" "}{.defaultRequest.cpu}{" "}{.defaultRequest.memory}{"\n"}{end}' \
209+
| grep -qx '250m 1Gi 100m 128Mi'
196210
}

‎packages/apps/tenant/templates/quota.yaml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,20 @@ metadata:
77
spec:
88
hard:
99
{{- include "cozy-lib.resources.flatten" (list .Values.resourceQuotas $) | nindent 6 }}
10+
---
11+
apiVersion: v1
12+
kind: LimitRange
13+
metadata:
14+
name: tenant-range-limits
15+
namespace: {{ include "tenant.name" . }}
16+
spec:
17+
limits:
18+
- default:
19+
cpu: "250m"
20+
memory: "1Gi"
21+
defaultRequest:
22+
cpu: "100m"
23+
memory: "128Mi"
24+
ephemeral-storage: "128Mi"
25+
type: Container
1026
{{- end }}

‎packages/library/cozy-lib/templates/_resources.tpl‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@
108108
{{- $vEphemeralStorageRequestF64 := (include "cozy-lib.resources.toFloat" $v) | float64 }}
109109
{{- $ephemeralStorageRequestF64 := divf $vEphemeralStorageRequestF64 $ephemeralStorageAllocationRatio }}
110110
{{- $_ := set $output.requests $k ($ephemeralStorageRequestF64 | int | toString) }}
111-
{{- $_ := set $output.limits $k ($v | toString) }}
112111
{{- else }}
113112
{{- $_ := set $output.requests $k $v }}
114-
{{- $_ := set $output.limits $k $v }}
115113
{{- end }}
116114
{{- end }}
117115
{{- $output | toYaml }}
@@ -182,5 +180,5 @@
182180
{{- $_ := set $out $key $v }}
183181
{{- end }}
184182
{{- end }}
185-
{{- dict "resourceQuotas" $out | toYaml }}
183+
{{- $out | toYaml }}
186184
{{- end }}

0 commit comments

Comments
 (0)