|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +check_pgbench() { |
| 4 | + local DBOPS_NAME="${1:-$DBOPS_NAME}" |
| 5 | + |
| 6 | + assert_dbops_running "$DBOPS_NAME" "$CLUSTER_NAMESPACE" |
| 7 | + |
| 8 | + assert_dbops_completion "$DBOPS_NAME" "$CLUSTER_NAMESPACE" |
| 9 | + |
| 10 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" job \ |
| 11 | + -l "stackgres.io/dbops-name=$DBOPS_NAME,stackgres.io/db-ops=true" \ |
| 12 | + -o name 2>/dev/null | wc -l)" = 1 ] |
| 13 | + then |
| 14 | + success "pgbench job was not removed after completion." |
| 15 | + else |
| 16 | + fail "pgbench job was removed after completion." |
| 17 | + fi |
| 18 | + |
| 19 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 20 | + --template '{{ .status.benchmark.pgbench.scaleFactor }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 21 | + then |
| 22 | + success "pgbench returned the scale factor." |
| 23 | + else |
| 24 | + fail "pgbench did not returned the scale factor." |
| 25 | + fi |
| 26 | + |
| 27 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 28 | + --template '{{ .status.benchmark.pgbench.transactionsProcessed }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 29 | + then |
| 30 | + success "pgbench returned the transactions processed." |
| 31 | + else |
| 32 | + fail "pgbench did not returned the transactions processed." |
| 33 | + fi |
| 34 | + |
| 35 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 36 | + --template '{{ .status.benchmark.pgbench.latency.average.value }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 37 | + then |
| 38 | + success "pgbench returned the average latency." |
| 39 | + else |
| 40 | + fail "pgbench did not returned the average latency." |
| 41 | + fi |
| 42 | + |
| 43 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 44 | + --template '{{ .status.benchmark.pgbench.latency.average.unit }}')" \ |
| 45 | + = "ms" ] |
| 46 | + then |
| 47 | + success "pgbench returned the average latency unit" |
| 48 | + else |
| 49 | + fail "pgbench did not returned the average latency unit." |
| 50 | + fi |
| 51 | + |
| 52 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 53 | + --template '{{ .status.benchmark.pgbench.latency.standardDeviation.value}}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 54 | + then |
| 55 | + success "pgbench returned the latency standard deviation." |
| 56 | + else |
| 57 | + fail "pgbench did not returned the latency standard deviation." |
| 58 | + fi |
| 59 | + |
| 60 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 61 | + --template '{{ .status.benchmark.pgbench.latency.standardDeviation.unit}}')" \ |
| 62 | + = "ms" ] |
| 63 | + then |
| 64 | + success "pgbench returned the latency standard deviation unit." |
| 65 | + else |
| 66 | + fail "pgbench did not returned the latency standard deviation unit." |
| 67 | + fi |
| 68 | + |
| 69 | + if [ "${E2E_POSTGRES_VERSION%%.*}" -le 13 ] |
| 70 | + then |
| 71 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 72 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.includingConnectionsEstablishing.value }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 73 | + then |
| 74 | + success "pgbench returned the tps including connections establishing." |
| 75 | + else |
| 76 | + fail "pgbench did not returned the tps including connections establishing." |
| 77 | + fi |
| 78 | + |
| 79 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 80 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.includingConnectionsEstablishing.unit }}')" \ |
| 81 | + = "tps" ] |
| 82 | + then |
| 83 | + success "pgbench returned the tps including connections establishing unit." |
| 84 | + else |
| 85 | + fail "pgbench did not returned the tps including connections establishing unit." |
| 86 | + fi |
| 87 | + fi |
| 88 | + |
| 89 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 90 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.excludingConnectionsEstablishing.value }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 91 | + then |
| 92 | + success "pgbench returned the tps excluding connections establishing." |
| 93 | + else |
| 94 | + fail "pgbench did not returned the tps excluding connections establishing." |
| 95 | + fi |
| 96 | + |
| 97 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 98 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.excludingConnectionsEstablishing.unit }}')" \ |
| 99 | + = "tps" ] |
| 100 | + then |
| 101 | + success "pgbench returned the tps excluding connections establishing unit." |
| 102 | + else |
| 103 | + fail "pgbench did not returned the tps excluding connections establishing unit." |
| 104 | + fi |
| 105 | + |
| 106 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 107 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.overTime.values | len }}')" -gt 0 ] |
| 108 | + then |
| 109 | + success "pgbench returned the tps over time values." |
| 110 | + else |
| 111 | + fail "pgbench did not returned the tps over time values." |
| 112 | + fi |
| 113 | + |
| 114 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 115 | + --template '{{ (index .status.benchmark.pgbench.transactionsPerSecond.overTime.values 0) }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 116 | + then |
| 117 | + success "pgbench returned the tps over time value." |
| 118 | + else |
| 119 | + fail "pgbench did not returned the tps over time value." |
| 120 | + fi |
| 121 | + |
| 122 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 123 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.overTime.valuesUnit }}')" = 'tps' ] |
| 124 | + then |
| 125 | + success "pgbench returned the tps over time values unit." |
| 126 | + else |
| 127 | + fail "pgbench did not returned the tps over time values unit." |
| 128 | + fi |
| 129 | + |
| 130 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 131 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.overTime.intervalDuration }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 132 | + then |
| 133 | + success "pgbench returned the tps over time interval duration." |
| 134 | + else |
| 135 | + fail "pgbench did not returned the tps over time interval duration." |
| 136 | + fi |
| 137 | + |
| 138 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 139 | + --template '{{ .status.benchmark.pgbench.transactionsPerSecond.overTime.intervalDurationUnit }}')" = 'ms' ] |
| 140 | + then |
| 141 | + success "pgbench returned the tps over time interval duration unit." |
| 142 | + else |
| 143 | + fail "pgbench did not returned the tps over time interval duration unit." |
| 144 | + fi |
| 145 | + |
| 146 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 147 | + --template '{{ .status.benchmark.pgbench.statements | len }}')" -gt 0 ] |
| 148 | + then |
| 149 | + success "pgbench returned the statements." |
| 150 | + else |
| 151 | + fail "pgbench did not returned the statements." |
| 152 | + fi |
| 153 | + |
| 154 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 155 | + --template '{{ (index .status.benchmark.pgbench.statements 0).command }}' | grep . |
| 156 | + then |
| 157 | + success "pgbench returned the statements command." |
| 158 | + else |
| 159 | + fail "pgbench did not returned the statements command." |
| 160 | + fi |
| 161 | + |
| 162 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 163 | + --template '{{ (index .status.benchmark.pgbench.statements 0).latency }}' | grep -x '[0-9]\+\(\.[0-9]\+\)\?' |
| 164 | + then |
| 165 | + success "pgbench returned the statements latency." |
| 166 | + else |
| 167 | + fail "pgbench did not returned the statements latency." |
| 168 | + fi |
| 169 | + |
| 170 | + if [ "$(kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 171 | + --template '{{ (index .status.benchmark.pgbench.statements 0).unit }}')" = ms ] |
| 172 | + then |
| 173 | + success "pgbench returned the statements unit." |
| 174 | + else |
| 175 | + fail "pgbench did not returned the statements unit." |
| 176 | + fi |
| 177 | + |
| 178 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 179 | + --template '{{ (index .status.benchmark.pgbench.statements 0).script }}' | grep -x '[0-9]\+' |
| 180 | + then |
| 181 | + success "pgbench returned the statements script." |
| 182 | + else |
| 183 | + fail "pgbench did not returned the statements script." |
| 184 | + fi |
| 185 | + |
| 186 | + if kubectl get -n "$CLUSTER_NAMESPACE" sgdbops "$DBOPS_NAME" \ |
| 187 | + --template '{{ .status.benchmark.pgbench.hdrHistogram }}' | grep -x '[0-9A-Za-z+/=]\+' |
| 188 | + then |
| 189 | + success "pgbench returned the HdrHistogram." |
| 190 | + else |
| 191 | + fail "pgbench did not returned the HdrHistogram." |
| 192 | + fi |
| 193 | + |
| 194 | + RESULT="$(run_query -i 0 -p 5432 -q "SELECT EXISTS(SELECT * FROM pg_database WHERE datname LIKE 'pgbench-%')")" |
| 195 | + if [ "$RESULT" = "f" ] |
| 196 | + then |
| 197 | + success "pgbench database was dropped." |
| 198 | + else |
| 199 | + fail "pgbench database was not dropped." |
| 200 | + fi |
| 201 | +} |
0 commit comments