From e0d3bb3a52cdb1523720fbaa363f914e901e8545 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 8 Feb 2024 15:37:52 -0800 Subject: [PATCH] delete DnsWatcher test after a bunch of messing with it i made the executive decision to just get rid of that test. the test for DNS propagation exercises it, and it's harder to test now --- nexus/src/app/background/dns_servers.rs | 116 ------------------------ 1 file changed, 116 deletions(-) diff --git a/nexus/src/app/background/dns_servers.rs b/nexus/src/app/background/dns_servers.rs index e059fdcbf3..8f4cce4ee0 100644 --- a/nexus/src/app/background/dns_servers.rs +++ b/nexus/src/app/background/dns_servers.rs @@ -147,119 +147,3 @@ impl BackgroundTask for DnsServersWatcher { .boxed() } } - -#[cfg(test)] -mod test { - // use crate::app::background::common::BackgroundTask; - // use crate::app::background::dns_servers::DnsServersList; - // use crate::app::background::dns_servers::DnsServersWatcher; - // use crate::app::background::dns_servers::MAX_DNS_SERVERS; - // use assert_matches::assert_matches; - // use async_bb8_diesel::AsyncRunQueryDsl; - // use diesel::ExpressionMethods; - // use diesel::QueryDsl; - // use nexus_db_model::DnsGroup; - // use nexus_db_queries::context::OpContext; - // use nexus_db_queries::db::model::Service; - // use nexus_db_queries::db::model::ServiceKind; - use nexus_test_utils_macros::nexus_test; - // use std::net::Ipv6Addr; - // use std::net::SocketAddrV6; - // use uuid::Uuid; - - type ControlPlaneTestContext = - nexus_test_utils::ControlPlaneTestContext; - - #[nexus_test(server = crate::Server)] - async fn test_basic(cptestctx: &ControlPlaneTestContext) { - // let nexus = &cptestctx.server.apictx().nexus; - // let datastore = nexus.datastore(); - // let opctx = OpContext::for_tests( - // cptestctx.logctx.log.clone(), - // datastore.clone(), - // ); - - // // Verify the initial state. - // let mut task = - // DnsServersWatcher::new(datastore.clone(), DnsGroup::Internal); - // let watcher = task.watcher(); - // assert_matches!(*watcher.borrow(), None); - - // // The datastore from the ControlPlaneTestContext is initialized with - // // one DNS server. - // let _ = task.activate(&opctx).await; - // assert_matches!(*watcher.borrow(), Some(DnsServersList { - // ref addresses - // }) if addresses.len() == 1); - - // // If we add another server, we should see it. - // { - // use nexus_db_queries::db::schema::service::dsl; - // diesel::insert_into(dsl::service) - // .values(Service::new( - // Uuid::new_v4(), - // Uuid::new_v4(), - // Some(Uuid::new_v4()), - // SocketAddrV6::new(Ipv6Addr::LOCALHOST, 1, 0, 0), - // ServiceKind::InternalDns, - // )) - // .execute_async( - // &*datastore.pool_connection_for_tests().await.unwrap(), - // ) - // .await - // .unwrap(); - // } - - // let _ = task.activate(&opctx).await; - // assert_matches!(*watcher.borrow(), Some(DnsServersList { - // ref addresses - // }) if addresses.len() == 2); - - // // If we add MAX_DNS_SERVERS more servers, we should see - // // MAX_DNS_SERVERS. - // { - // use nexus_db_queries::db::schema::service::dsl; - // let new_services = (0..u16::try_from(MAX_DNS_SERVERS).unwrap()) - // .map(|i| { - // Service::new( - // Uuid::new_v4(), - // Uuid::new_v4(), - // Some(Uuid::new_v4()), - // SocketAddrV6::new(Ipv6Addr::LOCALHOST, i + 2, 0, 0), - // ServiceKind::InternalDns, - // ) - // }) - // .collect::>(); - - // diesel::insert_into(dsl::service) - // .values(new_services) - // .execute_async( - // &*datastore.pool_connection_for_tests().await.unwrap(), - // ) - // .await - // .unwrap(); - // } - - // let _ = task.activate(&opctx).await; - // assert_matches!(*watcher.borrow(), Some(DnsServersList { - // ref addresses - // }) if addresses.len() == MAX_DNS_SERVERS); - - // // Now delete all the servers and try again. - // { - // use nexus_db_queries::db::schema::service::dsl; - // diesel::delete( - // dsl::service.filter(dsl::kind.eq(ServiceKind::InternalDns)), - // ) - // .execute_async( - // &*datastore.pool_connection_for_tests().await.unwrap(), - // ) - // .await - // .unwrap(); - // } - // let _ = task.activate(&opctx).await; - // assert_matches!(*watcher.borrow(), Some(DnsServersList { - // ref addresses - // }) if addresses.is_empty()); - } -}