Skip to content

Commit

Permalink
tests: init utils
Browse files Browse the repository at this point in the history
  • Loading branch information
alissa-tung committed Feb 1, 2023
1 parent 31ee6a3 commit 6b7d7eb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
8 changes: 8 additions & 0 deletions src/hstreamdb/src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ impl FlushSettings {
pub fn builder() -> FlushSettingsBuilder {
default()
}

pub fn sync() -> Self {
Self {
len: 0,
size: 0,
deadline: None,
}
}
}

#[derive(Default)]
Expand Down
59 changes: 33 additions & 26 deletions src/hstreamdb/tests/tls_test.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
// use std::{env, fs};
use std::env;

// use hstreamdb::tls::{Certificate, ClientTlsConfig, Identity};
// use hstreamdb::{ChannelProviderSettings, Client};
use hstreamdb::tls::{Certificate, ClientTlsConfig, Identity};
use hstreamdb::{ChannelProviderSettings, Client};

// async fn _test_tls_impl() {
// env::set_var("RUST_LOG", "DEBUG");
// env_logger::init();
#[tokio::test(flavor = "multi_thread")]
async fn test_tls() {
if let Ok(_) = env::var("ENDPOINT") {
test_tls_impl().await
} else {
log::warn!("cloud endpoint is not presented");
log::warn!("ignore tls tests");
}
}

// let server_url: &str = todo!();
// let tls_dir: &str = todo!();
async fn test_tls_impl() {
env::set_var("RUST_LOG", "DEBUG");
env_logger::init();

// let ca_certificate =
// Certificate::from_pem(fs::read(format!("{tls_dir}/root_ca.crt")).unwrap());
// let cert = fs::read(format!("{tls_dir}/client.crt")).unwrap();
// let key = fs::read(format!("{tls_dir}/client.key")).unwrap();
let server_url: String = env::var("ENDPOINT").unwrap();
let ca_certificate: String = env::var("ROOT_CA").unwrap();
let cert = env::var("CLIENT_CRT").unwrap();
let key = env::var("CLIENT_KEY").unwrap();

// let client = Client::new(
// server_url,
// ChannelProviderSettings::builder()
// .set_tls_config(
// ClientTlsConfig::new()
// .ca_certificate(ca_certificate)
// .identity(Identity::from_pem(cert, key)),
// )
// .build(),
// )
// .await
// .unwrap();
let client = Client::new(
server_url,
ChannelProviderSettings::builder()
.set_tls_config(
ClientTlsConfig::new()
.ca_certificate(Certificate::from_pem(ca_certificate))
.identity(Identity::from_pem(cert, key)),
)
.build(),
)
.await
.unwrap();

// log::info!("{:?}", client.list_streams().await.unwrap());
// }
log::info!("{:?}", client.list_streams().await.unwrap());
}

0 comments on commit 6b7d7eb

Please sign in to comment.