Skip to content

Commit

Permalink
tests: restart
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Dec 13, 2024
1 parent f1626f2 commit 7ae2e11
Show file tree
Hide file tree
Showing 2 changed files with 456 additions and 0 deletions.
293 changes: 293 additions & 0 deletions tests/cases/standalone/common/flow/flow_rebuild.result
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,296 @@ SELECT wildcard FROM out_basic;
| 3 |
+----------+

-- test again, this time with db restart
DROP TABLE input_basic;

Affected Rows: 0

DROP TABLE out_basic;

Affected Rows: 0

DROP FLOW test_wildcard_basic;

Affected Rows: 0

CREATE TABLE input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);

Affected Rows: 0

CREATE FLOW test_wildcard_basic sink TO out_basic AS
SELECT
COUNT(*) as wildcard
FROM
input_basic;

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500");

Affected Rows: 2

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 2 |
+----------+

DROP TABLE input_basic;

Affected Rows: 0

DROP TABLE out_basic;

Affected Rows: 0

DROP FLOW test_wildcard_basic;

Affected Rows: 0

-- combination of different order of rebuild input table/flow
CREATE TABLE input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);

Affected Rows: 0

CREATE FLOW test_wildcard_basic sink TO out_basic AS
SELECT
COUNT(*) as wildcard
FROM
input_basic;

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500");

Affected Rows: 2

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 2 |
+----------+

DROP TABLE input_basic;

Affected Rows: 0

CREATE TABLE input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500"),
(26, "2021-07-01 00:00:02.000");

Affected Rows: 3

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

-- this is expected to be the same as above("2") since the new `input_basic` table
-- have different table id, so is a different table
SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 2 |
+----------+

DROP FLOW test_wildcard_basic;

Affected Rows: 0

-- recreate flow so that it use new table id
CREATE FLOW test_wildcard_basic sink TO out_basic AS
SELECT
COUNT(*) as wildcard
FROM
input_basic;

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500"),
(25, "2021-07-01 00:00:01.700");

Affected Rows: 3

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

-- 3 is also expected, since flow don't have persisent state
SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 3 |
+----------+

DROP TABLE input_basic;

Affected Rows: 0

DROP FLOW test_wildcard_basic;

Affected Rows: 0

DROP TABLE out_basic;

Affected Rows: 0

CREATE TABLE input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);

Affected Rows: 0

CREATE FLOW test_wildcard_basic sink TO out_basic AS
SELECT
COUNT(*) as wildcard
FROM
input_basic;

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500");

Affected Rows: 2

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 2 |
+----------+

DROP FLOW test_wildcard_basic;

Affected Rows: 0

DROP TABLE out_basic;

Affected Rows: 0

CREATE FLOW test_wildcard_basic sink TO out_basic AS
SELECT
COUNT(*) as wildcard
FROM
input_basic;

Affected Rows: 0

-- SQLNESS ARG restart=true
INSERT INTO
input_basic
VALUES
(23, "2021-07-01 00:00:01.000"),
(24, "2021-07-01 00:00:01.500"),
(25, "2021-07-01 00:00:01.700");

Affected Rows: 3

-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
ADMIN FLUSH_FLOW('test_wildcard_basic');

+-----------------------------------------+
| ADMIN FLUSH_FLOW('test_wildcard_basic') |
+-----------------------------------------+
| FLOW_FLUSHED |
+-----------------------------------------+

SELECT wildcard FROM out_basic;

+----------+
| wildcard |
+----------+
| 3 |
+----------+

Loading

0 comments on commit 7ae2e11

Please sign in to comment.