Skip to content

Commit

Permalink
feat: rename greptime_region_peers to region_peers
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Apr 29, 2024
1 parent 852b8ee commit 6f68436
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/catalog/src/information_schema/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const INIT_CAPACITY: usize = 42;
/// The `CLUSTER_INFO` table provides information about the current topology of the cluster.
///
/// - `peer_id`: the peer server id.
/// - `peer_type`: the peer type, such as `datanode`, `frontend`, `metasrv` etc.
/// - `peer_type`: the peer type, such as `DATANODE`, `FRONTEND`, `METASRV` etc.
/// - `peer_addr`: the peer gRPC address.
/// - `version`: the build package version of the peer.
/// - `git_commit`: the build git commit hash of the peer.
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/src/information_schema/table_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ pub const GLOBAL_STATUS: &str = "global_status";
pub const SESSION_STATUS: &str = "session_status";
pub const RUNTIME_METRICS: &str = "runtime_metrics";
pub const PARTITIONS: &str = "partitions";
pub const REGION_PEERS: &str = "greptime_region_peers";
pub const REGION_PEERS: &str = "region_peers";
pub const TABLE_CONSTRAINTS: &str = "table_constraints";
pub const CLUSTER_INFO: &str = "cluster_info";
14 changes: 9 additions & 5 deletions tests-integration/tests/region_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,17 +854,21 @@ async fn find_region_distribution_by_sql(cluster: &GreptimeDbCluster) -> RegionD

