Skip to main content

flight_test_integration_client/
flight-test-integration-client.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
3// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
4
5//! The client side of the Arrow Flight integration tests.
6
7use arrow_integration_testing::flight_client_scenarios;
8use clap::Parser;
9type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
10type Result<T = (), E = Error> = std::result::Result<T, E>;
11
12#[derive(clap::ValueEnum, Debug, Clone)]
13enum Scenario {
14    Middleware,
15    #[clap(name = "auth:basic_proto")]
16    AuthBasicProto,
17}
18
19#[derive(Debug, Parser)]
20#[clap(author, version, about("rust flight-test-integration-client"), long_about = None)]
21struct Args {
22    #[clap(long, help = "host of flight server")]
23    host: String,
24    #[clap(long, help = "port of flight server")]
25    port: u16,
26    #[clap(
27        short,
28        long,
29        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"
30    )]
31    path: Option<String>,
32    #[clap(long, value_enum)]
33    scenario: Option<Scenario>,
34}
35
36#[tokio::main]
37async fn main() -> Result {
38    #[cfg(feature = "logging")]
39    tracing_subscriber::fmt::init();
40
41    let args = Args::parse();
42    let host = args.host;
43    let port = args.port;
44
45    match args.scenario {
46        Some(Scenario::Middleware) => {
47            flight_client_scenarios::middleware::run_scenario(&host, port).await?
48        }
49        Some(Scenario::AuthBasicProto) => {
50            flight_client_scenarios::auth_basic_proto::run_scenario(&host, port).await?
51        }
52        None => {
53            let path = args.path.expect("No path is given");
54            flight_client_scenarios::integration_test::run_scenario(&host, port, &path).await?;
55        }
56    }
57
58    Ok(())
59}