Skip to content

Commit c8c8a0b

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

8 files changed

Lines changed: 147 additions & 71 deletions

File tree

‎hack/e2e-apps/clickhouse.bats‎

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

33
@test "Create DB ClickHouse" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
resources=$(cat <<EOF
8+
resources:
9+
resources:
10+
cpu: 500m
11+
memory: 768Mi
12+
EOF
13+
)
14+
else
15+
resources=' resources: {}'
16+
fi
517
kubectl apply -f- <<EOF
618
apiVersion: apps.cozystack.io/v1alpha1
719
kind: ClickHouse
@@ -27,15 +39,13 @@ spec:
2739
s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu
2840
s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog
2941
resticPassword: ChaXoveekoh6eigh4siesheeda2quai0
30-
resources: {}
42+
$resources
3143
resourcesPreset: "nano"
3244
EOF
3345
sleep 5
34-
kubectl -n tenant-test wait hr clickhouse-$name --timeout=20s --for=condition=ready
35-
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"
36-
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1
37-
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints chi-clickhouse-$name-clickhouse-0-0 -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
38-
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"
39-
timeout 80 sh -ec "until kubectl -n tenant-test get sts chi-clickhouse-$name-clickhouse-0-1 ; do sleep 10; done"
40-
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-1 --timeout=140s --for=jsonpath='{.status.replicas}'=1
46+
kubectl -n tenant-test wait --timeout=40s hr clickhouse-$name --for=condition=ready
47+
kubectl -n tenant-test wait --timeout=130s clickhouses $name --for=condition=ready
48+
kubectl -n tenant-test wait --timeout=120s sts chi-clickhouse-$name-clickhouse-0-0 --for=jsonpath='{.status.replicas}'=1
49+
timeout 210 sh -ec "until kubectl -n tenant-test wait svc chendpoint-clickhouse-$name --for=jsonpath='{.spec.ports[0].port}'=8123; do sleep 10; done"
50+
kubectl -n tenant-test delete clickhouse.apps.cozystack.io $name
4151
}

‎hack/e2e-apps/kafka.bats‎

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

33
@test "Create Kafka" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
resources=$(cat <<EOF
8+
resources:
9+
resources:
10+
cpu: 500m
11+
memory: 768Mi
12+
EOF
13+
)
14+
else
15+
resources='resources: {}'
16+
fi
517
kubectl apply -f- <<EOF
618
apiVersion: apps.cozystack.io/v1alpha1
719
kind: Kafka
@@ -14,13 +26,13 @@ spec:
1426
size: 10Gi
1527
replicas: 2
1628
storageClass: ""
17-
resources: {}
29+
$resources
1830
resourcesPreset: "nano"
1931
zookeeper:
2032
size: 5Gi
2133
replicas: 2
2234
storageClass: ""
23-
resources:
35+
$resources
2436
resourcesPreset: "nano"
2537
topics:
2638
- name: testResults
@@ -38,14 +50,9 @@ spec:
3850
replicas: 2
3951
EOF
4052
sleep 5
41-
kubectl -n tenant-test wait hr kafka-$name --timeout=30s --for=condition=ready
42-
kubectl wait kafkas -n tenant-test test --timeout=60s --for=condition=ready
43-
timeout 60 sh -ec "until kubectl -n tenant-test get pvc data-kafka-$name-zookeeper-0; do sleep 10; done"
44-
kubectl -n tenant-test wait pvc data-kafka-$name-zookeeper-0 --timeout=50s --for=jsonpath='{.status.phase}'=Bound
45-
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"
46-
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"
47-
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints kafka-$name-zookeeper-nodes -o jsonpath='{.subsets[*].addresses[0].ip}' | grep -q '[0-9]'; do sleep 10; done"
53+
kubectl -n tenant-test wait --timeout=30s hr kafka-$name --for=condition=ready
54+
kubectl -n tenant-test wait --timeout=1m kafkas $name --for=condition=ready
55+
kubectl -n tenant-test wait --timeout=50s pvc data-kafka-$name-zookeeper-0 --for=jsonpath='{.status.phase}'=Bound
56+
kubectl -n tenant-test wait --timeout=40s svc kafka-$name-zookeeper-client --for=jsonpath='{.spec.ports[0].port}'=2181
4857
kubectl -n tenant-test delete kafka.apps.cozystack.io $name
49-
kubectl -n tenant-test delete pvc data-kafka-$name-zookeeper-0
50-
kubectl -n tenant-test delete pvc data-kafka-$name-zookeeper-1
5158
}

