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