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:
parent
e40b2438fc
commit
abd37ff9a5
4 changed files with 21 additions and 8 deletions
|
|
@ -157,7 +157,7 @@ pub async fn container_logs(docker: &Docker, container: &str, count: usize) -> R
|
||||||
pub struct ExitCode(i64);
|
pub struct ExitCode(i64);
|
||||||
|
|
||||||
impl ExitCode {
|
impl ExitCode {
|
||||||
pub fn is_ok(&self) -> Result<()> {
|
pub fn to_result(&self) -> Result<()> {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
0 => Ok(()),
|
0 => Ok(()),
|
||||||
code => Err(Report::msg(format!(
|
code => Err(Report::msg(format!(
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ async fn main() -> Result<()> {
|
||||||
Some(&mut out_buffer),
|
Some(&mut out_buffer),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.and_then(|c| c.is_ok())
|
.and_then(|c| c.to_result())
|
||||||
{
|
{
|
||||||
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
||||||
cloud.destroy(&mut docker).await?;
|
cloud.destroy(&mut docker).await?;
|
||||||
|
|
@ -321,7 +321,7 @@ async fn main() -> Result<()> {
|
||||||
Some(&mut out_buffer),
|
Some(&mut out_buffer),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.and_then(|c| c.is_ok())
|
.and_then(|c| c.to_result())
|
||||||
{
|
{
|
||||||
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
||||||
cloud.destroy(&mut docker).await?;
|
cloud.destroy(&mut docker).await?;
|
||||||
|
|
@ -334,7 +334,7 @@ async fn main() -> Result<()> {
|
||||||
Some(&mut out_buffer),
|
Some(&mut out_buffer),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.and_then(|c| c.is_ok())
|
.and_then(|c| c.to_result())
|
||||||
{
|
{
|
||||||
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
eprintln!("{}", String::from_utf8_lossy(&out_buffer));
|
||||||
cloud.destroy(&mut docker).await?;
|
cloud.destroy(&mut docker).await?;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ use tokio::time::{sleep, timeout};
|
||||||
pub trait ServiceTrait {
|
pub trait ServiceTrait {
|
||||||
fn name(&self) -> &str;
|
fn name(&self) -> &str;
|
||||||
|
|
||||||
fn env(&self) -> &[&str];
|
fn env(&self) -> &[&str] {
|
||||||
|
&[]
|
||||||
|
}
|
||||||
|
|
||||||
async fn spawn(
|
async fn spawn(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::config::HazeConfig;
|
use crate::config::HazeConfig;
|
||||||
|
use crate::exec::exec;
|
||||||
use crate::image::{image_exists, pull_image};
|
use crate::image::{image_exists, pull_image};
|
||||||
use crate::service::ServiceTrait;
|
use crate::service::ServiceTrait;
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
@ -7,6 +8,7 @@ use bollard::models::{EndpointSettings, HostConfig};
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
|
use std::io::Stdout;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Kaspersky;
|
pub struct Kaspersky;
|
||||||
|
|
@ -18,7 +20,7 @@ impl ServiceTrait for Kaspersky {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn env(&self) -> &[&str] {
|
fn env(&self) -> &[&str] {
|
||||||
&[]
|
&["KASPERSKY_HOST=kaspersky", "KASPERSKY_PORT=80"]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn spawn(
|
async fn spawn(
|
||||||
|
|
@ -61,8 +63,17 @@ impl ServiceTrait for Kaspersky {
|
||||||
Ok(id)
|
Ok(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn is_healthy(&self, _docker: &Docker, _cloud_id: &str) -> Result<bool> {
|
async fn is_healthy(&self, docker: &Docker, cloud_id: &str) -> Result<bool> {
|
||||||
Ok(true)
|
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 {
|
fn container_name(&self, cloud_id: &str) -> String {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue