-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bug: complete restart projects on delete * tests: update to latest Remove failed test that can no longer be simulated and update a test that is now handled successfully. * refactor: allow provisioner to be mocked
- Loading branch information
Showing
10 changed files
with
130 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod gateway; | ||
pub mod provisioner; | ||
pub mod resource_recorder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use std::net::{Ipv4Addr, SocketAddr}; | ||
|
||
use async_trait::async_trait; | ||
use portpicker::pick_unused_port; | ||
use shuttle_proto::provisioner::{ | ||
provisioner_server::{Provisioner, ProvisionerServer}, | ||
DatabaseDeletionResponse, DatabaseRequest, DatabaseResponse, Ping, Pong, | ||
}; | ||
use tonic::transport::Server; | ||
|
||
struct ProvisionerMock; | ||
|
||
#[async_trait] | ||
impl Provisioner for ProvisionerMock { | ||
async fn provision_database( | ||
&self, | ||
_request: tonic::Request<DatabaseRequest>, | ||
) -> Result<tonic::Response<DatabaseResponse>, tonic::Status> { | ||
panic!("no run tests should request a db"); | ||
} | ||
|
||
async fn delete_database( | ||
&self, | ||
_request: tonic::Request<DatabaseRequest>, | ||
) -> Result<tonic::Response<DatabaseDeletionResponse>, tonic::Status> { | ||
panic!("no run tests should delete a db"); | ||
} | ||
|
||
async fn health_check( | ||
&self, | ||
_request: tonic::Request<Ping>, | ||
) -> Result<tonic::Response<Pong>, tonic::Status> { | ||
panic!("no run tests should do a health check"); | ||
} | ||
} | ||
|
||
/// Start a mocked provisioner and return the port it started on | ||
pub async fn get_mocked_provisioner() -> u16 { | ||
let provisioner = ProvisionerMock; | ||
|
||
let port = pick_unused_port().unwrap(); | ||
let provisioner_addr = SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), port); | ||
tokio::spawn(async move { | ||
Server::builder() | ||
.add_service(ProvisionerServer::new(provisioner)) | ||
.serve(provisioner_addr) | ||
.await | ||
}); | ||
|
||
port | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.