Skip to content

Commit 272093c

Browse files
[tests] Run tests w/ requests and limits
Signed-off-by: Ahmad Murzahmatov <[email protected]>
1 parent cdc69f9 commit 272093c

8 files changed

Lines changed: 71 additions & 69 deletions

File tree

‎hack/e2e-apps/clickhouse.bats‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ spec:
4747
resourcesPreset: "nano"
4848
EOF
4949
sleep 5
50-
kubectl -n tenant-test wait hr clickhouse-$name --timeout=40s --for=condition=ready
51-
timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123 9000'; do sleep 10; done"
52-
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1
53-
timeout 100 sh -ec "until kubectl -n tenant-test get svc chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.spec.ports[*].port}' | grep -q '9000 8123 9009'; do sleep 10; done"
54-
timeout 80 sh -ec "until kubectl -n tenant-test get sts chi-clickhouse-$name-clickhouse-0-1 ; do sleep 10; done"
55-
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=1
50+
kubectl -n tenant-test wait --timeout=40s hr clickhouse-$name --for=condition=ready
51+
kubectl -n tenant-test wait --timeout=130s clickhouses $name --for=condition=ready
52+
kubectl -n tenant-test wait --timeout=120s sts chi-clickhouse-$name-clickhouse-0-0 --for=jsonpath='{.status.replicas}'=1
53+
timeout 210 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name --for=jsonpath='{.spec.ports[0].port}'=8123; do sleep 10; done"
5654
kubectl -n tenant-test delete clickhouse.apps.cozystack.io $name
5755
}

‎hack/e2e-apps/kafka.bats‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ spec:
5454
replicas: 2
5555
EOF
5656
sleep 5
57-
kubectl -n tenant-test wait hr kafka-$name --timeout=30s --for=condition=ready
58-
kubectl wait kafkas -n tenant-test $name --timeout=60s --for=condition=ready
59-
timeout 60 sh -ec "until kubectl -n tenant-test get pvc data-kafka-$name-zookeeper-0; do sleep 10; done"
60-
kubectl -n tenant-test wait pvc data-kafka-$name-zookeeper-0 --timeout=50s --for=jsonpath='{.status.phase}'=Bound
61-
timeout 40 sh -ec "until kubectl -n tenant-test get svc kafka-$name-zookeeper-client -o jsonpath='{.spec.ports[0].port}' | grep -q '2181'; do sleep 10; done"
62-
timeout 40 sh -ec "until kubectl -n tenant-test get svc kafka-$name-zookeeper-nodes -o jsonpath='{.spec.ports[*].port}' | grep -q '2181 2888 3888'; do sleep 10; done"
57+
kubectl -n tenant-test wait --timeout=30s hr kafka-$name --for=condition=ready
58+
kubectl -n tenant-test wait --timeout=1m kafkas $name --for=condition=ready
59+
kubectl -n tenant-test wait --timeout=50s pvc data-kafka-$name-zookeeper-0 --for=jsonpath='{.status.phase}'=Bound
60+
kubectl -n tenant-test wait --timeout=40s svc kafka-$name-zookeeper-client --for=jsonpath='{.spec.ports[0].port}'=2181
6361
kubectl -n tenant-test delete kafka.apps.cozystack.io $name
6462
}

‎hack/e2e-apps/kubernetes.bats‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env bats
22

