Skip to content

Commit

Permalink
[wip] remove services table
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Feb 9, 2024
1 parent 05065b2 commit 9a3f15d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 254 deletions.
125 changes: 0 additions & 125 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ mod region;
mod region_snapshot;
mod role;
mod saga;
mod service;
mod silo;
mod silo_group;
mod silo_user;
Expand Down Expand Up @@ -1424,130 +1423,6 @@ mod test {
logctx.cleanup_successful();
}

#[tokio::test]
async fn test_service_upsert_and_list() {
let logctx = dev::test_setup_log("test_service_upsert_and_list");
let mut db = test_setup_database(&logctx.log).await;
let (opctx, datastore) = datastore_test(&logctx, &db).await;

// Create a sled on which the service should exist.
let sled_id = create_test_sled(&datastore).await;

// Create a few new service to exist on this sled.
let service1_id =
"ab7bd7fd-7c37-48ab-a84a-9c09a90c4c7f".parse().unwrap();
let addr = SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0);
let kind = ServiceKind::Nexus;

let service1 =
Service::new(service1_id, sled_id, Some(service1_id), addr, kind);
let result =
datastore.service_upsert(&opctx, service1.clone()).await.unwrap();
assert_eq!(service1.id(), result.id());
assert_eq!(service1.ip, result.ip);
assert_eq!(service1.kind, result.kind);

let service2_id =
"fe5b6e3d-dfee-47b4-8719-c54f78912c0b".parse().unwrap();
let service2 = Service::new(service2_id, sled_id, None, addr, kind);
let result =
datastore.service_upsert(&opctx, service2.clone()).await.unwrap();
assert_eq!(service2.id(), result.id());
assert_eq!(service2.ip, result.ip);
assert_eq!(service2.kind, result.kind);

let service3_id = Uuid::new_v4();
let kind = ServiceKind::Oximeter;
let service3 = Service::new(
service3_id,
sled_id,
Some(Uuid::new_v4()),
addr,
kind,
);
let result =
datastore.service_upsert(&opctx, service3.clone()).await.unwrap();
assert_eq!(service3.id(), result.id());
assert_eq!(service3.ip, result.ip);
assert_eq!(service3.kind, result.kind);

// Try listing services of one kind.
let services = datastore
.services_list_kind(
&opctx,
ServiceKind::Nexus,
&DataPageParams {
marker: None,
direction: dropshot::PaginationOrder::Ascending,
limit: NonZeroU32::new(3).unwrap(),
},
)
.await
.unwrap();
assert_eq!(services[0].id(), service1.id());
assert_eq!(services[0].sled_id, service1.sled_id);
assert_eq!(services[0].zone_id, service1.zone_id);
assert_eq!(services[0].kind, service1.kind);
assert_eq!(services[1].id(), service2.id());
assert_eq!(services[1].sled_id, service2.sled_id);
assert_eq!(services[1].zone_id, service2.zone_id);
assert_eq!(services[1].kind, service2.kind);
assert_eq!(services.len(), 2);

// Try listing services of a different kind.
let services = datastore
.services_list_kind(
&opctx,
ServiceKind::Oximeter,
&DataPageParams {
marker: None,
direction: dropshot::PaginationOrder::Ascending,
limit: NonZeroU32::new(3).unwrap(),
},
)
.await
.unwrap();
assert_eq!(services[0].id(), service3.id());
assert_eq!(services[0].sled_id, service3.sled_id);
assert_eq!(services[0].zone_id, service3.zone_id);
assert_eq!(services[0].kind, service3.kind);
assert_eq!(services.len(), 1);

// Try listing services of a kind for which there are no services.
let services = datastore
.services_list_kind(
&opctx,
ServiceKind::Dendrite,
&DataPageParams {
marker: None,
direction: dropshot::PaginationOrder::Ascending,
limit: NonZeroU32::new(3).unwrap(),
},
)
.await
.unwrap();
assert!(services.is_empty());

// As a quick check, try supplying a marker.
let services = datastore
.services_list_kind(
&opctx,
ServiceKind::Nexus,
&DataPageParams {
marker: Some(&service1_id),
direction: dropshot::PaginationOrder::Ascending,
limit: NonZeroU32::new(3).unwrap(),
},
)
.await
.unwrap();
assert_eq!(services.len(), 1);
assert_eq!(services[0].id(), service2.id());

db.cleanup().await.unwrap();
logctx.cleanup_successful();
}

#[tokio::test]
async fn test_rack_initialize_is_idempotent() {
let logctx = dev::test_setup_log("test_rack_initialize_is_idempotent");
Expand Down
14 changes: 0 additions & 14 deletions nexus/db-queries/src/db/datastore/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,20 +442,6 @@ impl DataStore {
) -> Result<(), RackInitError> {
use internal_params::ServiceKind;

let service_db = db::model::Service::new(
service.service_id,
service.sled_id,
service.zone_id,
service.address,
service.kind.clone().into(),
);
self.service_upsert_conn(conn, service_db).await.map_err(
|e| match e.retryable() {
Retryable(e) => RackInitError::Retryable(e),
NotRetryable(e) => RackInitError::ServiceInsert(e.into()),
},
)?;

// For services with external connectivity, we record their
// explicit IP allocation and create a service NIC as well.
let service_ip_nic = match service.kind {
Expand Down
115 changes: 0 additions & 115 deletions nexus/db-queries/src/db/datastore/service.rs

This file was deleted.

0 comments on commit 9a3f15d

Please sign in to comment.