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 -n tenant-test get postgreses.apps.cozystack.io $name ||
618 kubectl create -f - << EOF
719apiVersion: apps.cozystack.io/v1alpha1
@@ -37,19 +49,14 @@ spec:
3749 s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu
3850 s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog
3951 resticPassword: ChaXoveekoh6eigh4siesheeda2quai0
40- resources: {}
52+ $ resources
4153 resourcesPreset: "nano"
4254EOF
4355 sleep 5
44- kubectl -n tenant-test wait hr postgres-$name --timeout=100s --for=condition=ready
45- kubectl -n tenant-test wait job.batch postgres-$name -init-job --timeout=50s --for=condition=Complete
46- 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"
47- 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"
48- 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"
49- 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"
50- # for some reason it takes longer for the read-only endpoint to be ready
51- # 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"
52- 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"
56+ kubectl -n tenant-test wait --timeout=200s hr postgres-$name --for=condition=ready
57+ kubectl -n tenant-test wait --timeout=130s postgreses $name --for=condition=ready
58+ kubectl -n tenant-test wait --timeout=50s job.batch postgres-$name -init-job --for=condition=Complete
59+ kubectl -n tenant-test wait --timeout=40s svc postgres-$name -r --for=jsonpath=' {.spec.ports[0].port}' =5432
5360 kubectl -n tenant-test delete postgreses.apps.cozystack.io $name
5461 kubectl -n tenant-test delete job.batch/postgres-$name -init-job
55- }
62+ }
0 commit comments