Skip to content

Commit adbeb06

Browse files
committed
add passing alter_table.md
1 parent 59dca2b commit adbeb06

File tree

8 files changed

+433
-145
lines changed

8 files changed

+433
-145
lines changed

ci/test/pipeline.template.yml

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,68 @@ steps:
378378
# Too slow on aarch64
379379
queue: hetzner-x86-64-4cpu-8gb
380380

381-
- id: sql-server-cdc
382-
label: "SQL Server CDC tests"
383-
depends_on: build-x86_64
384-
timeout_in_minutes: 30
385-
inputs: [test/sql-server-cdc]
386-
parallelism: 2
387-
plugins:
388-
- ./ci/plugins/mzcompose:
389-
composition: sql-server-cdc
390-
agents:
391-
# The SQL Server Docker image isn't available on ARM.
392-
#
393-
# See: <https://github.com/microsoft/mssql-docker/issues/864>
394-
queue: hetzner-x86-64-8cpu-16gb
381+
- group: "SQL Server tests"
382+
key: sql-server-tests
383+
steps:
384+
- id: sql-server-cdc
385+
label: "SQL Server CDC tests"
386+
depends_on: build-x86_64
387+
timeout_in_minutes: 30
388+
inputs: [test/sql-server-cdc]
389+
parallelism: 2
390+
plugins:
391+
- ./ci/plugins/mzcompose:
392+
composition: sql-server-cdc
393+
agents:
394+
# The SQL Server Docker image isn't available on ARM.
395+
#
396+
# See: <https://github.com/microsoft/mssql-docker/issues/864>
397+
queue: hetzner-x86-64-8cpu-16gb
398+
399+
- id: sql-server-cdc-old-syntax
400+
label: "SQL Server CDC old syntax tests"
401+
depends_on: build-x86_64
402+
timeout_in_minutes: 30
403+
inputs: [test/sql-server-cdc-old-syntax]
404+
parallelism: 2
405+
plugins:
406+
- ./ci/plugins/mzcompose:
407+
composition: sql-server-cdc
408+
agents:
409+
# The SQL Server Docker image isn't available on ARM.
410+
#
411+
# See: <https://github.com/microsoft/mssql-docker/issues/864>
412+
queue: hetzner-x86-64-8cpu-16gb
413+
414+
#- id: sql-server-cdc-resumption-old-syntax
415+
# label: "SQL Server resumption old syntax tests"
416+
# depends_on: build-x86_64
417+
# timeout_in_minutes: 30
418+
# inputs: [test/sql-server-resumption-old-syntax]
419+
# parallelism: 2
420+
# plugins:
421+
# - ./ci/plugins/mzcompose:
422+
# composition: sql-server-cdc
423+
# agents:
424+
# # The SQL Server Docker image isn't available on ARM.
425+
# #
426+
# # See: <https://github.com/microsoft/mssql-docker/issues/864>
427+
# queue: hetzner-x86-64-8cpu-16gb
428+
429+
- id: sql-server-rtr-old-syntax
430+
label: "SQL Server RTR old syntax tests"
431+
depends_on: build-x86_64
432+
timeout_in_minutes: 30
433+
inputs: [test/sql-server-rtr-old-syntax]
434+
parallelism: 2
435+
plugins:
436+
- ./ci/plugins/mzcompose:
437+
composition: sql-server-cdc
438+
agents:
439+
# The SQL Server Docker image isn't available on ARM.
440+
#
441+
# See: <https://github.com/microsoft/mssql-docker/issues/864>
442+
queue: hetzner-x86-64-8cpu-16gb
395443

396444
- group: "Connection tests"
397445
key: connection-tests

test/sql-server-cdc-old-syntax/alter-source.td

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@ $ sql-server-connect name=sql-server
1111
server=tcp:sql-server,1433;IntegratedSecurity=true;TrustServerCertificate=true;User ID=${arg.default-sql-server-user};Password=${arg.default-sql-server-password}
1212

1313
$ sql-server-execute name=sql-server
14-
IF EXISTS (SELECT 1 FROM sys.databases WHERE name = 'test') BEGIN ALTER DATABASE test SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE test; END;
15-
CREATE DATABASE test;
1614
USE test;
17-
EXEC sys.sp_cdc_enable_db;
18-
ALTER DATABASE test SET ALLOW_SNAPSHOT_ISOLATION ON;
19-
2015
CREATE TABLE table_a (pk INTEGER PRIMARY KEY, f2 VARCHAR(128));
2116
INSERT INTO table_a VALUES (1, 'one');
2217
INSERT INTO table_a VALUES (2, 'two');
2318
EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_a', @role_name = 'SA', @supports_net_changes = 0;
2419

25-
# Check empty publication on ALTER
26-
2720
> CREATE SECRET IF NOT EXISTS sql_server_pass AS '${arg.default-sql-server-password}'
2821

2922
> DROP CONNECTION IF EXISTS sql_server_test_connection CASCADE
@@ -40,6 +33,7 @@ EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_a', @
4033
> CREATE SOURCE mz_source
4134
FROM SQL SERVER CONNECTION sql_server_test_connection
4235
FOR ALL TABLES;
36+
> DROP SOURCE dummy;
4337

4438
> SELECT * FROM table_a;
4539
1 one
@@ -48,7 +42,7 @@ EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'table_a', @
4842
$ sql-server-execute name=sql-server
4943
DROP TABLE table_a;
5044

51-
!ALTER SOURCE mz_source ADD SUBSOURCE table_b;
45+
! ALTER SOURCE mz_source ADD SUBSOURCE table_b;
5246
contains:reference to table_b not found in source
5347

