Skip to content

Commit

Permalink
delete DnsWatcher test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hawkw committed Feb 8, 2024
1 parent fce2953 commit e0d3bb3
Showing 1 changed file with 0 additions and 116 deletions.
116 changes: 0 additions & 116 deletions nexus/src/app/background/dns_servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::Server>;

#[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::<Vec<_>>();

// 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());
}
}

0 comments on commit e0d3bb3

Please sign in to comment.