|
2 | 2 |
|
3 | 3 | @test "Create DB PostgreSQL" { |
4 | 4 | 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 |
5 | 17 | kubectl apply -f - <<EOF |
6 | 18 | apiVersion: apps.cozystack.io/v1alpha1 |
7 | 19 | kind: Postgres |
@@ -36,19 +48,14 @@ spec: |
36 | 48 | s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu |
37 | 49 | s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog |
38 | 50 | resticPassword: ChaXoveekoh6eigh4siesheeda2quai0 |
39 | | - resources: {} |
| 51 | + $resources |
40 | 52 | resourcesPreset: "nano" |
41 | 53 | EOF |
42 | 54 | 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 |
52 | 59 | kubectl -n tenant-test delete postgreses.apps.cozystack.io $name |
53 | 60 | kubectl -n tenant-test delete job.batch/postgres-$name-init-job |
54 | 61 | } |
0 commit comments