Skip to content

Commit

Permalink
Merge integration tests together (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Dec 9, 2021
1 parent 0e9e790 commit a628762
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
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;
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions nexus/tests/integration_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ 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,
};
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ 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;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions nexus/tests/test_all.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit a628762

Please sign in to comment.