This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new a3d0034be ci: make the debezium-sqlserver test setup safe to retry
(#3404)
a3d0034be is described below
commit a3d0034be42a698817d4feafd0c01237fcea6d4b
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Dec 2 12:58:13 2026 +0100
ci: make the debezium-sqlserver test setup safe to retry (#3404)
Enabling CDC on the table fails while SQL Server Agent is still starting
(Msg 22832 from sp_cdc_add_job). The setup SQL runs in repeatOnError, but
every retry started again with CREATE DATABASE testdb and failed with
Msg 1801 "already exists", so the test could never recover. Each statement
now checks first whether an earlier attempt has done it already.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../debezium-sqlserver-source-route.citrus.it.yaml | 24 ++++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git
a/tests/camel-kamelets-itest/src/test/resources/database/debezium/debezium-sqlserver-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/database/debezium/debezium-sqlserver-source-route.citrus.it.yaml
index c30b94107..0710cc4a1 100644
---
a/tests/camel-kamelets-itest/src/test/resources/database/debezium/debezium-sqlserver-source-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/database/debezium/debezium-sqlserver-source-route.citrus.it.yaml
@@ -46,24 +46,30 @@ actions:
waitFor:
logMessage: '.*SQL Server is now ready for client connections.*'
- # A table of one row with CDC, a table without CDC, and a user in the
db_owner role of the database
+ # A table of one row with CDC, a table without CDC, and a user in the
db_owner role of the database.
+ # Enabling CDC on the table fails while SQL Server Agent is still starting,
so the script is retried, and each
+ # statement checks first whether an earlier attempt has done it already
- createVariables:
variables:
- name: "db.container"
value: "sqlserver"
- name: "db.sql"
value: |-
- CREATE DATABASE testdb
+ IF DB_ID('testdb') IS NULL CREATE DATABASE testdb
GO
USE testdb
- CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100),
price DECIMAL(10,2), added DATE, note VARCHAR(100));
- INSERT INTO products VALUES (1, 'Tea', 4.50, '2026-01-01', 'not
sent');
- CREATE TABLE notes (id INT PRIMARY KEY, text VARCHAR(100));
- CREATE LOGIN test WITH PASSWORD = 'Citrus-Test-2', CHECK_POLICY =
OFF;
- CREATE USER test FOR LOGIN test;
+ IF OBJECT_ID('dbo.products') IS NULL
+ BEGIN
+ CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100),
price DECIMAL(10,2), added DATE, note VARCHAR(100));
+ INSERT INTO products VALUES (1, 'Tea', 4.50, '2026-01-01',
'not sent');
+ END
+ IF OBJECT_ID('dbo.notes') IS NULL CREATE TABLE notes (id INT
PRIMARY KEY, text VARCHAR(100));
+ IF SUSER_ID('test') IS NULL CREATE LOGIN test WITH PASSWORD =
'Citrus-Test-2', CHECK_POLICY = OFF;
+ IF USER_ID('test') IS NULL CREATE USER test FOR LOGIN test;
ALTER ROLE db_owner ADD MEMBER test;
- EXEC sys.sp_cdc_enable_db;
- EXEC sys.sp_cdc_enable_table @source_schema = 'dbo', @source_name
= 'products', @role_name = NULL;
+ IF (SELECT is_cdc_enabled FROM sys.databases WHERE name =
'testdb') = 0 EXEC sys.sp_cdc_enable_db;
+ IF (SELECT is_tracked_by_cdc FROM sys.tables WHERE object_id =
OBJECT_ID('dbo.products')) = 0
+ EXEC sys.sp_cdc_enable_table @source_schema = 'dbo',
@source_name = 'products', @role_name = NULL;
- repeatOnError:
until: "i > 30"
autoSleep: 1000