Skip to content
Snippets Groups Projects
Verified Commit 834ae611 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

feat: improve logging on configuration cache update

As a side effect we got rid of the environment variable in a unit
tests build. Now we rely of a feature "mock" for this purpose.
parent 727ad98a
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -38,3 +38,6 @@ crate-type = ["cdylib", "rlib"]
[[bench]]
name = "parse"
harness = false
[features]
mock = []
......@@ -13,19 +13,19 @@ endif
bench:
make clean
MOCK_DEC_NUMBER=1 cargo bench
cargo bench --features mock
bench_check:
make clean
MOCK_DEC_NUMBER=1 cargo bench --no-run
cargo bench --no-run --features mock
build:
make clean
MOCK_DEC_NUMBER=0 cargo build --release
cargo build --release
build_debug:
make clean
MOCK_DEC_NUMBER=0 cargo build
cargo build
build_integration:
make build
......@@ -60,7 +60,7 @@ run_integration:
test:
make clean
MOCK_DEC_NUMBER=1 cargo test
MOCK_DEC_NUMBER=1 cargo test --features mock
test_integration:
make build_integration
......
extern crate cc;
use std::env;
use std::path::Path;
use std::process::Command;
fn main() {
match env::var("MOCK_DEC_NUMBER") {
Ok(val) => {
if val == "1" {
// mock decNumber
} else {
return;
}
}
_ => return,
}
#[cfg(feature = "mock")]
{
extern crate cc;
use std::path::Path;
use std::process::Command;
// Mock Tarantool decNumber library for a `cargo test` build.
let litend = if cfg!(target_endian = "little") {
"1"
} else {
"0"
};
// Mock Tarantool decNumber library for a `cargo test` build.
let litend = if cfg!(target_endian = "little") {
"1"
} else {
"0"
};
// ../sbroad/target/debug/build/sbroad-703f9e463350cae9/build-script-build
let current_file = std::env::current_exe().unwrap();
let root: &Path = current_file
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap();
let tarantool = root.join("deps").join("tarantool");
let dec_number = tarantool.join("third_party").join("decNumber");
let msg_puck = tarantool.join("src").join("lib").join("msgpuck");
// ../sbroad/target/debug/build/sbroad-703f9e463350cae9/build-script-build
let current_file = std::env::current_exe().unwrap();
let root: &Path = current_file
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap();
let tarantool = root.join("deps").join("tarantool");
let dec_number = tarantool.join("third_party").join("decNumber");
let msg_puck = tarantool.join("src").join("lib").join("msgpuck");
// We need to configure Tarantool with cmake in order to generate all
// required headers for the further build of the decNumber mocking
// library (used in the unit tests).
//
// Mostly the problem is with `decimal.c` that depends on the `small`
// allocator requiring `trivia/config.h`.
Command::new("cmake")
.current_dir(tarantool.clone())
.arg(".")
.arg("-DCMAKE_BUILD_TYPE=Release")
.status()
.expect("failed to run cmake");
cc::Build::new()
.warnings(true)
.include(msg_puck.to_str().unwrap())
.file(msg_puck.join("hints.c").to_str().unwrap())
.define("MP_PROTO", Some("inline"))
.define("MP_IMPL", Some("inline"))
.compile("libmsgpuck.a");
cc::Build::new()
.warnings(true)
.include(dec_number.to_str().unwrap())
.include(msg_puck.to_str().unwrap())
.include(tarantool.join("third_party").to_str().unwrap())
.include(tarantool.join("src").to_str().unwrap())
.include(
tarantool
.join("src")
.join("lib")
.join("small")
.join("include"),
)
.include(
tarantool
.join("src")
.join("lib")
.join("small")
.join("third_party"),
)
.file(dec_number.join("decContext.c").to_str().unwrap())
.file(dec_number.join("decNumber.c").to_str().unwrap())
.file(dec_number.join("decPacked.c").to_str().unwrap())
.file(
tarantool
.join("src")
.join("lib")
.join("core")
.join("decimal.c")
.to_str()
.unwrap(),
)
.define("DECLITEND", Some(litend))
// Never define MP_LIBRARY as we need to inline functions from msgpuck.h
.define("MP_LIBRARY", None)
.compile("libdecNumber.a");
// We need to configure Tarantool with cmake in order to generate all
// required headers for the further build of the decNumber mocking
// library (used in the unit tests).
//
// Mostly the problem is with `decimal.c` that depends on the `small`
// allocator requiring `trivia/config.h`.
Command::new("cmake")
.current_dir(tarantool.clone())
.arg(".")
.arg("-DCMAKE_BUILD_TYPE=Release")
.status()
.expect("failed to run cmake");
cc::Build::new()
.warnings(true)
.include(msg_puck.to_str().unwrap())
.file(msg_puck.join("hints.c").to_str().unwrap())
.define("MP_PROTO", Some("inline"))
.define("MP_IMPL", Some("inline"))
.compile("libmsgpuck.a");
cc::Build::new()
.warnings(true)
.include(dec_number.to_str().unwrap())
.include(msg_puck.to_str().unwrap())
.include(tarantool.join("third_party").to_str().unwrap())
.include(tarantool.join("src").to_str().unwrap())
.include(
tarantool
.join("src")
.join("lib")
.join("small")
.join("include"),
)
.include(
tarantool
.join("src")
.join("lib")
.join("small")
.join("third_party"),
)
.file(dec_number.join("decContext.c").to_str().unwrap())
.file(dec_number.join("decNumber.c").to_str().unwrap())
.file(dec_number.join("decPacked.c").to_str().unwrap())
.file(
tarantool
.join("src")
.join("lib")
.join("core")
.join("decimal.c")
.to_str()
.unwrap(),
)
.define("DECLITEND", Some(litend))
// Never define MP_LIBRARY as we need to inline functions from msgpuck.h
.define("MP_LIBRARY", None)
.compile("libdecNumber.a");
}
}
......@@ -12,6 +12,9 @@ use crate::ir::relation::{Column, ColumnRole, Table, Type};
use self::yaml_rust::yaml;
#[cfg(not(feature = "mock"))]
use tarantool::log::{say, SayLevel};
/// Cluster metadata information
///
/// Information based on tarantool cartridge schema. Cache knows nothing about bucket distribution in the cluster,
......@@ -108,7 +111,19 @@ impl RouterConfiguration {
}
result
}
None => continue,
None => {
#[cfg(not(feature = "mock"))]
{
say(
SayLevel::Warn,
file!(),
line!().try_into().unwrap_or(0),
Option::from("configuration parsing"),
&format!("Skip space {}: fields not found.", current_space_name),
);
}
continue;
}
};
let keys: Vec<String> = match params["sharding_key"].as_vec() {
......@@ -117,13 +132,40 @@ impl RouterConfiguration {
for k in keys {
let key: &str = match k.as_str() {
Some(k) => k,
None => continue,
None => {
#[cfg(not(feature = "mock"))]
{
say(
SayLevel::Warn,
file!(),
line!().try_into().unwrap_or(0),
Option::from("configuration parsing"),
&format!(
"Skip space {}: failed to convert key {:?} to string.",
current_space_name, k
),
);
}
continue;
}
};
result.push(Self::to_name(key));
}
result
}
None => continue,
None => {
#[cfg(not(feature = "mock"))]
{
say(
SayLevel::Warn,
file!(),
line!().try_into().unwrap_or(0),
Option::from("configuration parsing"),
&format!("Skip space {}: keys not found.", current_space_name),
);
}
continue;
}
};
let table_name: String = RouterConfiguration::to_name(current_space_name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment