Add use_tls option for interop tests

This commit is contained in:
Lucio Franco
2019-09-02 18:20:22 -04:00
parent b82439af17
commit 6d09f4de25
5 changed files with 22 additions and 23 deletions
+3 -1
View File
@@ -21,5 +21,7 @@ jobs:
run: cargo check --all --all-features --all-targets
- name: Run tests
run: cargo test --all
- name: Run interop tests
- name: Run interop tests without tls
run: ./tonic-interop/test.sh
- name: Run interop tests with tls
run: ./tonic-interop/test.sh --use_tls
+1 -4
View File
@@ -7,10 +7,7 @@ pub mod hello_world {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let origin = vec![
http::Uri::from_static("http://[::1]:50051").into(),
];
let origin = vec![http::Uri::from_static("http://[::1]:50051").into()];
let svc = Channel::builder().balance_list(origin)?;
+12 -4
View File
@@ -1,5 +1,5 @@
use structopt::{clap::arg_enum, StructOpt};
use tonic::transport::Channel;
use tonic::transport::{Channel, Endpoint};
use tonic_interop::client;
#[derive(StructOpt)]
@@ -11,6 +11,9 @@ struct Opts {
raw(possible_values = r#"&Testcase::variants()"#)
)]
test_case: Vec<Testcase>,
#[structopt(long)]
use_tls: bool
}
#[tokio::main]
@@ -26,10 +29,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "localhost:10000";
let origin = http::Uri::from_shared(format!("http://{}", addr).into()).unwrap();
let endpoint = if matches.use_tls {
let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
Endpoint::with_pem(origin, ca, Some("foo.test.google.fr".into()))
} else {
Endpoint::from(origin)
};
let channel = Channel::builder()
// .tls(ca)
// .tls_override_domain("foo.test.google.fr")
.build(origin)?;
.connect(endpoint)?;
let mut client = client::TestClient::new(channel.clone());
let mut unimplemented_client = client::UnimplementedClient::new(channel);
+2 -2
View File
@@ -12,7 +12,7 @@ esac
SERVER="tonic-interop/bin/server_${OS}_amd64"
# run the test server
./"${SERVER}" &
./"${SERVER}" $1 &
SERVER_PID=$!
echo ":; started grpc-go test server."
@@ -23,4 +23,4 @@ trap 'echo ":; killing test server"; kill ${SERVER_PID};' EXIT
cargo run -p tonic-interop --bin client -- \
--test_case=empty_unary,large_unary,client_streaming,server_streaming,ping_pong,\
empty_stream,status_code_and_message,special_status_message,unimplemented_method,\
unimplemented_service,custom_metadata
unimplemented_service,custom_metadata $1
+4 -12
View File
@@ -74,18 +74,6 @@ impl Builder {
}
}
#[cfg(any(feature = "openssl-1", feature = "rustls"))]
pub fn tls(&mut self, ca: Vec<u8>) -> &mut Self {
self.ca = Some(ca);
self
}
#[cfg(any(feature = "openssl-1", feature = "rustls"))]
pub fn tls_override_domain<D: AsRef<str>>(&mut self, domain: D) -> &mut Self {
self.override_domain = Some(domain.as_ref().into());
self
}
pub fn buffer(&mut self, size: usize) -> &mut Self {
self.buffer_size = size;
self
@@ -110,6 +98,10 @@ impl Builder {
Ok(Channel { svc })
}
pub fn connect(&mut self, endpoint: Endpoint) -> Result<Channel, super::Error> {
self.balance_list(vec![endpoint])
}
pub fn build<T>(&mut self, uri: T) -> Result<Channel, super::Error>
where
Uri: http::HttpTryFrom<T>,