-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddbd0ab
commit 156e7bc
Showing
26 changed files
with
400 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::fs; | ||
use std::path::Path; | ||
|
||
use serde::Serialize; | ||
use strum::{Display, EnumString}; | ||
use tinytemplate::TinyTemplate; | ||
|
||
use crate::find_workspace_path; | ||
|
||
#[derive(EnumString, Display)] | ||
#[strum(serialize_all = "lowercase")] | ||
pub enum ConfigTemplate { | ||
Datanode, | ||
Metasrv, | ||
Standalone, | ||
} | ||
|
||
impl ConfigTemplate { | ||
fn render(&self, config_values: ConfigValues) -> String { | ||
let template_name = self.to_string(); | ||
|
||
let template = fs::read_to_string(find_workspace_path(&format!( | ||
"/src/common/test-util/conf/{template_name}-test.toml.template" | ||
))) | ||
.unwrap(); | ||
|
||
let mut tt = TinyTemplate::new(); | ||
tt.add_template(&template_name, &template).unwrap(); | ||
tt.render(&template_name, &config_values).unwrap() | ||
} | ||
} | ||
|
||
#[derive(Serialize, Default)] | ||
pub struct ConfigValues { | ||
pub wal_dir: String, | ||
pub data_home: String, | ||
pub procedure_dir: String, | ||
pub is_raft_engine: bool, | ||
pub kafka_wal_broker_endpoints: String, | ||
pub grpc_addr: String, | ||
} | ||
|
||
/// Generate a config file from template (determined by parameter `config_template`), with provided | ||
/// config values (in parameter `config_values`), and stores the file under the directory specified | ||
/// by parameter `target_dir`, returns the target file name. | ||
pub fn generate_config_file( | ||
config_template: ConfigTemplate, | ||
config_values: ConfigValues, | ||
target_dir: &Path, | ||
) -> String { | ||
let rendered = config_template.render(config_values); | ||
|
||
let target_file = format!( | ||
"{config_template}-{}.toml", | ||
common_time::util::current_time_millis() | ||
); | ||
fs::write(target_dir.join(&target_file), rendered).unwrap(); | ||
|
||
target_file | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::fmt; | ||
use std::fmt::Formatter; | ||
|
||
use client::error::Result; | ||
use common_error::ext::ErrorExt; | ||
use common_query::Output; | ||
use common_recordbatch::util::collect_batches; | ||
|
||
pub struct ResultDisplayer(pub Result<Output>); | ||
|
||
impl fmt::Display for ResultDisplayer { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
match &self.0 { | ||
Ok(result) => match result { | ||
Output::AffectedRows(rows) => { | ||
write!(f, "Affected Rows: {rows}") | ||
} | ||
Output::RecordBatches(recordbatches) => { | ||
let pretty = recordbatches.pretty_print().unwrap(); | ||
write!(f, "{pretty}") | ||
} | ||
Output::Stream(_) => unimplemented!(), | ||
}, | ||
Err(e) => { | ||
let status_code = e.status_code(); | ||
let root_cause = e.output_msg(); | ||
write!( | ||
f, | ||
"Error: {}({status_code}), {root_cause}", | ||
status_code as u32 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl ResultDisplayer { | ||
pub async fn display(self) -> String { | ||
match self.0 { | ||
Ok(Output::Stream(s)) => collect_batches(s).await.unwrap().pretty_print().unwrap(), | ||
_ => self.to_string(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "tests-compatibility" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
client.workspace = true | ||
common-telemetry.workspace = true | ||
common-test-util.workspace = true | ||
tokio.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# When compatibility tests failed: | ||
|
||
- Start an old version (or built from old source codes) GreptimeDB with its data home and WAL set to directory `tests-compatibility/data_home` and `tests-compatibility/data_home/wal/` respectively. | ||
- Using our CLI tool to [export](https://docs.greptime.com/user-guide/upgrade) the data. | ||
- Clear everything under `tests-compatibility/data_home/`. | ||
- Build a new GreptimeDB with your changes with the same data home and WAL dir config. | ||
- Using our CLI tool again to [import](https://docs.greptime.com/user-guide/upgrade) the data. | ||
- Rerun the compatibility test. If it passes, commit the data files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1fbbc371-ff9e-4404-9252-68d7f87cc9fb |
Binary file added
BIN
+31.3 KB
...me/data/greptime/public/1024/1024_0000000000/0ae10fd3-68d6-4929-858e-2a1c1442a091.parquet
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...ty/data_home/data/greptime/public/1024/1024_0000000000/manifest/00000000000000000000.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"actions":[{"Change":{"metadata":{"column_metadatas":[{"column_schema":{"name":"host","data_type":{"String":null},"is_nullable":true,"is_time_index":false,"default_constraint":null,"metadata":{}},"semantic_type":"Tag","column_id":0},{"column_schema":{"name":"ts","data_type":{"Timestamp":{"Millisecond":null}},"is_nullable":false,"is_time_index":false,"default_constraint":null,"metadata":{}},"semantic_type":"Timestamp","column_id":1},{"column_schema":{"name":"cpu","data_type":{"Float64":{}},"is_nullable":true,"is_time_index":false,"default_constraint":null,"metadata":{}},"semantic_type":"Field","column_id":2},{"column_schema":{"name":"memory","data_type":{"Float64":{}},"is_nullable":true,"is_time_index":false,"default_constraint":null,"metadata":{}},"semantic_type":"Field","column_id":3}],"primary_key":[0],"region_id":4398046511104,"schema_version":0}}}]} |
1 change: 1 addition & 0 deletions
1
...ty/data_home/data/greptime/public/1024/1024_0000000000/manifest/00000000000000000001.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"actions":[{"Edit":{"files_to_add":[{"region_id":4398046511104,"file_id":"0ae10fd3-68d6-4929-858e-2a1c1442a091","time_range":[{"value":1703576791287,"unit":"Millisecond"},{"value":1703577385721,"unit":"Millisecond"}],"level":0,"file_size":32062}],"files_to_remove":[],"compaction_time_window":null,"flushed_entry_id":18721,"flushed_sequence":18723}}]} |
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Oops, something went wrong.