‎hack/e2e-apps/kubernetes.bats‎

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

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

‎hack/e2e-apps/mysql.bats‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
@test "Create DB MySQL" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
resources=$(cat <<EOF
8+
resources:
9+
resources:
10+
cpu: 3000m
11+
memory: 3Gi
12+
EOF
13+
)
14+
else
15+
resources=' resources: {}'
16+
fi
517
kubectl apply -f- <<EOF
618
apiVersion: apps.cozystack.io/v1alpha1
719
kind: MySQL
@@ -31,16 +43,15 @@ spec:
3143
s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu
3244
s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog
3345
resticPassword: ChaXoveekoh6eigh4siesheeda2quai0
34-
resources: {}
46+
$resources
3547
resourcesPreset: "nano"
3648
EOF
37-
sleep 5
38-
kubectl -n tenant-test wait hr mysql-$name --timeout=30s --for=condition=ready
39-
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"
40-
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints mysql-$name -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
41-
kubectl -n tenant-test wait statefulset.apps/mysql-$name --timeout=110s --for=jsonpath='{.status.replicas}'=2
42-
timeout 80 sh -ec "until kubectl -n tenant-test get svc mysql-$name-metrics -o jsonpath='{.spec.ports[0].port}' | grep -q '9104'; do sleep 10; done"
43-
timeout 40 sh -ec "until kubectl -n tenant-test get endpoints mysql-$name-metrics -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
44-
kubectl -n tenant-test wait deployment.apps/mysql-$name-metrics --timeout=90s --for=jsonpath='{.status.replicas}'=1
49+
sleep 10
50+
kubectl -n tenant-test wait --timeout=30s hr mysql-$name --for=condition=ready
51+
kubectl -n tenant-test wait --timeout=130s mysqls $name --for=condition=ready
52+
kubectl -n tenant-test wait --timeout=110s sts mysql-$name --for=jsonpath='{.status.replicas}'=2
53+
sleep 60
54+
kubectl -n tenant-test wait --timeout=60s deploy mysql-$name-metrics --for=jsonpath='{.status.replicas}'=1
55+
kubectl -n tenant-test wait --timeout=100s svc mysql-$name --for=jsonpath='{.spec.ports[0].port}'=3306
4556
kubectl -n tenant-test delete mysqls.apps.cozystack.io $name
4657
}

‎hack/e2e-apps/postgres.bats‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
@test "Create DB PostgreSQL" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
resources=$(cat <<EOF
8+
resources:
9+
resources:
10+
cpu: 500m
11+
memory: 768Mi
12+
EOF
13+
)
14+
else
15+
resources=' resources: {}'
16+
fi
517
kubectl apply -f - <<EOF
618
apiVersion: apps.cozystack.io/v1alpha1
719
kind: Postgres
@@ -36,19 +48,14 @@ spec:
3648
s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu
3749
s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog
3850
resticPassword: ChaXoveekoh6eigh4siesheeda2quai0
39-
resources: {}
51+
$resources
4052
resourcesPreset: "nano"
4153
EOF
4254
sleep 5
43-
kubectl -n tenant-test wait hr postgres-$name --timeout=100s --for=condition=ready
44-
kubectl -n tenant-test wait job.batch postgres-$name-init-job --timeout=50s --for=condition=Complete
45-
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"
46-
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"
47-
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"
48-
timeout 120 sh -ec "until kubectl -n tenant-test get endpoints postgres-$name-r -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
49-
# for some reason it takes longer for the read-only endpoint to be ready
50-
#timeout 120 sh -ec "until kubectl -n tenant-test get endpoints postgres-$name-ro -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
51-
timeout 120 sh -ec "until kubectl -n tenant-test get endpoints postgres-$name-rw -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"
55+
kubectl -n tenant-test wait --timeout=200s hr postgres-$name --for=condition=ready
56+
kubectl -n tenant-test wait --timeout=130s postgreses $name --for=condition=ready
57+
kubectl -n tenant-test wait --timeout=50s job.batch postgres-$name-init-job --for=condition=Complete
58+
kubectl -n tenant-test wait --timeout=40s svc postgres-$name-r --for=jsonpath='{.spec.ports[0].port}'=5432
5259
kubectl -n tenant-test delete postgreses.apps.cozystack.io $name
5360
kubectl -n tenant-test delete job.batch/postgres-$name-init-job
5461
}

