relentless_grpc/
lib.rs

1//! GRPC implementation of comparison testing framework [relentless].
2//!
3//! # Binary Usage
4//! About the same as [relentless]
5//! | step | command |
6//! | --- | --- |
7//! | install binary | `cargo install --git https://github.com/hayas1/relentless relentless-grpc --features cli` |
8//! | install dev server | `cargo install --git https://github.com/hayas1/relentless relentless-grpc-dev-server` |
9//! | run command | `relentless-grpc -f compare.yaml` |
10//!
11//! # Library Usage
12//! ## Install
13//! Often used in dev-dependencies.
14//! ```sh
15//! cargo add --dev --git https://github.com/hayas1/relentless relentless-grpc
16//! ```
17//! ```toml
18//! [dev-dependencies]
19//! relentless-grpc = { git = "https://github.com/hayas1/relentless" }
20//! ```
21//!
22//! ## Testing
23#![cfg_attr(
24    feature = "yaml",
25    doc = r##"
26 ```
27 # tokio_test::block_on(async {
28 use relentless::interface::{config::{Config, Format}, command::{Assault, Relentless}};
29 use relentless_grpc::{client::GrpcClient, command::GrpcAssault};
30 use relentless_grpc_dev_server::service::{
31     counter::{pb::counter_server::CounterServer, CounterImpl},
32     echo::{pb::echo_server::EchoServer, EchoImpl},
33     greeter::{pb::greeter_server::GreeterServer, GreeterImpl},
34 };
35 use tonic::service::Routes;
36
37 let assault = GrpcAssault::new(Relentless {
38     file: vec![], // files can be specified also
39     ..Default::default()
40 });
41 let config = r#"
42   name: basic grpc comparison test
43   destinations:
44     actual: http://localhost:50051
45     expect: http://localhost:50051
46
47   testcases:
48   - target: greeter.Greeter/SayHello
49     setting:
50       request:
51         descriptor:
52           protos: [../dev/server/grpc/proto/greeter.proto]
53           import_path: [../dev/server/grpc/proto]
54         message:
55           json:
56             name: John Doe
57 "#;
58
59 let configs = vec![Config::read_str(config, Format::Yaml).unwrap()];
60 let destinations = assault.all_destinations(&configs);
61 let mut builder = Routes::builder();
62 builder
63     .add_service(GreeterServer::new(GreeterImpl))
64     .add_service(CounterServer::new(CounterImpl::default()))
65     .add_service(EchoServer::new(EchoImpl));
66 let routes = builder.routes();
67 let service = GrpcClient::from_services(&destinations.into_iter().map(|d| (d, routes.clone())).collect()).await.unwrap();
68 let report = assault.assault_with(configs, service).await.unwrap();
69
70 assert!(assault.pass(&report));
71 # })
72```
73"##
74)]
75pub mod client;
76pub mod command;
77pub mod error;
78pub mod evaluate;
79pub mod factory;
80pub mod record;
81
82pub mod helper;