5448
# Adding a table with the same name as a running table does not allow you to add
@@ -115,6 +109,8 @@ INSERT INTO table_g VALUES (2, 'two');
115109
)
116110
FOR ALL TABLES;
117111

112+
> DROP SOURCE dummy;
113+
118114
> SHOW SUBSOURCES ON mz_source
119115
mz_source_progress progress
120116
table_a subsource

test/sql-server-cdc-old-syntax/mzcompose.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@
1212
"""
1313

1414
import glob
15+
import pathlib
1516
import random
1617

17-
from materialize import MZ_ROOT
18-
from materialize.mzcompose.composition import Composition, WorkflowArgumentParser
18+
from materialize import MZ_ROOT, buildkite
19+
from materialize.mzcompose.composition import (
20+
Composition,
21+
WorkflowArgumentParser,
22+
)
1923
from materialize.mzcompose.services.materialized import Materialized
2024
from materialize.mzcompose.services.mz import Mz
2125
from materialize.mzcompose.services.sql_server import SqlServer
2226
from materialize.mzcompose.services.testdrive import Testdrive
2327

2428
SERVICES = [
2529
Mz(app_password=""),
26-
Materialized(),
30+
Materialized(
31+
additional_system_parameter_defaults={
32+
"log_filter": "mz_storage::source::sql_server=trace,mz_storage::source::sql_server::replication=trace,mz_sql_server_util=debug,info"
33+
},
34+
),
2735
Testdrive(),
2836
SqlServer(),
2937
]
3038

3139

32-
#
33-
# Test that SQL Server ingestion works
34-
#
3540
def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
3641
parser.add_argument(
3742
"filter",
@@ -41,26 +46,35 @@ def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
4146
)
4247
args = parser.parse_args()
4348

44-
matching_files = []
49+
matching_files: list[str] = []
4550
for filter in args.filter:
4651
matching_files.extend(
4752
glob.glob(filter, root_dir=MZ_ROOT / "test" / "sql-server-cdc-old-syntax")
4853
)
4954
matching_files = sorted(matching_files)
50-
print(f"Filter: {args.filter} Files: {matching_files}")
55+
sharded_files: list[str] = buildkite.shard_list(
56+
sorted(matching_files), lambda file: file
57+
)
58+
print(f"Filter: {args.filter} Files: {sharded_files}")
59+
60+
# Start with a fresh state
61+
c.kill("sql-server")
62+
c.rm("sql-server")
63+
c.kill("materialized")
64+
c.rm("materialized")
5165

5266
c.up("materialized", "sql-server")
5367
seed = random.getrandbits(16)
5468

55-
c.test_parts(
56-
matching_files,
57-
lambda file: c.run_testdrive_files(
58-
"--no-reset",
69+
def run(file: pathlib.Path | str) -> None:
70+
c.run_testdrive_files(
5971
"--max-errors=1",
6072
f"--seed={seed}",
6173
f"--var=default-replica-size={Materialized.Size.DEFAULT_SIZE}-{Materialized.Size.DEFAULT_SIZE}",
6274
f"--var=default-sql-server-user={SqlServer.DEFAULT_USER}",
6375
f"--var=default-sql-server-password={SqlServer.DEFAULT_SA_PASSWORD}",
76+
"setup/setup.td",
6477
str(file),
65-
),
66-
)
78+
)
79+
80+
c.test_parts(sharded_files, run)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
$ sql-server-connect name=sql-server
11+
server=tcp:sql-server,1433;IntegratedSecurity=true;TrustServerCertificate=true;User ID=${arg.default-sql-server-user};Password=${arg.default-sql-server-password}
12+
13+
$ sql-server-execute name=sql-server split-lines=false
14+
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'test')
15+
BEGIN
16+
ALTER DATABASE test SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
17+
DROP DATABASE test;
18+
END;
19+
20+
$ sql-server-execute name=sql-server split-lines=false
21+
USE msdb;
22+
IF EXISTS (
23+
SELECT 1
24+
FROM msdb.dbo.sysjobs
25+
WHERE name = N'DummyTicker'
26+
)
27+
BEGIN
28+
EXEC sp_delete_job @job_name = N'DummyTicker';
29+
END;
30+
31+
$ sql-server-execute name=sql-server
32+
CREATE DATABASE test COLLATE Latin1_General_100_CI_AI_SC_UTF8;
33+
USE test;
34+
35+
EXEC sys.sp_cdc_enable_db;
36+
ALTER DATABASE test SET ALLOW_SNAPSHOT_ISOLATION ON;
37+
38+
CREATE TABLE dummy (t datetime);
39+
INSERT INTO dummy VALUES (CURRENT_TIMESTAMP);
40+
EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name = 'dummy', @role_name = 'SA', @supports_net_changes = 0;
41+
42+
$ sql-server-execute name=sql-server split-lines=false
43+
CREATE OR ALTER PROCEDURE dbo.DummyTicker AS
44+
BEGIN
45+
SET NOCOUNT ON;
46+
WHILE 1 = 1
47+
BEGIN
48+
UPDATE dbo.dummy SET t = CURRENT_TIMESTAMP;
49+
WAITFOR DELAY '00:00:01';
50+
END
51+
END;
52+
53+
$ sql-server-execute name=sql-server
54+
USE msdb;
55+
EXEC sp_add_job @job_name = N'DummyTicker', @enabled = 1;
56+
EXEC sp_add_jobstep @job_name = N'DummyTicker', @step_name = N'run', @subsystem = N'TSQL', @database_name = N'test', @command = N'EXEC dbo.DummyTicker;';
57+
EXEC sp_add_jobserver @job_name = N'DummyTicker';
58+
EXEC msdb.dbo.sp_start_job N'DummyTicker';

0 commit comments

Comments
 (0)