33
@test "Create a tenant Kubernetes control plane" {
4-
kubectl -n tenant-test get kuberneteses.apps.cozystack.io test ||
4+
name='test'
5+
kubectl -n tenant-test get kuberneteses.apps.cozystack.io $name ||
56
kubectl create -f - <<EOF
67
apiVersion: apps.cozystack.io/v1alpha1
78
kind: Kubernetes
89
metadata:
9-
name: test
10+
name: $name
1011
namespace: tenant-test
1112
spec:
1213
addons:
@@ -62,12 +63,12 @@ spec:
6263
- ingress-nginx
6364
storageClass: replicated
6465
EOF
65-
kubectl wait namespace tenant-test --timeout=20s --for=jsonpath='{.status.phase}'=Active
66-
timeout 10 sh -ec 'until kubectl get kamajicontrolplane -n tenant-test kubernetes-test; do sleep 1; done'
67-
kubectl wait --for=condition=TenantControlPlaneCreated kamajicontrolplane -n tenant-test kubernetes-test --timeout=4m
68-
kubectl wait tcp -n tenant-test kubernetes-test --timeout=210s --for=jsonpath='{.status.kubernetesResources.version.status}'=Ready
69-
kubectl wait deploy --timeout=4m --for=condition=available -n tenant-test kubernetes-test kubernetes-test-cluster-autoscaler kubernetes-test-kccm kubernetes-test-kcsi-controller
70-
kubectl wait machinedeployment kubernetes-test-md0 -n tenant-test --timeout=1m --for=jsonpath='{.status.replicas}'=2
71-
kubectl wait machinedeployment kubernetes-test-md0 -n tenant-test --timeout=10m --for=jsonpath='{.status.v1beta2.readyReplicas}'=2
72-
kubectl -n tenant-test delete kuberneteses.apps.cozystack.io test
66+
kubectl -n tenant-test wait --timeout=20s --for=jsonpath='{.status.phase}'=Active
67+
kubectl -n tenant-test wait --timeout=10s kamajicontrolplane kubernetes-$name --for=condition=Ready
68+
kubectl -n tenant-test wait --timeout=4m --for=condition=TenantControlPlaneCreated kamajicontrolplane kubernetes-$name
69+
kubectl -n tenant-test wait --timeout=210s tcp kubernetes-$name --for=jsonpath='{.status.kubernetesResources.version.status}'=Ready
70+
kubectl -n tenant-test wait --timeout=4m deploy --for=condition=available kubernetes-$name kubernetes-$name-cluster-autoscaler kubernetes-$name-kccm kubernetes-$name-kcsi-controller
71+
kubectl -n tenant-test wait --timeout=1m machinedeployment kubernetes-$name-md0 --for=jsonpath='{.status.replicas}'=2
72+
kubectl -n tenant-test wait --timeout=10m machinedeployment kubernetes-$name-md0 --for=jsonpath='{.status.v1beta2.readyReplicas}'=2
73+
kubectl -n tenant-test delete kuberneteses.apps.cozystack.io $name
7374
}

‎hack/e2e-apps/mysql.bats‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ spec:
5151
resourcesPreset: "nano"
5252
EOF
5353
sleep 10
54-
kubectl -n tenant-test wait hr mysql-$name --timeout=30s --for=condition=ready
55-
timeout 80 sh -ec "until kubectl -n tenant-test get svc mysql-$name -o jsonpath='{.spec.ports[0].port}' | grep -q '3306'; do sleep 10; done"
56-
kubectl -n tenant-test wait statefulset.apps/mysql-$name --timeout=110s --for=jsonpath='{.status.replicas}'=2
57-
timeout 80 sh -ec "until kubectl -n tenant-test get svc mysql-$name -o jsonpath='{.spec.ports[0].port}' | grep -q '3306'; do sleep 10; done"
58-
kubectl -n tenant-test wait deployment.apps/mysql-$name-metrics --timeout=300s --for=jsonpath='{.status.replicas}'=1
54+
kubectl -n tenant-test wait --timeout=30s hr mysql-$name --for=condition=ready
55+
kubectl -n tenant-test wait --timeout=130s mysqls $name --for=condition=ready
56+
kubectl -n tenant-test wait --timeout=110s sts mysql-$name --for=jsonpath='{.status.replicas}'=2
57+
sleep 60
58+
kubectl -n tenant-test wait --timeout=60s deploy mysql-$name-metrics --for=jsonpath='{.status.replicas}'=1
59+
kubectl -n tenant-test wait --timeout=100s svc mysql-$name --for=jsonpath='{.spec.ports[0].port}'=3306
5960
kubectl -n tenant-test delete mysqls.apps.cozystack.io $name
6061
}

