WP-12: contract and failing tests for the Kubernetes overview
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / ui (push) Has been cancelled

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Dennis Nemec
2026-09-02 22:29:36 +02:00
parent 684695e71a
commit 51ec216910
14 changed files with 922 additions and 0 deletions

View File

@ -399,3 +399,98 @@ impl HostUpdater for FakeUpdater {
Ok(())
}
}
use domain::cluster::{
ClusterOverview, Container, NodeInfo, VolumeClaim, Workload, WorkloadKind, WorkloadRef,
};
use domain::ports::ClusterGateway;
#[derive(Default)]
pub struct MemCluster {
pub actions: Mutex<Vec<String>>,
}
pub fn sample_overview() -> ClusterOverview {
ClusterOverview {
nodes: vec![NodeInfo {
name: "node1".into(),
version: "v1.32.13".into(),
ready: true,
os_image: "Debian GNU/Linux 12 (bookworm)".into(),
kernel: "6.1.0-42-amd64".into(),
container_runtime: "containerd://1.6.36".into(),
}],
namespaces: vec!["default".into(), "gitea".into()],
workloads: vec![
Workload {
namespace: "gitea".into(),
kind: WorkloadKind::Deployment,
name: "gitea".into(),
ready: 1,
desired: 1,
containers: vec![Container {
name: "gitea".into(),
image: "gitea/gitea:1.22.3".into(),
}],
},
Workload {
namespace: "gitea".into(),
kind: WorkloadKind::StatefulSet,
name: "gitea-postgresql".into(),
ready: 1,
desired: 1,
containers: vec![Container {
name: "postgresql".into(),
image: "bitnami/postgresql:16.4.0".into(),
}],
},
],
volume_claims: vec![VolumeClaim {
namespace: "gitea".into(),
name: "gitea-shared-storage".into(),
capacity: "10Gi".into(),
storage_class: "microk8s-hostpath".into(),
status: "Bound".into(),
}],
fetched_at: Utc::now(),
}
}
#[async_trait]
impl ClusterGateway for MemCluster {
async fn overview(&self) -> Result<ClusterOverview, DomainError> {
Ok(sample_overview())
}
async fn restart(&self, w: &WorkloadRef) -> Result<(), DomainError> {
self.actions.lock().unwrap().push(format!(
"restart {}/{}/{}",
w.namespace,
w.kind.as_str(),
w.name
));
Ok(())
}
async fn scale(&self, w: &WorkloadRef, replicas: i32) -> Result<(), DomainError> {
self.actions.lock().unwrap().push(format!(
"scale {}/{}/{} {replicas}",
w.namespace,
w.kind.as_str(),
w.name
));
Ok(())
}
async fn set_image(
&self,
w: &WorkloadRef,
container: &str,
image: &str,
) -> Result<(), DomainError> {
self.actions.lock().unwrap().push(format!(
"image {}/{}/{} {container}={image}",
w.namespace,
w.kind.as_str(),
w.name
));
Ok(())
}
}