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
|
run: cargo check --all --all-features --all-targets
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --all
|
run: cargo test --all
|
||||||
- name: Run interop tests
|
- name: Run interop tests without tls
|
||||||
run: ./tonic-interop/test.sh
|
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]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let origin = vec![
|
let origin = vec![http::Uri::from_static("http://[::1]:50051").into()];
|
||||||
http::Uri::from_static("http://[::1]:50051").into(),
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
let svc = Channel::builder().balance_list(origin)?;
|
let svc = Channel::builder().balance_list(origin)?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use structopt::{clap::arg_enum, StructOpt};
|
use structopt::{clap::arg_enum, StructOpt};
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::{Channel, Endpoint};
|
||||||
use tonic_interop::client;
|
use tonic_interop::client;
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
@@ -11,6 +11,9 @@ struct Opts {
|
|||||||
raw(possible_values = r#"&Testcase::variants()"#)
|
raw(possible_values = r#"&Testcase::variants()"#)
|
||||||
)]
|
)]
|
||||||
test_case: Vec<Testcase>,
|
test_case: Vec<Testcase>,
|
||||||
|
|
||||||
|
#[structopt(long)]
|
||||||
|
use_tls: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -26,10 +29,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let addr = "localhost:10000";
|
let addr = "localhost:10000";
|
||||||
let origin = http::Uri::from_shared(format!("http://{}", addr).into()).unwrap();
|
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()
|
let channel = Channel::builder()
|
||||||
// .tls(ca)
|
.connect(endpoint)?;
|
||||||
// .tls_override_domain("foo.test.google.fr")
|
|
||||||
.build(origin)?;
|
|
||||||
|
|
||||||
let mut client = client::TestClient::new(channel.clone());
|
let mut client = client::TestClient::new(channel.clone());
|
||||||
let mut unimplemented_client = client::UnimplementedClient::new(channel);
|
let mut unimplemented_client = client::UnimplementedClient::new(channel);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ esac
|
|||||||
SERVER="tonic-interop/bin/server_${OS}_amd64"
|
SERVER="tonic-interop/bin/server_${OS}_amd64"
|
||||||
|
|
||||||
# run the test server
|
# run the test server
|
||||||
./"${SERVER}" &
|
./"${SERVER}" $1 &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
echo ":; started grpc-go test server."
|
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 -- \
|
cargo run -p tonic-interop --bin client -- \
|
||||||
--test_case=empty_unary,large_unary,client_streaming,server_streaming,ping_pong,\
|
--test_case=empty_unary,large_unary,client_streaming,server_streaming,ping_pong,\
|
||||||
empty_stream,status_code_and_message,special_status_message,unimplemented_method,\
|
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 {
|
pub fn buffer(&mut self, size: usize) -> &mut Self {
|
||||||
self.buffer_size = size;
|
self.buffer_size = size;
|
||||||
self
|
self
|
||||||
@@ -110,6 +98,10 @@ impl Builder {
|
|||||||
Ok(Channel { svc })
|
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>
|
pub fn build<T>(&mut self, uri: T) -> Result<Channel, super::Error>
|
||||||
where
|
where
|
||||||
Uri: http::HttpTryFrom<T>,
|
Uri: http::HttpTryFrom<T>,
|
||||||
|
|||||||
Reference in New Issue
Block a user