Skip to content

Commit b4fca70

Browse files
test version check
1 parent 97f8db5 commit b4fca70

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright Materialize, Inc. and contributors. All rights reserved.
2+
#
3+
# Use of this software is governed by the Business Source License
4+
# included in the LICENSE file at the root of this repository.
5+
#
6+
# As of the Change Date specified in that file, in accordance with
7+
# the Business Source License, use of this software will be governed
8+
# by the Apache License, Version 2.0.
9+
10+
# Verify that CREATE TABLE FROM SOURCE fails when connected to a MySQL server
11+
# older than version 8.0.1, which does not support the binlog_row_metadata
12+
# system variable required for full row metadata in the binlog.
13+
14+
$ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
15+
16+
$ mysql-execute name=mysql
17+
DROP DATABASE IF EXISTS public;
18+
CREATE DATABASE public;
19+
USE public;
20+
CREATE TABLE t1 (id INT PRIMARY KEY, val TEXT);
21+
INSERT INTO t1 VALUES (1, 'hello');
22+
23+
> CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
24+
25+
> CREATE CONNECTION mysql_conn TO MYSQL (
26+
HOST mysql,
27+
USER root,
28+
PASSWORD SECRET mysqlpass
29+
)
30+
31+
> CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
32+
33+
! CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
34+
contains: 8.0.1

test/mysql-cdc/mzcompose.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ def create_mysql(mysql_version: str) -> MySql:
3737
return MySql(version=mysql_version)
3838

3939

40+
def create_mysql_pre_8_0_1(version: str = "5.7.44") -> MySql:
41+
"""
42+
Create a MySQL instance for a version older than 8.0.1.
43+
The --binlog-row-metadata flag did not exist before 8.0.1, so it must be
44+
omitted from the server args.
45+
"""
46+
return MySql(
47+
version=version,
48+
additional_args=[
49+
"--log-bin=mysql-bin",
50+
"--gtid_mode=ON",
51+
"--enforce_gtid_consistency=ON",
52+
"--binlog-format=row",
53+
"--binlog-row-image=full",
54+
"--server-id=1",
55+
"--max-connections=500",
56+
],
57+
)
58+
59+
4060
def create_mysql_replica(mysql_version: str) -> MySql:
4161
return MySql(
4262
name="mysql-replica",
@@ -368,3 +388,19 @@ def workflow_source_timeouts(c: Composition, parser: WorkflowArgumentParser) ->
368388
f"--var=mysql-root-password={MySql.DEFAULT_ROOT_PASSWORD}",
369389
"proxied/*.td",
370390
)
391+
392+
393+
def workflow_mysql_version_compat(
394+
c: Composition, _parser: WorkflowArgumentParser
395+
) -> None:
396+
"""
397+
Validates that CREATE TABLE FROM SOURCE fails when connected to a MySQL
398+
server older than version 8.0.1, which does not support the
399+
binlog_row_metadata system variable required for full row metadata.
400+
"""
401+
with c.override(create_mysql_pre_8_0_1()):
402+
c.up("materialized", "mysql")
403+
c.run_testdrive_files(
404+
f"--var=mysql-root-password={MySql.DEFAULT_ROOT_PASSWORD}",
405+
"mysql-version-compat/version-check.td",
406+
)

0 commit comments

Comments
 (0)