Skip to content

Commit

Permalink
security, server: fix running local test (tikv#12712)
Browse files Browse the repository at this point in the history
close tikv#12711

Signed-off-by: Yu Juncen <yujuncen@pingcap.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
  • Loading branch information
2 people authored and joccau committed Jun 11, 2022
1 parent 835436c commit 1698814
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
22 changes: 6 additions & 16 deletions components/backup-stream/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,26 +628,16 @@ mod test {
.global_progress_of_task("test_fatal_error"),
)
.unwrap();
assert_eq!(safepoints.len(), 4, "{:?}", safepoints);

assert!(
safepoints
.iter()
.take(3)
// They are choosing the lock safepoint, it must greater than the global checkpoint.
.all(|sp| { sp.safepoint.into_inner() >= checkpoint }),
safepoints.iter().any(|sp| {
sp.serivce.contains(&format!("{}", victim))
&& sp.ttl >= Duration::from_secs(60 * 60 * 24)
&& sp.safepoint.into_inner() == checkpoint
}),
"{:?}",
safepoints
);

let sp = &safepoints[3];
assert!(sp.serivce.contains(&format!("{}", victim)), "{:?}", sp);
assert!(sp.ttl >= Duration::from_secs(60 * 60 * 24), "{:?}", sp);
assert!(
sp.safepoint.into_inner() == checkpoint,
"{:?} vs {}",
sp,
checkpoint
);
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion components/security/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.0.1"
edition = "2018"
publish = false

[features]
tonic = ["dep:tonic"]

[dependencies]
collections = { path = "../collections" }
encryption = { path = "../encryption", default-features = false }
Expand All @@ -12,7 +15,7 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tikv_util = { path = "../tikv_util", default-features = false }
tonic = "0.5"
tonic = { version = "0.5", features = ["tls"], optional = true }

[dev-dependencies]
tempfile = "3.0"
2 changes: 2 additions & 0 deletions components/security/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use grpcio::{
RpcContext, RpcStatus, RpcStatusCode, ServerBuilder, ServerChecker, ServerCredentialsBuilder,
ServerCredentialsFetcher,
};
#[cfg(feature = "tonic")]
use tonic::transport::{channel::ClientTlsConfig, Certificate, Identity};

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)]
Expand Down Expand Up @@ -122,6 +123,7 @@ impl SecurityManager {
})
}

#[cfg(feature = "tonic")]
/// Make a tonic tls config via the config.
pub fn tonic_tls_config(&self) -> Option<ClientTlsConfig> {
let (ca, cert, key) = self.cfg.load_certs().unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion components/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ raftstore = { path = "../raftstore", default-features = false }
rand = "0.8"
resolved_ts = { path = "../../components/resolved_ts", default-features = false }
resource_metering = { path = "../resource_metering" }
security = { path = "../security", default-features = false }
security = { path = "../security", default-features = false, features = ["tonic"] }
serde_json = "1.0"
slog = { version = "2.3", features = ["max_level_trace", "release_max_level_debug"] }
slog-global = { version = "0.1", git = "https://github.com/breeswish/slog-global.git", rev = "d592f88e4dbba5eb439998463054f1a44fbf17b9" }
Expand Down

0 comments on commit 1698814

Please sign in to comment.