‎hack/e2e-apps/postgres.bats‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ spec:
5656
resourcesPreset: "nano"
5757
EOF
5858
sleep 5
59-
kubectl -n tenant-test wait hr postgres-$name --timeout=150s --for=condition=ready
60-
kubectl -n tenant-test wait job.batch postgres-$name-init-job --timeout=50s --for=condition=Complete
61-
timeout 40 sh -ec "until kubectl -n tenant-test get svc postgres-$name-r -o jsonpath='{.spec.ports[0].port}' | grep -q '5432'; do sleep 10; done"
62-
timeout 40 sh -ec "until kubectl -n tenant-test get svc postgres-$name-ro -o jsonpath='{.spec.ports[0].port}' | grep -q '5432'; do sleep 10; done"
63-
timeout 40 sh -ec "until kubectl -n tenant-test get svc postgres-$name-rw -o jsonpath='{.spec.ports[0].port}' | grep -q '5432'; do sleep 10; done"
59+
kubectl -n tenant-test wait --timeout=200s hr postgres-$name --for=condition=ready
60+
kubectl -n tenant-test wait --timeout=130s postgreses $name --for=condition=ready
61+
kubectl -n tenant-test wait --timeout=50s job.batch postgres-$name-init-job --for=condition=Complete
62+
kubectl -n tenant-test wait --timeout=40s svc postgres-$name-r --for=jsonpath='{.spec.ports[0].port}'=5432
6463
kubectl -n tenant-test delete postgreses.apps.cozystack.io $name
6564
kubectl -n tenant-test delete job.batch/postgres-$name-init-job
6665
}

‎hack/e2e-apps/redis.bats‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ spec:
3434
resourcesPreset: "nano"
3535
EOF
3636
sleep 5
37-
kubectl -n tenant-test wait hr redis-$name --timeout=20s --for=condition=ready
38-
kubectl -n tenant-test wait pvc redisfailover-persistent-data-rfr-redis-$name-0 --timeout=50s --for=jsonpath='{.status.phase}'=Bound
39-
kubectl -n tenant-test wait deploy rfs-redis-$name --timeout=90s --for=condition=available
40-
kubectl -n tenant-test wait sts rfr-redis-$name --timeout=90s --for=jsonpath='{.status.replicas}'=2
37+
kubectl -n tenant-test wait --timeout=20s hr redis-$name --for=condition=ready
38+
kubectl -n tenant-test wait --timeout=130s redis.apps.cozystack.io $name --for=condition=ready
39+
kubectl -n tenant-test wait --timeout=50s pvc redisfailover-persistent-data-rfr-redis-$name-0 --for=jsonpath='{.status.phase}'=Bound
40+
kubectl -n tenant-test wait --timeout=90s sts rfr-redis-$name --for=jsonpath='{.status.replicas}'=2
41+
sleep 45
42+
kubectl -n tenant-test wait --timeout=45s deploy rfs-redis-$name --for=condition=available
4143
kubectl -n tenant-test delete redis.apps.cozystack.io $name
4244
}

‎hack/e2e-apps/virtualmachine.bats‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
if [ "$withResources" == 'true' ]; then
77
resources=$(cat <<EOF
88
resources:
9+
requests:
10+
cpu: 500m
11+
memory: 768Mi
912
limits:
10-
requests:
11-
cpu: 500m
12-
memory: 768Mi
13-
limits:
14-
cpu: "1000m"
15-
memory: "1Gi"
13+
cpu: "1000m"
14+
memory: "1Gi"
1615
EOF
1716
)
1817
else
@@ -45,6 +44,7 @@ spec:
4544
#cloud-config
4645
users:
4746
- name: test
47+
plain_text_passwd: 'test'
4848
shell: /bin/bash
4949
sudo: ['ALL=(ALL) NOPASSWD: ALL']
5050
groups: sudo
@@ -53,10 +53,11 @@ spec:
5353
cloudInitSeed: ""
5454
EOF
5555
sleep 5
56-
kubectl -n tenant-test wait hr virtual-machine-$name --timeout=10s --for=condition=ready
57-
kubectl -n tenant-test wait dv virtual-machine-$name --timeout=150s --for=condition=ready
58-
kubectl -n tenant-test wait pvc virtual-machine-$name --timeout=100s --for=jsonpath='{.status.phase}'=Bound
59-
kubectl -n tenant-test wait vm virtual-machine-$name --timeout=100s --for=condition=ready
60-
timeout 120 sh -ec "until kubectl -n tenant-test get vmi virtual-machine-$name -o jsonpath='{.status.interfaces[0].ipAddress}' | grep -q '[0-9]'; do sleep 10; done"
56+
kubectl -n tenant-test wait --timeout=10s hr virtual-machine-$name --for=condition=ready
57+
kubectl -n tenant-test wait --timeout=130s virtualmachines $name --for=condition=ready
58+
kubectl -n tenant-test wait --timeout=130s pvc virtual-machine-$name --for=jsonpath='{.status.phase}'=Bound
59+
kubectl -n tenant-test wait --timeout=150s dv virtual-machine-$name --for=condition=ready
60+
kubectl -n tenant-test wait --timeout=100s vm virtual-machine-$name --for=condition=ready
61+
kubectl -n tenant-test wait --timeout=150s vmi virtual-machine-$name --for=jsonpath='{status.phase}'=Running
6162
kubectl -n tenant-test delete virtualmachines.apps.cozystack.io $name
6263
}

