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