Crate relentless_grpc

Source
Expand description

GRPC implementation of comparison testing framework [relentless].

§Binary Usage

About the same as [relentless]

stepcommand
install binarycargo install --git https://github.com/hayas1/relentless relentless-grpc --features cli
install dev servercargo install --git https://github.com/hayas1/relentless relentless-grpc-dev-server
run commandrelentless-grpc -f compare.yaml

§Library Usage

§Install

Often used in dev-dependencies.

cargo add --dev --git https://github.com/hayas1/relentless relentless-grpc
[dev-dependencies]
relentless-grpc = { git = "https://github.com/hayas1/relentless" }

§Testing

use relentless::interface::{config::{Config, Format}, command::{Assault, Relentless}};
use relentless_grpc::{client::GrpcClient, command::GrpcAssault};
use relentless_grpc_dev_server::service::{
    counter::{pb::counter_server::CounterServer, CounterImpl},
    echo::{pb::echo_server::EchoServer, EchoImpl},
    greeter::{pb::greeter_server::GreeterServer, GreeterImpl},
};
use tonic::transport::Server;

let assault = GrpcAssault::new(Relentless {
    file: vec![], // files can be specified also
    ..Default::default()
});
let config = r#"
  name: basic grpc comparison test
  destinations:
    actual: http://localhost:50051
    expect: http://localhost:50051

  testcases:
  - target: greeter.Greeter/SayHello
    setting:
      request:
        descriptor:
          protos: [../dev/server/grpc/proto/greeter.proto]
          import_path: [../dev/server/grpc/proto]
        message:
          json:
            name: John Doe
"#;

let configs = vec![Config::read_str(config, Format::Yaml).unwrap()];
let destinations = assault.all_destinations(&configs);
let routes = Server::builder()
    .add_service(GreeterServer::new(GreeterImpl))
    .add_service(CounterServer::new(CounterImpl::default()))
    .add_service(EchoServer::new(EchoImpl))
    .into_service();
let service = GrpcClient::from_services(&destinations.into_iter().map(|d| (d, routes.clone())).collect()).await.unwrap();
let report = assault.assault_with(configs, service).await.unwrap();

assert!(assault.pass(&report));

Modules§