Skip to content

Commit

Permalink
[1/n] [dropshot] combine integration tests into one binary (#1170)
Browse files Browse the repository at this point in the history
This is a pattern commonly used by us and speeds up compile times, since
there's only one test binary to link.
  • Loading branch information
sunshowers authored Nov 15, 2024
1 parent 8b0bff4 commit 403c4b9
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use std::sync::atomic::{AtomicU16, Ordering};
use tempfile::NamedTempFile;
use tokio::sync::mpsc;

pub mod common;
use common::create_log_context;
use crate::common::{self, create_log_context};

// Bad values for "bind_address"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::WebSocketStream;
use uuid::Uuid;

extern crate slog;
use crate::common;

pub mod common;
extern crate slog;

fn demo_api() -> ApiDescription<usize> {
let mut api = ApiDescription::<usize>::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use http::{Method, Response, StatusCode};
use std::time::Duration;
use tokio::sync::mpsc;

pub mod common;
use crate::common;

struct Context {
endpoint_started_tx: mpsc::UnboundedSender<()>,
Expand Down
26 changes: 26 additions & 0 deletions dropshot/tests/integration-tests/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 Oxide Computer Company

//! Integration tests for Dropshot.
//!
//! These are all combined into the same file to ensure that a single binary is
//! generated, speeding up link times.

#[macro_use]
extern crate slog;
#[macro_use]
extern crate lazy_static;

mod api_trait;
mod common;
mod config;
mod demo;
mod detached_shutdown;
mod multipart;
mod openapi;
mod pagination;
mod pagination_schema;
mod path_names;
mod starter;
mod streaming;
mod tls;
mod versions;
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use dropshot::{
};
use http::{Method, Response, StatusCode};

extern crate slog;
use crate::common;

pub mod common;
extern crate slog;

fn api() -> ApiDescription<usize> {
let mut api = ApiDescription::new();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ use subprocess::NullFile;
use subprocess::Popen;
use uuid::Uuid;

#[macro_use]
extern crate slog;
#[macro_use]
extern crate lazy_static;

pub mod common;
use crate::common;

// Common helpers

Expand Down Expand Up @@ -571,7 +566,7 @@ lazy_static! {
}

fn make_word_list() -> BTreeSet<String> {
let word_list = include_str!("wordlist.txt");
let word_list = include_str!("../wordlist.txt");
word_list.lines().map(|s| s.to_string()).collect()
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
//! Quick check that the "legacy" HttpServerStarter::new() and
//! HttpServerStarter::new_with_tls() interfaces work.

pub mod common;

use common::create_log_context;
use dropshot::endpoint;
use dropshot::test_util::read_json;
use dropshot::test_util::ClientTestContext;
Expand All @@ -17,6 +14,9 @@ use dropshot::HttpResponseOk;
use dropshot::HttpServerStarter;
use dropshot::RequestContext;

use crate::common;
use crate::common::create_log_context;

extern crate slog;

/// Test starting a server with `HttpServerStarter::new()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use http::{Method, Response, StatusCode};
use http_body_util::BodyExt;
use tokio::io::{AsyncSeekExt, AsyncWriteExt};

extern crate slog;
use crate::common;

pub mod common;
extern crate slog;

fn api() -> ApiDescription<usize> {
let mut api = ApiDescription::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;

pub mod common;
use common::create_log_context;

use crate::common::generate_tls_key;
use crate::common::{self, create_log_context, generate_tls_key};

/// See rustls::client::ServerCertVerifier::verify_server_cert for argument
/// meanings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::Deserialize;
use serde::Serialize;
use std::io::Cursor;

pub mod common;
use crate::common;

const VERSION_HEADER_NAME: &str = "dropshot-test-version";
const HANDLER1_MSG: &str = "handler1";
Expand Down

0 comments on commit 403c4b9

Please sign in to comment.