Skip to content

Commit

Permalink
sqlness cases
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Dec 4, 2023
1 parent 13024a8 commit 4b288a8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/common/meta/src/rpc/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub struct DropTableTask {
pub schema: String,
pub table: String,
pub table_id: TableId,
#[serde(default)]
pub drop_if_exists: bool,
}

Expand Down
14 changes: 10 additions & 4 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## Sqlness manual

### Case file
Sqlness has two types of file

Sqlness has two types of file:

- `.sql`: test input, SQL only
- `.result`: expected test output, SQL and its results

Expand All @@ -14,17 +16,21 @@ check change logs to solve the problem.
You only need to write test SQL in `.sql` file, and run the test.

### Case organization
The root dir of input cases is `tests/cases`. It contains several sub-directories stand for different test

The root dir of input cases is `tests/cases`. It contains several subdirectories stand for different test
modes. E.g., `standalone/` contains all the tests to run under `greptimedb standalone start` mode.

Under the first level of sub-directory (e.g. the `cases/standalone`), you can organize your cases as you like.
Under the first level of subdirectory (e.g. the `cases/standalone`), you can organize your cases as you like.
Sqlness walks through every file recursively and runs them.

## Run the test
Unlike other tests, this harness is in a binary target form. You can run it with

Unlike other tests, this harness is in a binary target form. You can run it with:

```shell
cargo sqlness
```

It automatically finishes the following procedures: compile `GreptimeDB`, start it, grab tests and feed it to
the server, then collect and compare the results. You only need to check if the `.result` files are changed.
If not, congratulations, the test is passed 🥳!
22 changes: 22 additions & 0 deletions tests/cases/standalone/common/drop/drop_table.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
DROP TABLE IF EXISTS foo;

Affected Rows: 0

create table foo (
host string,
ts timestamp DEFAULT '2023-04-29 00:00:00+00:00',
cpu double default 0,
TIME INDEX (ts),
PRIMARY KEY(host)
) engine=mito with(regions=1);

Affected Rows: 0

DROP TABLE IF EXISTS foo;

Affected Rows: 0

DROP TABLE IF EXISTS foo;

Affected Rows: 0

13 changes: 13 additions & 0 deletions tests/cases/standalone/common/drop/drop_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DROP TABLE IF EXISTS foo;

create table foo (
host string,
ts timestamp DEFAULT '2023-04-29 00:00:00+00:00',
cpu double default 0,
TIME INDEX (ts),
PRIMARY KEY(host)
) engine=mito with(regions=1);

DROP TABLE IF EXISTS foo;

DROP TABLE IF EXISTS foo;

0 comments on commit 4b288a8

Please sign in to comment.