1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

enable running kaspersky tests

This commit is contained in:
Robin Appelman 2021-12-14 15:27:48 +01:00
commit abd37ff9a5
4 changed files with 21 additions and 8 deletions

View file

@ -157,7 +157,7 @@ pub async fn container_logs(docker: &Docker, container: &str, count: usize) -> R
pub struct ExitCode(i64);
impl ExitCode {
pub fn is_ok(&self) -> Result<()> {
pub fn to_result(&self) -> Result<()> {
match self.0 {
0 => Ok(()),
code => Err(Report::msg(format!(

View file

@ -294,7 +294,7 @@ async fn main() -> Result<()> {
Some(&mut out_buffer),
)
.await
.and_then(|c| c.is_ok())
.and_then(|c| c.to_result())
{
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
cloud.destroy(&mut docker).await?;
@ -321,7 +321,7 @@ async fn main() -> Result<()> {
Some(&mut out_buffer),
)
.await
.and_then(|c| c.is_ok())
.and_then(|c| c.to_result())
{
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
cloud.destroy(&mut docker).await?;
@ -334,7 +334,7 @@ async fn main() -> Result<()> {
Some(&mut out_buffer),
)
.await
.and_then(|c| c.is_ok())
.and_then(|c| c.to_result())
{
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
cloud.destroy(&mut docker).await?;

View file

@ -24,7 +24,9 @@ use tokio::time::{sleep, timeout};
pub trait ServiceTrait {
fn name(&self) -> &str;
fn env(&self) -> &[&str];
fn env(&self) -> &[&str] {
&[]
}
async fn spawn(
&self,

View file

@ -1,4 +1,5 @@
use crate::config::HazeConfig;
use crate::exec::exec;
use crate::image::{image_exists, pull_image};
use crate::service::ServiceTrait;
use crate::Result;
@ -7,6 +8,7 @@ use bollard::models::{EndpointSettings, HostConfig};
use bollard::Docker;
use color_eyre::eyre::eyre;
use maplit::hashmap;
use std::io::Stdout;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Kaspersky;
@ -18,7 +20,7 @@ impl ServiceTrait for Kaspersky {
}
fn env(&self) -> &[&str] {
&[]
&["KASPERSKY_HOST=kaspersky", "KASPERSKY_PORT=80"]
}
async fn spawn(
@ -61,8 +63,17 @@ impl ServiceTrait for Kaspersky {
Ok(id)
}
async fn is_healthy(&self, _docker: &Docker, _cloud_id: &str) -> Result<bool> {
Ok(true)
async fn is_healthy(&self, docker: &Docker, cloud_id: &str) -> Result<bool> {
let exit = exec(
docker,
self.container_name(cloud_id),
"root",
vec!["curl", "localhost/licenseinfo"],
vec![],
Option::<Stdout>::None,
)
.await?;
Ok(exit.to_result().is_ok())
}
fn container_name(&self, cloud_id: &str) -> String {