Skip to content

Commit 6f987df

Browse files
test(e2e): fix upgrade canary DB access (verified on a live cluster)
Dev-cluster validation of the seed/verify canary commands surfaced two real bugs, now fixed and re-verified (postgres=3, mariadb=3 rows): - postgres: the seed writes SQL to psql over a heredoc on stdin, but `kubectl exec` without `-i` does not forward stdin, so CREATE/INSERT silently never ran. Add `-i`. - mariadb: the nano server container ships the `mariadb` client (MariaDB 11 dropped `mysql`) and does not bind 127.0.0.1 — connecting there fails and its retry OOM-kills the container. Use the `mariadb` client against the mariadb-test-primary Service (writable primary) from mariadb-test-0. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent a8e5038 commit 6f987df

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

‎hack/e2e-chainsaw-upgrade/seed/mariadb/chainsaw-test.yaml‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ spec:
1818
- podLogs:
1919
selector: app.kubernetes.io/instance=mariadb-test
2020
tail: 50
21+
# Canary writes go to the mariadb-test-primary Service (the writable primary)
22+
# via the `mariadb` client (MariaDB 11 dropped the `mysql` binary). Verified on
23+
# dev10: connecting to 127.0.0.1 fails (server does not bind loopback) and its
24+
# retry OOM-kills the nano server container; the primary Service is clean.
2125
steps:
2226
- name: create-mariadb
2327
try:
@@ -53,18 +57,18 @@ spec:
5357
try:
5458
- script:
5559
timeout: 2m
56-
# mariadb-test-0 is the primary in a fresh install; 127.0.0.1 forces a
57-
# TCP connection so the testuser@%% grant applies (a unix-socket login
58-
# would be testuser@localhost and fail to match).
60+
# Exec from mariadb-test-0 (always present) but connect to the
61+
# mariadb-test-primary Service, so writes reach the actual primary
62+
# regardless of which pod holds that role.
5963
content: |
6064
set -eu
61-
kubectl -n "$NAMESPACE" exec mariadb-test-0 -- env MYSQL_PWD=xai7Wepo \
62-
mysql -h 127.0.0.1 -u testuser testdb -e "
65+
kubectl -n "$NAMESPACE" exec mariadb-test-0 -c mariadb -- env MYSQL_PWD=xai7Wepo \
66+
mariadb -h mariadb-test-primary -u testuser testdb -e "
6367
CREATE TABLE IF NOT EXISTS upgrade_canary (id INT AUTO_INCREMENT PRIMARY KEY, data VARCHAR(64));
6468
TRUNCATE upgrade_canary;
6569
INSERT INTO upgrade_canary (data) VALUES ('pre-upgrade-1'), ('pre-upgrade-2'), ('pre-upgrade-3');"
66-
count=$(kubectl -n "$NAMESPACE" exec mariadb-test-0 -- env MYSQL_PWD=xai7Wepo \
67-
mysql -h 127.0.0.1 -u testuser -N -B testdb -e "SELECT count(*) FROM upgrade_canary;")
70+
count=$(kubectl -n "$NAMESPACE" exec mariadb-test-0 -c mariadb -- env MYSQL_PWD=xai7Wepo \
71+
mariadb -h mariadb-test-primary -u testuser -N -B testdb -e "SELECT count(*) FROM upgrade_canary;")
6872
echo "mariadb canary rows seeded: $count"
6973
[ "$count" = "3" ] || { echo "FAIL: expected 3 seeded rows, got '$count'" >&2; exit 1; }
7074
check:

‎hack/e2e-chainsaw-upgrade/seed/postgres/chainsaw-test.yaml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ spec:
6262
-l cnpg.io/cluster=postgres-test,cnpg.io/instanceRole=primary \
6363
-o name | head -n1)
6464
[ -n "$pod" ] || { echo "no primary pod found" >&2; exit 1; }
65-
kubectl -n "$NAMESPACE" exec "$pod" -c postgres -- psql -U postgres -v ON_ERROR_STOP=1 <<'SQL'
65+
# -i is required: the SQL is fed on stdin via the heredoc, and without
66+
# -i kubectl exec does not forward stdin (verified on dev10 — the
67+
# CREATE/INSERT silently never runs).
68+
kubectl -n "$NAMESPACE" exec -i "$pod" -c postgres -- psql -U postgres -v ON_ERROR_STOP=1 <<'SQL'
6669
CREATE TABLE IF NOT EXISTS upgrade_canary (id serial PRIMARY KEY, data text);
6770
TRUNCATE upgrade_canary;
6871
INSERT INTO upgrade_canary (data) VALUES ('pre-upgrade-1'), ('pre-upgrade-2'), ('pre-upgrade-3');

‎hack/e2e-chainsaw-upgrade/verify/mariadb/chainsaw-test.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ spec:
3333
timeout: 2m
3434
content: |
3535
set -eu
36-
count=$(kubectl -n "$NAMESPACE" exec mariadb-test-0 -- env MYSQL_PWD=xai7Wepo \
37-
mysql -h 127.0.0.1 -u testuser -N -B testdb -e "SELECT count(*) FROM upgrade_canary;")
36+
count=$(kubectl -n "$NAMESPACE" exec mariadb-test-0 -c mariadb -- env MYSQL_PWD=xai7Wepo \
37+
mariadb -h mariadb-test-primary -u testuser -N -B testdb -e "SELECT count(*) FROM upgrade_canary;")
3838
echo "mariadb canary rows after upgrade: $count"
3939
[ "$count" = "3" ] || { echo "FAIL: expected 3 canary rows, got '$count'" >&2; exit 1; }
4040
check:

0 commit comments

Comments
 (0)