Skip to content

Commit

Permalink
Implement stop/pause/resume in client code, add test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Oct 21, 2024
1 parent 2bac7b3 commit cf9df3c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
30 changes: 24 additions & 6 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,32 @@ impl AdminClient {
let _response = self.connect_to().await?.start_application(request).await?;
Ok(())
}
pub async fn stop(&self, _app: String) -> anyhow::Result<()> {
todo!();
pub async fn stop(&self, app_name: String) -> anyhow::Result<()> {
let request = pb::admin::ApplicationRequest {
app_name,
vm_name: None,
args: Vec::new(),
};
let _response = self.connect_to().await?.stop_application(request).await?;
Ok(())
}
pub async fn pause(&self, _app: String) -> anyhow::Result<()> {
todo!();
pub async fn pause(&self, app_name: String) -> anyhow::Result<()> {
let request = pb::admin::ApplicationRequest {
app_name,
vm_name: None,
args: Vec::new(),
};
let _response = self.connect_to().await?.pause_application(request).await?;
Ok(())
}
pub async fn resume(&self, _app: String) -> anyhow::Result<()> {
todo!();
pub async fn resume(&self, app_name: String) -> anyhow::Result<()> {
let request = pb::admin::ApplicationRequest {
app_name,
vm_name: None,
args: Vec::new(),
};
let _response = self.connect_to().await?.resume_application(request).await?;
Ok(())
}
pub async fn reboot(&self) -> anyhow::Result<()> {
let request = pb::admin::Empty {};
Expand Down
5 changes: 5 additions & 0 deletions nixos/tests/admin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ in
print(hostvm.succeed("${cli} --addr ${nodes.adminvm.config.givc.admin.addr} --port ${nodes.adminvm.config.givc.admin.port} --cacert ${nodes.hostvm.givc.host.tls.caCertPath} --cert ${nodes.hostvm.givc.host.tls.certPath} --key ${nodes.hostvm.givc.host.tls.keyPath} ${if tls then "" else "--notls"} --name ${nodes.adminvm.config.givc.admin.name} start --vm chromium-vm foot"))
wait_for_window("ghaf@appvm")
with subtest("stop application"):
appvm.succeed("pgrep foot")
print(hostvm.succeed("${cli} --addr ${nodes.adminvm.config.givc.admin.addr} --port ${nodes.adminvm.config.givc.admin.port} --cacert ${nodes.hostvm.givc.host.tls.caCertPath} --cert ${nodes.hostvm.givc.host.tls.certPath} --key ${nodes.hostvm.givc.host.tls.keyPath} ${if tls then "" else "--notls"} --name ${nodes.adminvm.config.givc.admin.name} stop [email protected]"))
appvm.fail("pgrep foot")
with subtest("clear exit and restart"):
print(hostvm.succeed("${cli} --addr ${nodes.adminvm.config.givc.admin.addr} --port ${nodes.adminvm.config.givc.admin.port} --cacert ${nodes.hostvm.givc.host.tls.caCertPath} --cert ${nodes.hostvm.givc.host.tls.certPath} --key ${nodes.hostvm.givc.host.tls.keyPath} ${if tls then "" else "--notls"} --name ${nodes.adminvm.config.givc.admin.name} start --vm chromium-vm clearexit"))
time.sleep(20) # Give few seconds to application to spin up, exit, then start it again
Expand Down

0 comments on commit cf9df3c

Please sign in to comment.