diff --git a/nexus/tests/test_authn_http.rs b/nexus/tests/integration_tests/authn_http.rs similarity index 99% rename from nexus/tests/test_authn_http.rs rename to nexus/tests/integration_tests/authn_http.rs index 07adc70268e..4b417c3b959 100644 --- a/nexus/tests/test_authn_http.rs +++ b/nexus/tests/integration_tests/authn_http.rs @@ -8,7 +8,7 @@ // a lower-level interface, since our hyper Client will not allow us to send // such invalid requests. -pub mod common; +use super::common; use async_trait::async_trait; use chrono::{DateTime, Duration, Utc}; @@ -30,9 +30,6 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex}; use uuid::Uuid; -#[macro_use] -extern crate slog; - /// Tests authn::external::Authenticator with the "spoof" scheme allowed /// /// This does not use Nexus or any of the rest of Omicron. It sets up its own diff --git a/nexus/tests/test_authz.rs b/nexus/tests/integration_tests/authz.rs similarity index 99% rename from nexus/tests/test_authz.rs rename to nexus/tests/integration_tests/authz.rs index 928e83b9be5..4b876cf2c7d 100644 --- a/nexus/tests/test_authz.rs +++ b/nexus/tests/integration_tests/authz.rs @@ -6,7 +6,7 @@ use common::http_testing::RequestBuilder; use dropshot::HttpErrorResponseBody; -pub mod common; +use super::common; use common::test_setup; use http::method::Method; use http::StatusCode; @@ -14,8 +14,6 @@ use omicron_common::api::external::IdentityMetadataCreateParams; use omicron_nexus::authn::external::spoof::HTTP_HEADER_OXIDE_AUTHN_SPOOF; use omicron_nexus::external_api::params; -extern crate slog; - // TODO-coverage It would be nice to have tests that attempt to hit every // OpenAPI endpoint with valid arguments and: // (a) missing credentials (should all fail with 401, 403, or 404) diff --git a/nexus/tests/test_basic.rs b/nexus/tests/integration_tests/basic.rs similarity index 99% rename from nexus/tests/test_basic.rs rename to nexus/tests/integration_tests/basic.rs index 5254f3ba7ef..d704e45d2f9 100644 --- a/nexus/tests/test_basic.rs +++ b/nexus/tests/integration_tests/basic.rs @@ -27,7 +27,7 @@ use omicron_nexus::external_api::{ use serde::Serialize; use uuid::Uuid; -pub mod common; +use super::common; use common::http_testing::AuthnMode; use common::http_testing::NexusRequest; use common::http_testing::RequestBuilder; @@ -36,9 +36,6 @@ use common::resource_helpers::create_project; use common::start_sled_agent; use common::test_setup; -#[macro_use] -extern crate slog; - #[tokio::test] async fn test_basic_failures() { let testctx = test_setup("basic_failures").await; diff --git a/nexus/tests/test_commands.rs b/nexus/tests/integration_tests/commands.rs similarity index 98% rename from nexus/tests/test_commands.rs rename to nexus/tests/integration_tests/commands.rs index d169245de0b..1ccef96e289 100644 --- a/nexus/tests/test_commands.rs +++ b/nexus/tests/integration_tests/commands.rs @@ -101,7 +101,7 @@ fn run_command_with_arg(arg: &str) -> (String, String) { * purpose. However, it's not clear how to reliably locate it at runtime. * But we do know where it is at compile time, so we load it then. */ - let config = include_str!("../examples/config.toml"); + let config = include_str!("../../examples/config.toml"); let config_path = write_config(config); let exec = Exec::cmd(path_to_nexus()).arg(&config_path).arg(arg); let (exit_status, stdout_text, stderr_text) = run_command(exec); diff --git a/nexus/tests/test_console_api.rs b/nexus/tests/integration_tests/console_api.rs similarity index 99% rename from nexus/tests/test_console_api.rs rename to nexus/tests/integration_tests/console_api.rs index 0a66c7aa5fe..645a7aba8d5 100644 --- a/nexus/tests/test_console_api.rs +++ b/nexus/tests/integration_tests/console_api.rs @@ -7,15 +7,13 @@ use http::header::HeaderName; use http::{header, method::Method, StatusCode}; use std::env::current_dir; -pub mod common; +use super::common; use common::http_testing::{RequestBuilder, TestResponse}; use common::{load_test_config, test_setup, test_setup_with_config}; use omicron_common::api::external::IdentityMetadataCreateParams; use omicron_nexus::external_api::console_api::LoginParams; use omicron_nexus::external_api::params::OrganizationCreate; -extern crate slog; - #[tokio::test] async fn test_sessions() { let cptestctx = test_setup("test_sessions").await; diff --git a/nexus/tests/test_datasets.rs b/nexus/tests/integration_tests/datasets.rs similarity index 98% rename from nexus/tests/test_datasets.rs rename to nexus/tests/integration_tests/datasets.rs index 9d61323a10a..1d09a82bcb5 100644 --- a/nexus/tests/test_datasets.rs +++ b/nexus/tests/integration_tests/datasets.rs @@ -11,11 +11,9 @@ use omicron_nexus::internal_api::params::{ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use uuid::Uuid; -pub mod common; +use super::common; use common::{test_setup, SLED_AGENT_UUID}; -extern crate slog; - // Tests the "normal" case of dataset_put: inserting a dataset within a known // zpool. // diff --git a/nexus/tests/test_disks.rs b/nexus/tests/integration_tests/disks.rs similarity index 99% rename from nexus/tests/test_disks.rs rename to nexus/tests/integration_tests/disks.rs index e3067644a4e..701f0e18b2a 100644 --- a/nexus/tests/test_disks.rs +++ b/nexus/tests/integration_tests/disks.rs @@ -27,7 +27,7 @@ use dropshot::test_util::objects_post; use dropshot::test_util::read_json; use dropshot::test_util::ClientTestContext; -pub mod common; +use super::common; use common::http_testing::AuthnMode; use common::http_testing::NexusRequest; use common::http_testing::RequestBuilder; diff --git a/nexus/tests/test_instances.rs b/nexus/tests/integration_tests/instances.rs similarity index 99% rename from nexus/tests/test_instances.rs rename to nexus/tests/integration_tests/instances.rs index 305dc013846..444b84405a9 100644 --- a/nexus/tests/test_instances.rs +++ b/nexus/tests/integration_tests/instances.rs @@ -26,7 +26,7 @@ use dropshot::test_util::objects_post; use dropshot::test_util::read_json; use dropshot::test_util::ClientTestContext; -pub mod common; +use super::common; use common::identity_eq; use common::resource_helpers::{create_organization, create_project}; use common::test_setup; diff --git a/nexus/tests/integration_tests/mod.rs b/nexus/tests/integration_tests/mod.rs new file mode 100644 index 00000000000..064959920eb --- /dev/null +++ b/nexus/tests/integration_tests/mod.rs @@ -0,0 +1,25 @@ +//! Nexus integration tests +//! +//! See the driver in the parent directory for how and why this is structured +//! the way it is. + +use super::common; + +mod authn_http; +mod authz; +mod basic; +mod commands; +mod console_api; +mod datasets; +mod disks; +mod instances; +mod organizations; +mod oximeter; +mod projects; +mod router_routes; +mod users_builtin; +mod vpc_firewall; +mod vpc_routers; +mod vpc_subnets; +mod vpcs; +mod zpools; diff --git a/nexus/tests/test_organizations.rs b/nexus/tests/integration_tests/organizations.rs similarity index 98% rename from nexus/tests/test_organizations.rs rename to nexus/tests/integration_tests/organizations.rs index 96cbbeb518a..ce2c2793d40 100644 --- a/nexus/tests/test_organizations.rs +++ b/nexus/tests/integration_tests/organizations.rs @@ -6,7 +6,7 @@ use omicron_nexus::external_api::views::Organization; use dropshot::test_util::{object_delete, object_get}; -pub mod common; +use super::common; use common::resource_helpers::{ create_organization, create_project, objects_list_page_authz, }; @@ -14,8 +14,6 @@ use common::test_setup; use http::method::Method; use http::StatusCode; -extern crate slog; - #[tokio::test] async fn test_organizations() { let cptestctx = test_setup("test_organizations").await; diff --git a/nexus/tests/test_oximeter.rs b/nexus/tests/integration_tests/oximeter.rs similarity index 99% rename from nexus/tests/test_oximeter.rs rename to nexus/tests/integration_tests/oximeter.rs index 17b65e6d09c..a257502ba00 100644 --- a/nexus/tests/test_oximeter.rs +++ b/nexus/tests/integration_tests/oximeter.rs @@ -4,7 +4,7 @@ //! Integration tests for oximeter collectors and producers. -pub mod common; +use super::common; use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError}; use oximeter_db::DbWrite; diff --git a/nexus/tests/test_projects.rs b/nexus/tests/integration_tests/projects.rs similarity index 98% rename from nexus/tests/test_projects.rs rename to nexus/tests/integration_tests/projects.rs index 05288ee142e..cac538bca37 100644 --- a/nexus/tests/test_projects.rs +++ b/nexus/tests/integration_tests/projects.rs @@ -7,12 +7,10 @@ use omicron_nexus::external_api::views::Project; use dropshot::test_util::object_get; use dropshot::test_util::objects_list_page; -pub mod common; +use super::common; use common::resource_helpers::{create_organization, create_project}; use common::test_setup; -extern crate slog; - #[tokio::test] async fn test_projects() { let cptestctx = test_setup("test_projects").await; diff --git a/nexus/tests/test_router_routes.rs b/nexus/tests/integration_tests/router_routes.rs similarity index 99% rename from nexus/tests/test_router_routes.rs rename to nexus/tests/integration_tests/router_routes.rs index ec4859223ed..7e975b3f3b9 100644 --- a/nexus/tests/test_router_routes.rs +++ b/nexus/tests/integration_tests/router_routes.rs @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -pub mod common; +use super::common; use std::net::{IpAddr, Ipv4Addr}; use common::test_setup; @@ -21,8 +21,6 @@ use crate::common::resource_helpers::{ create_organization, create_project, create_router, create_vpc, }; -extern crate slog; - #[tokio::test] async fn test_router_routes() { let cptestctx = test_setup("test_vpc_routers").await; diff --git a/nexus/tests/test_users_builtin.rs b/nexus/tests/integration_tests/users_builtin.rs similarity index 98% rename from nexus/tests/test_users_builtin.rs rename to nexus/tests/integration_tests/users_builtin.rs index c75842ac07e..4a2205615ba 100644 --- a/nexus/tests/test_users_builtin.rs +++ b/nexus/tests/integration_tests/users_builtin.rs @@ -5,7 +5,7 @@ use http::Method; use http::StatusCode; use std::collections::BTreeMap; -pub mod common; +use super::common; use common::http_testing::AuthnMode; use common::http_testing::NexusRequest; use common::http_testing::RequestBuilder; @@ -13,8 +13,6 @@ use common::test_setup; use omicron_nexus::authn; use omicron_nexus::external_api::views::User; -extern crate slog; - #[tokio::test] async fn test_users_builtin() { let cptestctx = test_setup("test_users_builtin").await; diff --git a/nexus/tests/test_vpc_firewall.rs b/nexus/tests/integration_tests/vpc_firewall.rs similarity index 99% rename from nexus/tests/test_vpc_firewall.rs rename to nexus/tests/integration_tests/vpc_firewall.rs index e966c836bf7..078a36a1847 100644 --- a/nexus/tests/test_vpc_firewall.rs +++ b/nexus/tests/integration_tests/vpc_firewall.rs @@ -16,14 +16,12 @@ use std::convert::TryFrom; use dropshot::test_util::{object_delete, objects_list_page}; -pub mod common; +use super::common; use common::resource_helpers::{ create_organization, create_project, create_vpc, }; use common::test_setup; -extern crate slog; - #[tokio::test] async fn test_vpc_firewall() { let cptestctx = test_setup("test_vpc_firewall").await; diff --git a/nexus/tests/test_vpc_routers.rs b/nexus/tests/integration_tests/vpc_routers.rs similarity index 99% rename from nexus/tests/test_vpc_routers.rs rename to nexus/tests/integration_tests/vpc_routers.rs index 3538e4734c5..2942ecca1cc 100644 --- a/nexus/tests/test_vpc_routers.rs +++ b/nexus/tests/integration_tests/vpc_routers.rs @@ -14,15 +14,13 @@ use dropshot::test_util::object_get; use dropshot::test_util::objects_list_page; use dropshot::test_util::objects_post; -pub mod common; +use super::common; use common::identity_eq; use common::resource_helpers::{ create_organization, create_project, create_vpc, }; use common::test_setup; -extern crate slog; - #[tokio::test] async fn test_vpc_routers() { let cptestctx = test_setup("test_vpc_routers").await; diff --git a/nexus/tests/test_vpc_subnets.rs b/nexus/tests/integration_tests/vpc_subnets.rs similarity index 99% rename from nexus/tests/test_vpc_subnets.rs rename to nexus/tests/integration_tests/vpc_subnets.rs index 103c6f7b34c..f9db10f5c4c 100644 --- a/nexus/tests/test_vpc_subnets.rs +++ b/nexus/tests/integration_tests/vpc_subnets.rs @@ -16,15 +16,13 @@ use dropshot::test_util::objects_list_page; use dropshot::test_util::objects_post; use dropshot::test_util::ClientTestContext; -pub mod common; +use super::common; use common::identity_eq; use common::resource_helpers::{ create_organization, create_project, create_vpc, }; use common::test_setup; -extern crate slog; - #[tokio::test] async fn test_vpc_subnets() { let cptestctx = test_setup("test_vpc_subnets").await; diff --git a/nexus/tests/test_vpcs.rs b/nexus/tests/integration_tests/vpcs.rs similarity index 99% rename from nexus/tests/test_vpcs.rs rename to nexus/tests/integration_tests/vpcs.rs index 176be42cca2..20486972b09 100644 --- a/nexus/tests/test_vpcs.rs +++ b/nexus/tests/integration_tests/vpcs.rs @@ -11,15 +11,13 @@ use dropshot::test_util::object_get; use dropshot::test_util::objects_list_page; use dropshot::test_util::ClientTestContext; -pub mod common; +use super::common; use common::identity_eq; use common::resource_helpers::{ create_organization, create_project, create_vpc, create_vpc_with_error, }; use common::test_setup; -extern crate slog; - #[tokio::test] async fn test_vpcs() { let cptestctx = test_setup("test_vpcs").await; diff --git a/nexus/tests/test_zpools.rs b/nexus/tests/integration_tests/zpools.rs similarity index 98% rename from nexus/tests/test_zpools.rs rename to nexus/tests/integration_tests/zpools.rs index ae88667f42e..c22292d57d2 100644 --- a/nexus/tests/test_zpools.rs +++ b/nexus/tests/integration_tests/zpools.rs @@ -8,11 +8,9 @@ use omicron_common::api::external::ByteCount; use omicron_nexus::internal_api::params::ZpoolPutRequest; use uuid::Uuid; -pub mod common; +use super::common; use common::{test_setup, SLED_AGENT_UUID}; -extern crate slog; - // Tests the "normal" case of zpool_put: inserting a known Zpool. // // This will typically be invoked by the Sled Agent, after performing inventory. diff --git a/nexus/tests/test_all.rs b/nexus/tests/test_all.rs new file mode 100644 index 00000000000..7bd916f7879 --- /dev/null +++ b/nexus/tests/test_all.rs @@ -0,0 +1,20 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Integration test driver +//! +//! All integration tests are driven from this top-level integration test so +//! that we only have to build one target and so that Cargo can run the tests +//! concurrently. (Currently, Cargo runs separate integration tests +//! sequentially.) + +#[macro_use] +extern crate slog; + +pub mod common; + +// The individual tests themselves live in the "integration_tests" subdirectory. +// This extra level of indirection is annoying but we can't put them into the +// current directory because Cargo would try to build them individually. +mod integration_tests;