Skip to content

Commit bf152f8

Browse files
committed
Document all test functions
1 parent 468f21e commit bf152f8

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

test/run_test

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ run_s2i_enable_ssl_test
2727
run_upgrade_test
2828
run_migration_test
2929
run_pgaudit_test
30-
run_new_pgaudit_test
30+
run_env_extension_load_test
3131
run_logging_test
3232
"
3333

@@ -291,6 +291,12 @@ function try_image_invalid_combinations() {
291291
return $ret
292292
}
293293

294+
# run_container_creation_tests
295+
# --------------------
296+
# Asserts that container image fails to run in certain illegal use of arguments,
297+
# while it correctly runs in other combinations.
298+
# NOTE: Previously the `creation_succeeds` combinations were supposed to fail, but
299+
# these cases are now supposed to work
294300
function run_container_creation_tests() {
295301
local ret=0
296302
echo " Testing image entrypoint usage"
@@ -583,6 +589,11 @@ function run_master_restart_test() {
583589
return $ret
584590
}
585591

592+
# run_replication_test
593+
# --------------------
594+
# Start two containers one as main, one as secondary. Checks whether the main
595+
# sees secondary server connected. Tries to create data on main server and
596+
# checks whether they are correctly replicated to secondary server.
586597
function run_replication_test() {
587598
local DB=postgres
588599
local PGUSER=master
@@ -610,6 +621,10 @@ function run_replication_test() {
610621
return $ret
611622
}
612623

624+
# run_change_password_test
625+
# --------------------
626+
# Check whether starting container with different password argument correctly
627+
# changes the password and allows connection to old already used db.
613628
function run_change_password_test() {
614629
echo " Testing password change"
615630
local name="change_password"
@@ -686,6 +701,11 @@ $volume_options
686701
return $ret
687702
}
688703

704+
# run_upgrade_test
705+
# --------------------
706+
# Testing upgrade from previous version to current version using
707+
# POSTGRESQL_UPGRADE env variable. Checks that upgrade is successfull using two
708+
# demo databases (simple and pagila)
689709
run_upgrade_test ()
690710
{
691711
local ret=0
@@ -728,6 +748,11 @@ run_upgrade_test ()
728748
return $ret
729749
}
730750

751+
# run_migration_test
752+
# --------------------
753+
# Testing migration from each supported version to currently tested one. Pagila
754+
# is used as a demo database - data integrity is checked. Asserts that no
755+
# invalid options can be passed without container failing to start.
731756
run_migration_test ()
732757
{
733758
local ret=0
@@ -750,6 +775,10 @@ run_migration_test ()
750775
return $ret
751776
}
752777

778+
# run_doc_test
779+
# --------------------
780+
# Checks whether `help.1` file with specific terms is included in default
781+
# working directory in the container image.
753782
run_doc_test() {
754783
local tmpdir=$(mktemp -d)
755784
local f
@@ -801,6 +830,10 @@ ${mount_opts}
801830
return $ret
802831
}
803832

833+
# run_s2i_test
834+
# --------------------
835+
# Build S2I image with basic script. Try running the container with usage of the
836+
# script that we built into that S2I image. Compare with original image.
804837
run_s2i_test() {
805838
local temp_file
806839
local ret=0
@@ -826,6 +859,10 @@ run_s2i_test() {
826859
return $ret
827860
}
828861

862+
# run_general_tests
863+
# --------------------
864+
# Tests different combinations of parameters and that they work. Also tests SCL
865+
# usage. Tries to actually SELECT something from the database.
829866
function run_general_tests() {
830867
local ret=0
831868
PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin || ret=1
@@ -841,6 +878,10 @@ function run_general_tests() {
841878
return $ret
842879
}
843880

881+
# run_test_cfg_hook
882+
# --------------------
883+
# Checks whether using config files in persistent mounted volume works. Also
884+
# checks that the config file has priority over env variables.
844885
run_test_cfg_hook()
845886
{
846887
local ret=0
@@ -877,6 +918,10 @@ run_test_cfg_hook()
877918
return $ret
878919
}
879920

921+
# run_s2i_enable_ssl_test
922+
# --------------------
923+
# Creates S2I image with SSL config and certificates. Tries to connect with
924+
# required SSL connection.
880925
run_s2i_enable_ssl_test()
881926
{
882927
local s2i_image_name="$IMAGE_NAME-ssl_$(ct_random_string)"
@@ -898,6 +943,10 @@ run_s2i_enable_ssl_test()
898943
false "FAIL: Did not manage to connect using SSL only."
899944
}
900945

946+
# run_s2i_bake_data_test
947+
# --------------------
948+
# Testing pre-start script and `init.sql` file with prefilled data placed in S2I
949+
# resulting image.
901950
run_s2i_bake_data_test ()
902951
{
903952
local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
@@ -916,6 +965,11 @@ run_s2i_bake_data_test ()
916965
bash -c "psql -tA -c 'SELECT * FROM test;'")"
917966
}
918967

968+
# run_pgaudit_test
969+
# --------------------
970+
# Configure container to include pgaudit using config directory volumes. Check
971+
# that pgaudit is loaded. Set pgaudit logging and check that logs are present in
972+
# log folder.
919973
run_pgaudit_test()
920974
{
921975
local ret=0
@@ -975,6 +1029,10 @@ EOSQL" || ret=3
9751029
return $ret
9761030
}
9771031

1032+
# run_logging_test
1033+
# --------------------
1034+
# Checks that changing log location via `POSTGRESQL_LOG_DESTINATION` env
1035+
# variable works correctly.
9781036
run_logging_test()
9791037
{
9801038
local data_dir name=pg-test-logging
@@ -1018,7 +1076,11 @@ run_logging_test()
10181076
echo " Success!"
10191077
}
10201078

1021-
run_new_pgaudit_test() {
1079+
# run_env_extension_load_test
1080+
# --------------------
1081+
# Tries to load pgaudit extension using environment variables
1082+
# `POSTGRESQL_EXTENSIONS` and `POSTGRESQL_LIBRARIES`
1083+
run_env_extension_load_test() {
10221084
DOCKER_EXTRA_ARGS="
10231085
-e POSTGRESQL_EXTENSIONS=pgaudit
10241086
-e POSTGRESQL_LIBRARIES=pgaudit"

0 commit comments

Comments
 (0)