‎hack/e2e-apps/redis.bats‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
@test "Create Redis" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
resources=$(cat <<EOF
8+
resources:
9+
resources:
10+
cpu: 500m
11+
memory: 768Mi
12+
EOF
13+
)
14+
else
15+
resources='resources: {}'
16+
fi
517
kubectl apply -f- <<EOF
618
apiVersion: apps.cozystack.io/v1alpha1
719
kind: Redis
@@ -14,13 +26,15 @@ spec:
1426
replicas: 2
1527
storageClass: ""
1628
authEnabled: true
17-
resources: {}
29+
$resources
1830
resourcesPreset: "nano"
1931
EOF
2032
sleep 5
21-
kubectl -n tenant-test wait hr redis-$name --timeout=20s --for=condition=ready
22-
kubectl -n tenant-test wait pvc redisfailover-persistent-data-rfr-redis-$name-0 --timeout=50s --for=jsonpath='{.status.phase}'=Bound
23-
kubectl -n tenant-test wait deploy rfs-redis-$name --timeout=90s --for=condition=available
24-
kubectl -n tenant-test wait sts rfr-redis-$name --timeout=90s --for=jsonpath='{.status.replicas}'=2
33+
kubectl -n tenant-test wait --timeout=20s hr redis-$name --for=condition=ready
34+
kubectl -n tenant-test wait --timeout=130s redis.apps.cozystack.io $name --for=condition=ready
35+
kubectl -n tenant-test wait --timeout=50s pvc redisfailover-persistent-data-rfr-redis-$name-0 --for=jsonpath='{.status.phase}'=Bound
36+
kubectl -n tenant-test wait --timeout=90s sts rfr-redis-$name --for=jsonpath='{.status.replicas}'=2
37+
sleep 45
38+
kubectl -n tenant-test wait --timeout=45s deploy rfs-redis-$name --for=condition=available
2539
kubectl -n tenant-test delete redis.apps.cozystack.io $name
2640
}

‎hack/e2e-apps/virtualmachine.bats‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22

33
@test "Create a Virtual Machine" {
44
name='test'
5+
withResources='true'
6+
if [ "$withResources" == 'true' ]; then
7+
cores="1000m"
8+
memory="1Gi
9+
else
10+
cores="2000m"
11+
memory="2Gi
12+
fi
513
kubectl apply -f - <<EOF
614
apiVersion: apps.cozystack.io/v1alpha1
715
kind: VirtualMachine
816
metadata:
917
name: $name
1018
namespace: tenant-test
1119
spec:
20+
domain:
21+
cpu:
22+
cores: "$cores"
23+
resources:
24+
requests:
25+
memory: "$memory"
1226
external: false
1327
externalMethod: PortList
1428
externalPorts:
@@ -20,9 +34,6 @@ spec:
2034
storage: 5Gi
2135
storageClass: replicated
2236
gpus: []
23-
resources:
24-
cpu: ""
25-
memory: ""
2637
sshKeys:
2738
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPht0dPk5qQ+54g1hSX7A6AUxXJW5T6n/3d7Ga2F8gTF
2839
test@test
@@ -37,11 +48,12 @@ spec:
3748
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPht0dPk5qQ+54g1hSX7A6AUxXJW5T6n/3d7Ga2F8gTF test@test
3849
cloudInitSeed: ""
3950
EOF
40-
sleep 5
41-
kubectl -n tenant-test wait hr virtual-machine-$name --timeout=10s --for=condition=ready
42-
kubectl -n tenant-test wait dv virtual-machine-$name --timeout=150s --for=condition=ready
43-
kubectl -n tenant-test wait pvc virtual-machine-$name --timeout=100s --for=jsonpath='{.status.phase}'=Bound
44-
kubectl -n tenant-test wait vm virtual-machine-$name --timeout=100s --for=condition=ready
45-
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"
51+
sleep 10
52+
kubectl -n tenant-test wait --timeout=10s hr virtual-machine-$name --for=condition=ready
53+
kubectl -n tenant-test wait --timeout=130s virtualmachines $name --for=condition=ready
54+
kubectl -n tenant-test wait --timeout=130s pvc virtual-machine-$name --for=jsonpath='{.status.phase}'=Bound
55+
kubectl -n tenant-test wait --timeout=150s dv virtual-machine-$name --for=condition=ready
56+
kubectl -n tenant-test wait --timeout=100s vm virtual-machine-$name --for=condition=ready
57+
kubectl -n tenant-test wait --timeout=150s vmi virtual-machine-$name --for=jsonpath='{status.phase}'=Running
4658
kubectl -n tenant-test delete virtualmachines.apps.cozystack.io $name
4759
}