let OutputData::Stream(stream) = run_sql(
&cluster.frontend,
&format!(r#"select b.peer_id as datanode_id,
&format!(
r#"select b.peer_id as datanode_id,
a.greptime_partition_id as region_id
from information_schema.partitions a left join information_schema.greptime_region_peers b
from information_schema.partitions a left join information_schema.region_peers b
on a.greptime_partition_id = b.region_id
where a.table_name='{TEST_TABLE_NAME}' order by datanode_id asc"#
),
query_ctx.clone(),
)
.await.unwrap().data else {
unreachable!();
};
.await
.unwrap()
.data
else {
unreachable!();
};

let recordbatches = RecordBatches::try_collect(stream).await.unwrap();

Expand Down
41 changes: 23 additions & 18 deletions tests/cases/distributed/information_schema/cluster_info.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,31 @@ DESC TABLE CLUSTER_INFO;
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO;
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO ORDER BY peer_type;

+---------+-----------+----------------+---------+------------+-------------------------+----------+
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time | uptime |
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time |uptime|
+---------+-----------+----------------+---------+------------+-------------------------+----------+
| 0 | METASRV | 127.0.0.1:3002 | UNKNOWN | UNKNOWN | | |
| 1 | DATANODE | 127.0.0.1:4101 |Version |Hash |Start_time|Uptime|
| 2 | DATANODE | 127.0.0.1:4102 |Version |Hash |Start_time|Uptime |
| 2 | DATANODE | 127.0.0.1:4102 |Version |Hash |Start_time|Uptime|
| 3 | DATANODE | 127.0.0.1:4103 |Version |Hash |Start_time|Uptime|
| 0 | FRONTEND | 127.0.0.1:4001 |Version |Hash |Start_time|Uptime |
| 0 | METASRV | 127.0.0.1:3002 | UNKNOWN | UNKNOWN | | |
+---------+-----------+----------------+---------+------------+-------------------------+----------+

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'METASRV';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'METASRV' ORDER BY peer_type;

+---------+-----------+----------------+---------+------------+------------+--------+
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time | uptime |
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time |uptime|
+---------+-----------+----------------+---------+------------+------------+--------+
| 0 | METASRV | 127.0.0.1:3002 | UNKNOWN | UNKNOWN | | |
+---------+-----------+----------------+---------+------------+------------+--------+
Expand All @@ -53,11 +55,12 @@ SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'METASRV';
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'FRONTEND';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'FRONTEND' ORDER BY peer_type;

+---------+-----------+----------------+---------+------------+-------------------------+--------+
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time | uptime |
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time |uptime|
+---------+-----------+----------------+---------+------------+-------------------------+--------+
| 0 | FRONTEND | 127.0.0.1:4001 |Version |Hash |Start_time|Uptime |
+---------+-----------+----------------+---------+------------+-------------------------+--------+
Expand All @@ -67,28 +70,30 @@ SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'FRONTEND';
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE != 'FRONTEND';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE != 'FRONTEND' ORDER BY peer_type;

+---------+-----------+----------------+---------+------------+-------------------------+----------+
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time | uptime |
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time |uptime|
+---------+-----------+----------------+---------+------------+-------------------------+----------+
| 0 | METASRV | 127.0.0.1:3002 | UNKNOWN | UNKNOWN | | |
| 1 | DATANODE | 127.0.0.1:4101 |Version |Hash |Start_time|Uptime|
| 2 | DATANODE | 127.0.0.1:4102 |Version |Hash |Start_time|Uptime|
| 3 | DATANODE | 127.0.0.1:4103 |Version |Hash |Start_time|Uptime|
| 0 | METASRV | 127.0.0.1:3002 | UNKNOWN | UNKNOWN | | |
+---------+-----------+----------------+---------+------------+-------------------------+----------+

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_ID > 1;
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_ID > 1 ORDER BY peer_type;

+---------+-----------+----------------+---------+------------+-------------------------+----------+
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time | uptime |
| peer_id | peer_type | peer_addr | node_version | git_commit | start_time |uptime|
+---------+-----------+----------------+---------+------------+-------------------------+----------+
| 2 | DATANODE | 127.0.0.1:4102 |Version |Hash |Start_time|Uptime|
| 3 | DATANODE | 127.0.0.1:4103 |Version |Hash |Start_time|Uptime|
Expand Down
25 changes: 15 additions & 10 deletions tests/cases/distributed/information_schema/cluster_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,44 @@ DESC TABLE CLUSTER_INFO;
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO;
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO ORDER BY peer_type;

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'METASRV';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'METASRV' ORDER BY peer_type;

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'FRONTEND';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE = 'FRONTEND' ORDER BY peer_type;

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE != 'FRONTEND';
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_TYPE != 'FRONTEND' ORDER BY peer_type;

-- SQLNESS REPLACE version node_version
-- SQLNESS REPLACE unknown UNKNOWN
-- SQLNESS REPLACE (\s\d\.\d\.\d\s) Version
-- SQLNESS REPLACE (\s[a-z0-9]{7}\s) Hash
-- SQLNESS REPLACE (\s[\-0-9T:\.]{23}\s) Start_time
-- SQLNESS REPLACE (\s(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_ID > 1;
-- SQLNESS REPLACE (\s+uptime\s+) uptime
-- SQLNESS REPLACE (\s+(\d+(s|ms|m)\s)+) Uptime
SELECT * FROM CLUSTER_INFO WHERE PEER_ID > 1 ORDER BY peer_type;

USE PUBLIC;
5 changes: 2 additions & 3 deletions tests/cases/standalone/common/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SELECT table_catalog, table_schema, table_name, partition_name, partition_expres

-- SQLNESS REPLACE (\d{13}) REGION_ID
-- SQLNESS REPLACE (\d{1}) PEER_ID
SELECT region_id, peer_id, is_leader, status FROM information_schema.greptime_region_peers ORDER BY peer_id;
SELECT region_id, peer_id, is_leader, status FROM information_schema.region_peers ORDER BY peer_id;

+---------------+---------+-----------+--------+
| region_id | peer_id | is_leader | status |
Expand Down Expand Up @@ -128,7 +128,7 @@ SELECT table_catalog, table_schema, table_name, partition_name, partition_expres

-- SQLNESS REPLACE (\d{13}) REGION_ID
-- SQLNESS REPLACE (\d{1}) PEER_ID
SELECT region_id, peer_id, is_leader, status FROM information_schema.greptime_region_peers ORDER BY peer_id;
SELECT region_id, peer_id, is_leader, status FROM information_schema.region_peers ORDER BY peer_id;

+---------------+---------+-----------+--------+
| region_id | peer_id | is_leader | status |
Expand All @@ -148,7 +148,6 @@ INSERT INTO my_table VALUES

Affected Rows: 8


SELECT * FROM my_table;

+------+---+-------------------------+
Expand Down
6 changes: 3 additions & 3 deletions tests/cases/standalone/common/partition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SELECT table_catalog, table_schema, table_name, partition_name, partition_expres

-- SQLNESS REPLACE (\d{13}) REGION_ID
-- SQLNESS REPLACE (\d{1}) PEER_ID
SELECT region_id, peer_id, is_leader, status FROM information_schema.greptime_region_peers ORDER BY peer_id;
SELECT region_id, peer_id, is_leader, status FROM information_schema.region_peers ORDER BY peer_id;

INSERT INTO my_table VALUES
(100, 'a', 1),
Expand Down Expand Up @@ -54,7 +54,7 @@ SELECT table_catalog, table_schema, table_name, partition_name, partition_expres

-- SQLNESS REPLACE (\d{13}) REGION_ID
-- SQLNESS REPLACE (\d{1}) PEER_ID
SELECT region_id, peer_id, is_leader, status FROM information_schema.greptime_region_peers ORDER BY peer_id;
SELECT region_id, peer_id, is_leader, status FROM information_schema.region_peers ORDER BY peer_id;

INSERT INTO my_table VALUES
(100, 'a', 1),
Expand All @@ -65,7 +65,7 @@ INSERT INTO my_table VALUES
(2100, 'f', 6),
(2200, 'g', 7),
(2400, 'h', 8);

SELECT * FROM my_table;

DROP TABLE my_table;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ show tables;
| build_info |
| character_sets |
| check_constraints |
| cluster_info |
| collation_character_set_applicability |
| collations |
| column_privileges |
Expand All @@ -29,13 +30,13 @@ show tables;
| events |
| files |
| global_status |
| greptime_region_peers |
| key_column_usage |
| optimizer_trace |
| parameters |
| partitions |
| profiling |
| referential_constraints |
| region_peers |
| routines |
| runtime_metrics |
| schema_privileges |
Expand Down
Loading

0 comments on commit 6f68436

Please sign in to comment.