Skip to content

Commit

Permalink
tests: Add test for mysql_source_connect_timeout with toxiproxy latency
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Feb 5, 2025
1 parent 0f62d9d commit 48f4afd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/mysql-cdc/mzcompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,5 @@ def workflow_source_timeouts(c: Composition, parser: WorkflowArgumentParser) ->
c.up("materialized", "mysql", "toxiproxy")
c.run_testdrive_files(
f"--var=mysql-root-password={MySql.DEFAULT_ROOT_PASSWORD}",
"proxied/connect_timeout.td",
"proxied/*.td",
)
56 changes: 56 additions & 0 deletions test/mysql-cdc/proxied/connect_timeout_latency.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.


> DROP SOURCE IF EXISTS mz_source CASCADE;
> DROP CONNECTION IF EXISTS mysql_conn CASCADE;
> DROP SECRET IF EXISTS mysql_pass;

# Override MySQL connect timeout to 2s
$ postgres-connect name=mz_system url=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
$ postgres-execute connection=mz_system
ALTER SYSTEM SET mysql_source_connect_timeout = '2s';

# delay connectivity to mysql by 3s
$ http-request method=POST url=http://toxiproxy:8474/proxies content-type=application/json
{
"name": "mysql",
"listen": "0.0.0.0:3306",
"upstream": "mysql:3306",
"enabled": true
}
$ http-request method=POST url=http://toxiproxy:8474/proxies/mysql/toxics content-type=application/json
{
"name": "mysql",
"type": "latency",
"attributes": { "latency": 3000 }
}

> CREATE SECRET mysql_pass AS '${arg.mysql-root-password}';
! CREATE CONNECTION mysql_conn TO MYSQL (
HOST "toxiproxy",
USER root,
PASSWORD SECRET mysql_pass
);
contains:connection attempt timed out after 2s

# Override MySQL connect timeout to 30s
$ postgres-connect name=mz_system url=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
$ postgres-execute connection=mz_system
ALTER SYSTEM SET mysql_source_connect_timeout = '30s';

> CREATE CONNECTION mysql_conn TO MYSQL (
HOST "toxiproxy",
USER root,
PASSWORD SECRET mysql_pass
);

> DROP CONNECTION mysql_conn

$ http-request method=DELETE url=http://toxiproxy:8474/proxies/mysql

0 comments on commit 48f4afd

Please sign in to comment.