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