Add use_tls option for interop tests
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user