Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy test #589

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ COPY ./docker/lagpolling /lagpolling
COPY ./docker/shell-test /shell-test
COPY ./docker/tsa /tsa
COPY ./docker/xproto /xproto
COPY ./docker/copy /copy

COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh

Expand Down
8 changes: 8 additions & 0 deletions docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ do
}
done

# Create tables
psql -h localhost -p 5432 -U postgres -d db -c "CREATE TABLE copy_test(c1 VARCHAR(50), c2 VARCHAR(50), c3 VARCHAR(50))" >> $SETUP_LOG 2>&1 || {
echo "ERROR: tables creation failed, examine the log"
cat "$SETUP_LOG"
cat "$PG_LOG"
exit 1
}

# Create databases for ldap_storage_credentials
for database_name in ldap_db1 ldap_db2; do
sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || {
Expand Down
86 changes: 86 additions & 0 deletions docker/copy/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pid_file "/tmp/odyssey.pid"
daemonize yes

unix_socket_dir "/tmp"
unix_socket_mode "0644"

log_format "%p %t %l [%i %s] (%c) %m\n"

log_to_stdout no

log_syslog no
log_syslog_ident "odyssey"
log_syslog_facility "daemon"

log_debug no
log_config yes
log_session yes
log_query no
log_stats yes
stats_interval 60
log_general_stats_prom yes
log_route_stats_prom no
promhttp_server_port 7777

workers "auto"
resolvers 1

readahead 8192

cache_coroutine 0

coroutine_stack_size 16

nodelay yes

keepalive 15
keepalive_keep_interval 75
keepalive_probes 9

keepalive_usr_timeout 0

listen {
host "*"
port 6432
backlog 128
compression yes
tls "disable"
}


storage "postgres_server" {
type "remote"
host "[localhost]:5432,localhost"
port 5550
}

database "db" {
user "postgres" {
authentication "none"
storage "postgres_server"
pool "transaction"
pool_discard no
pool_reserve_prepared_statement yes
client_fwd_error yes
}
}

storage "local" {
type "local"
}

database "console" {
user default {
authentication "none"
role "admin"
pool "session"
storage "local"
}
}


locks_dir "/tmp/odyssey"

graceful_die_on_errors yes
enable_online_restart no
bindwith_reuseport yes
47 changes: 47 additions & 0 deletions docker/copy/copy_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash -x

set -ex

test_successful() {
(for i in {1..1000}; do
echo "run_id_${i},task_id_${i},Some random ${i}th text";
done | psql postgresql://postgres@localhost:6432/db -c "COPY copy_test FROM STDIN (FORMAT csv);";) > /dev/null 2>&1 || {
echo 1
return
}
echo 0
}

/usr/bin/odyssey /copy/config.conf
with_pstmts_test_successful=$(test_successful)
ody-stop

sed -i '/pool_reserve_prepared_statement yes/d' /copy/config.conf

/usr/bin/odyssey /copy/config.conf
without_pstmts_test_successful=$(test_successful)
ody-stop

if [ $with_pstmts_test_successful -eq 1 -a $without_pstmts_test_successful -eq 0 ]; then {
echo "ERROR: copy bug when pool_reserve_prepared_statement setting to yes"

cat /var/log/odyssey.log
echo "

"
cat /var/log/postgresql/postgresql-14-main.log

exit 1
} fi

if [ $with_pstmts_test_successful -eq 1 -o $without_pstmts_test_successful -eq 1 ]; then {
echo "ERROR: copy bug"

cat /var/log/odyssey.log
echo "

"
cat /var/log/postgresql/postgresql-14-main.log

exit 1
} fi
9 changes: 8 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ ody-start
/xproto/test.sh
ody-stop

# copy
/copy/copy_test.sh
if [ $? -eq 1 ]
then
exit 1
fi

# odyssey rule-address test
/rule-address/test.sh
if [ $? -eq 1 ]
Expand Down Expand Up @@ -86,4 +93,4 @@ ody-start
/ody-integration-test
ody-stop

teardown
teardown
Loading