‎hack/e2e-apps/vminstance.bats‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22

33
@test "Create a VM Disk" {
44
name='test'
5-
withResources=''
6-
if [ "$withResources" == 'true' ]; then
7-
resources=$(cat <<EOF
8-
resources:
9-
requests:
10-
cpu: 500m
11-
memory: 768Mi
12-
limits:
13-
cpu: "1000m"
14-
memory: "1Gi"
15-
EOF
16-
)
17-
else
18-
resources='resources: {}'
19-
fi
205
kubectl -n tenant-test get vmdisks.apps.cozystack.io $name ||
216
kubectl create -f - <<EOF
227
apiVersion: apps.cozystack.io/v1alpha1
@@ -33,14 +18,30 @@ spec:
3318
storageClass: replicated
3419
EOF
3520
sleep 5
36-
kubectl -n tenant-test wait hr vm-disk-$name --timeout=5s --for=condition=ready
37-
kubectl -n tenant-test wait dv vm-disk-$name --timeout=150s --for=condition=ready
38-
kubectl -n tenant-test wait pvc vm-disk-$name --timeout=100s --for=jsonpath='{.status.phase}'=Bound
21+
kubectl -n tenant-test wait --timeout=5s hr vm-disk-$name --for=condition=ready
22+
kubectl -n tenant-test wait --timeout=130s vmdisks $name --for=condition=ready
23+
kubectl -n tenant-test wait --timeout=130s pvc vm-disk-$name --for=jsonpath='{.status.phase}'=Bound
24+
kubectl -n tenant-test wait --timeout=150s dv vm-disk-$name --for=condition=ready
3925
}
4026

4127
@test "Create a VM Instance" {
4228
diskName='test'
4329
name='test'
30+
withResources='true'
31+
if [ "$withResources" == 'true' ]; then
32+
resources=$(cat <<EOF
33+
resources:
34+
requests:
35+
cpu: 500m
36+
memory: 768Mi
37+
limits:
38+
cpu: "1000m"
39+
memory: "1Gi"
40+
EOF
41+
)
42+
else
43+
resources='resources: {}'
44+
fi
4445
kubectl -n tenant-test get vminstances.apps.cozystack.io $name ||
4546
kubectl create -f - <<EOF
4647
apiVersion: apps.cozystack.io/v1alpha1
@@ -59,7 +60,7 @@ spec:
5960
disks:
6061
- name: $diskName
6162
gpus: []
62-
resources:
63+
$resources
6364
cpu: ""
6465
memory: ""
6566
sshKeys:
@@ -77,9 +78,10 @@ spec:
7778
cloudInitSeed: ""
7879
EOF
7980
sleep 5
80-
timeout 40 sh -ec "until kubectl -n tenant-test get vmi vm-instance-$name -o jsonpath='{.status.interfaces[0].ipAddress}' | grep -q '[0-9]'; do sleep 5; done"
81-
kubectl -n tenant-test wait hr vm-instance-$name --timeout=5s --for=condition=ready
82-
kubectl -n tenant-test wait vm vm-instance-$name --timeout=20s --for=condition=ready
81+
kubectl -n tenant-test wait --timeout=5s hr vm-instance-$name --for=condition=ready
82+
kubectl -n tenant-test wait --timeout=130s vminstances $name --for=condition=ready
83+
kubectl -n tenant-test wait --timeout=20s vm vm-instance-$name --for=condition=ready
84+
kubectl -n tenant-test wait --timeout=40s vmi vm-instance-$name --for=jsonpath='{status.phase}'=Running
8385
kubectl -n tenant-test delete vminstances.apps.cozystack.io $name
8486
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $diskName
8587
}

0 commit comments

Comments
 (0)