flight_test_integration_client/
flight-test-integration-client.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18// The unused_crate_dependencies lint does not work well for crates defining additional examples/bin targets
19#![allow(unused_crate_dependencies)]
20
21use arrow_integration_testing::flight_client_scenarios;
22use clap::Parser;
23type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
24type Result<T = (), E = Error> = std::result::Result<T, E>;
25
26#[derive(clap::ValueEnum, Debug, Clone)]
27enum Scenario {
28    Middleware,
29    #[clap(name = "auth:basic_proto")]
30    AuthBasicProto,
31}
32
33#[derive(Debug, Parser)]
34#[clap(author, version, about("rust flight-test-integration-client"), long_about = None)]
35struct Args {
36    #[clap(long, help = "host of flight server")]
37    host: String,
38    #[clap(long, help = "port of flight server")]
39    port: u16,
40    #[clap(
41        short,
42        long,
43        help = "path to the descriptor file, only used when scenario is not provided. See https://arrow.apache.org/docs/format/Integration.html#json-test-data-format"
44    )]
45    path: Option<String>,
46    #[clap(long, value_enum)]
47    scenario: Option<Scenario>,
48}
49
50#[tokio::main]
51async fn main() -> Result {
52    #[cfg(feature = "logging")]
53    tracing_subscriber::fmt::init();
54
55    let args = Args::parse();
56    let host = args.host;
57    let port = args.port;
58
59    match args.scenario {
60        Some(Scenario::Middleware) => {
61            flight_client_scenarios::middleware::run_scenario(&host, port).await?
62        }
63        Some(Scenario::AuthBasicProto) => {
64            flight_client_scenarios::auth_basic_proto::run_scenario(&host, port).await?
65        }
66        None => {
67            let path = args.path.expect("No path is given");
68            flight_client_scenarios::integration_test::run_scenario(&host, port, &path).await?;
69        }
70    }
71
72    Ok(())
73}