(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestPod(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | |
| 26 | pgadmin := new(v1beta1.PGAdmin) |
| 27 | pgadmin.Name = "pgadmin" |
| 28 | pgadmin.Namespace = "postgres-operator" |
| 29 | config := new(corev1.ConfigMap) |
| 30 | testpod := new(corev1.PodSpec) |
| 31 | pvc := new(corev1.PersistentVolumeClaim) |
| 32 | |
| 33 | call := func() { pod(pgadmin, config, testpod, pvc) } |
| 34 | |
| 35 | t.Run("Defaults", func(t *testing.T) { |
| 36 | |
| 37 | call() |
| 38 | |
| 39 | assert.Assert(t, cmp.MarshalMatches(testpod, ` |
| 40 | containers: |
| 41 | - command: |
| 42 | - bash |
| 43 | - -ceu |
| 44 | - -- |
| 45 | - |- |
| 46 | monitor() { |
| 47 | export PGADMIN_SETUP_PASSWORD="$(date +%s | sha256sum | base64 | head -c 32)" |
| 48 | PGADMIN_DIR=/usr/local/lib/python3.12/site-packages/pgadmin4 |
| 49 | APP_RELEASE=$(cd $PGADMIN_DIR && python3 -c "import config; print(config.APP_RELEASE)") |
| 50 | |
| 51 | echo "Running pgAdmin4 Setup" |
| 52 | if [ $APP_RELEASE -eq 7 ]; then |
| 53 | python3 ${PGADMIN_DIR}/setup.py |
| 54 | else |
| 55 | python3 ${PGADMIN_DIR}/setup.py setup-db |
| 56 | fi |
| 57 | |
| 58 | echo "Starting pgAdmin4" |
| 59 | PGADMIN4_PIDFILE=/tmp/pgadmin4.pid |
| 60 | if [ $APP_RELEASE -eq 7 ]; then |
| 61 | pgadmin4 & |
| 62 | else |
| 63 | gunicorn -c /etc/pgadmin/gunicorn_config.py --chdir $PGADMIN_DIR pgAdmin4:app & |
| 64 | fi |
| 65 | echo $! > $PGADMIN4_PIDFILE |
| 66 | |
| 67 | loadServerCommand() { |
| 68 | if [ $APP_RELEASE -eq 7 ]; then |
| 69 | python3 ${PGADMIN_DIR}/setup.py --load-servers /etc/pgadmin/conf.d/~postgres-operator/pgadmin-shared-clusters.json --user admin@pgadmin.postgres-operator.svc --replace |
| 70 | else |
| 71 | python3 ${PGADMIN_DIR}/setup.py load-servers /etc/pgadmin/conf.d/~postgres-operator/pgadmin-shared-clusters.json --user admin@pgadmin.postgres-operator.svc --replace |
| 72 | fi |
| 73 | } |
| 74 | loadServerCommand |
| 75 | |
| 76 | exec {fd}<> <(:||:) |
| 77 | while read -r -t 5 -u "${fd}" ||:; do |
| 78 | if [[ "${cluster_file}" -nt "/proc/self/fd/${fd}" ]] && loadServerCommand && kill -TERM $(head -1 ${PGADMIN4_PIDFILE?}); |
| 79 | then |
| 80 | exec {fd}>&- && exec {fd}<> <(:||:) |
nothing calls this directly
no test coverage detected