Skip to main content

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 client side of the Arrow Flight integration tests.
19
20// The unused_crate_dependencies lint does not work well for crates defining additional examples/bin targets
21#![allow(unused_crate_dependencies)]
22
23use arrow_integration_testing::flight_client_scenarios;
24use clap::Parser;
25type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
26type Result<T = (), E = Error> = std::result::Result<T, E>;
27
28#[derive(clap::ValueEnum, Debug, Clone)]
29enum Scenario {
30    Middleware,
31    #[clap(name = "auth:basic_proto")]
32    AuthBasicProto,
33}
34
35#[derive(Debug, Parser)]
36#[clap(author, version, about("rust flight-test-integration-client"), long_about = None)]
37struct Args {
38    #[clap(long, help = "host of flight server")]
39    host: String,
40    #[clap(long, help = "port of flight server")]
41    port: u16,
42    #[clap(
43        short,
44        long,
45        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"
46    )]
47    path: Option<String>,
48    #[clap(long, value_enum)]
49    scenario: Option<Scenario>,
50}
51
52#[tokio::main]
53async fn main() -> Result {
54    #[cfg(feature = "logging")]
55    tracing_subscriber::fmt::init();
56
57    let args = Args::parse();
58    let host = args.host;
59    let port = args.port;
60
61    match args.scenario {
62        Some(Scenario::Middleware) => {
63            flight_client_scenarios::middleware::run_scenario(&host, port).await?
64        }
65        Some(Scenario::AuthBasicProto) => {
66            flight_client_scenarios::auth_basic_proto::run_scenario(&host, port).await?
67        }
68        None => {
69            let path = args.path.expect("No path is given");
70            flight_client_scenarios::integration_test::run_scenario(&host, port, &path).await?;
71        }
72    }
73
74    Ok(())
75}