‎hack/e2e-apps/vminstance.bats‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,37 @@ spec:
1717
storageClass: replicated
1818
EOF
1919
sleep 5
20-
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
20+
kubectl -n tenant-test wait --timeout=5s hr vm-disk-$name --for=condition=ready
21+
kubectl -n tenant-test wait --timeout=130s vmdisks $name --for=condition=ready
22+
kubectl -n tenant-test wait --timeout=130s pvc vm-disk-$name --for=jsonpath='{.status.phase}'=Bound
23+
kubectl -n tenant-test wait --timeout=150s dv vm-disk-$name --for=condition=ready
2324
}
2425

2526
@test "Create a VM Instance" {
2627
diskName='test'
2728
name='test'
28-
kubectl apply -f - <<EOF
29+
withResources='true'
30+
if [ "$withResources" == 'true' ]; then
31+
cores="1000m"
32+
memory="1Gi
33+
else
34+
cores="2000m"
35+
memory="2Gi
36+
fi
37+
kubectl -n tenant-test get vminstances.apps.cozystack.io $name ||
38+
kubectl create -f - <<EOF
2939
apiVersion: apps.cozystack.io/v1alpha1
3040
kind: VMInstance
3141
metadata:
3242
name: $name
3343
namespace: tenant-test
3444
spec:
45+
domain:
46+
cpu:
47+
cores: "$cores"
48+
resources:
49+
requests:
50+
memory: "$memory"
3551
external: false
3652
externalMethod: PortList
3753
externalPorts:
@@ -42,9 +58,6 @@ spec:
4258
disks:
4359
- name: $diskName
4460
gpus: []
45-
resources:
46-
cpu: ""
47-
memory: ""
4861
sshKeys:
4962
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPht0dPk5qQ+54g1hSX7A6AUxXJW5T6n/3d7Ga2F8gTF
5063
test@test
@@ -60,9 +73,10 @@ spec:
6073
cloudInitSeed: ""
6174
EOF
6275
sleep 5
63-
timeout 20 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"
64-
kubectl -n tenant-test wait hr vm-instance-$name --timeout=5s --for=condition=ready
65-
kubectl -n tenant-test wait vm vm-instance-$name --timeout=20s --for=condition=ready
76+
kubectl -n tenant-test wait --timeout=5s hr vm-instance-$name --for=condition=ready
77+
kubectl -n tenant-test wait --timeout=130s vminstances $name --for=condition=ready
78+
kubectl -n tenant-test wait --timeout=20s vm vm-instance-$name --for=condition=ready
79+
kubectl -n tenant-test wait --timeout=40s vmi vm-instance-$name --for=jsonpath='{status.phase}'=Running
6680
kubectl -n tenant-test delete vminstances.apps.cozystack.io $name
6781
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $diskName
6882
}

0 commit comments

Comments
 (0)