Skip to main content

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