File tree 4 files changed +61
-0
lines changed
4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/bash -x
2
+
3
+ # fail early
4
+ set -e
5
+
6
+ # source the convenience tooling
7
+ source " ${CONTAINER_SCRIPTS_PATH} /common.sh"
8
+
9
+ # set $PGDATA variable
10
+ set_pgdata
11
+
12
+ # assert uninitialized data
13
+ test ! -f " $PGDATA /postgresql.conf"
14
+
15
+ # empty config file is needed after 'initialize_database' call
16
+ touch " $POSTGRESQL_CONFIG_FILE "
17
+
18
+ initialize_database
19
+
20
+ # start local PostgreSQL server (wait with '-w')
21
+ pg_ctl -w start -o " -h ''"
22
+
23
+ # load all sql files
24
+ shopt -s nullglob
25
+ for file in /tmp/src/init/* .sql; do
26
+ psql -f " $file "
27
+ done
28
+
29
+ pg_ctl stop
30
+
31
+ # dump the data into $PWD (in-image storage)
32
+ tar caf data.tar.xz -C " $PGDATA " .
33
+ rm -rf " $PGDATA "
34
+
35
+ # install pre-start hook
36
+ cp -r /tmp/src/postgresql-pre-start .
Original file line number Diff line number Diff line change
1
+ CREATE TABLE test (sth TEXT );
2
+ INSERT INTO test VALUES (' hello world' );
Original file line number Diff line number Diff line change
1
+ if test ! -f " $PGDATA /postgresql.conf" ; then
2
+ tar xf " $APP_DATA " /src/data.tar.xz -C " $PGDATA "
3
+ fi
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ run_master_restart_test
26
26
run_doc_test
27
27
run_s2i_test
28
28
run_test_cfg_hook
29
+ run_s2i_bake_data_test
29
30
"
30
31
31
32
test $# -eq 1 -a " ${1-} " == --list && echo " $TEST_LIST " && exit 0
@@ -707,6 +708,25 @@ run_test_cfg_hook()
707
708
assert_runtime_option " $name -3" shared_buffers 111MB
708
709
}
709
710
711
+ run_s2i_bake_data_test ()
712
+ {
713
+ local s2i_image_name=" $IMAGE_NAME -bake_$( ct_random_string) "
714
+ s2i build " file://$test_dir /../examples/s2i-dump-data" " ${IMAGE_NAME} " " $s2i_image_name "
715
+ ct_path_append images_to_clean " $s2i_image_name "
716
+
717
+ local container_name=bake-data-test
718
+
719
+ DOCKER_ARGS=" -e POSTGRESQL_ADMIN_PASSWORD=password" \
720
+ IMAGE_NAME=" $s2i_image_name " create_container " $container_name "
721
+
722
+ wait_ready " $container_name "
723
+
724
+ test " hello world" == " $( docker exec " $( get_cid " $container_name " ) " \
725
+ bash -c " psql -tA -c 'SELECT * FROM test;'" ) "
726
+
727
+ docker stop " $( get_cid " $container_name " ) "
728
+ }
729
+
710
730
function run_all_tests() {
711
731
for test_case in $TEST_LIST ; do
712
732
: " Running test $test_case "
You can’t perform that action at this time.
0 commit comments