Accountant: Inventar, where, Checkmk, Abrechnung
This commit is contained in:
1 parent
9f16148cde
commit
dd93277750
59 files changed
+7522
-113
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"sultan/pkg/docker"
|
||||
"sultan/pkg/registry"
|
||||
@@ -38,6 +39,7 @@ func TestWorkloads_TranslatesPublishedPort(t *testing.T) {
|
||||
"traefik.http.routers.wp.rule": "Host(`kunde.de`)",
|
||||
"traefik.http.services.wp.loadbalancer.server.port": "8081",
|
||||
},
|
||||
Meta: ®istry.WorkloadMeta{State: "running"},
|
||||
}}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Workloads =\n%+v\nerwartet\n%+v", got, want)
|
||||
@@ -220,3 +222,39 @@ func TestWorkloads_RunningWinsOverStopped(t *testing.T) {
|
||||
t.Errorf("ohne Überschneidung: got=%+v down=%v", got, down)
|
||||
}
|
||||
}
|
||||
|
||||
// Compose-Projekt, -Verzeichnis, Zustand, Startzeit und Health kommen
|
||||
// automatisch aus Docker – ohne zusätzliche Labels.
|
||||
func TestWorkloads_Meta(t *testing.T) {
|
||||
started := time.Date(2026, 10, 16, 8, 15, 30, 0, time.UTC)
|
||||
labels := wpLabels()
|
||||
labels["com.docker.compose.project"] = "kunde-a"
|
||||
labels["com.docker.compose.service"] = "wordpress"
|
||||
labels["com.docker.compose.project.working_dir"] = "/srv/kunde-a"
|
||||
compose := ctr("kunde-a-wordpress-1", labels, pub(80, 8081))
|
||||
compose.StartedAt = started
|
||||
compose.Health = "healthy"
|
||||
|
||||
plain := ctr("solo", map[string]string{
|
||||
"traefik.enable": "true",
|
||||
"traefik.http.routers.so.rule": "Host(`solo.kunde.de`)",
|
||||
}, pub(80, 8082))
|
||||
plain.State = "exited"
|
||||
|
||||
got, _, warnings := Workloads([]docker.Container{compose, plain}, "100.64.0.42")
|
||||
if len(warnings) != 0 || len(got) != 2 {
|
||||
t.Fatalf("Workloads = %+v, Warnungen %v", got, warnings)
|
||||
}
|
||||
want := map[string]*registry.WorkloadMeta{
|
||||
"kunde-a-wordpress-1": {
|
||||
ComposeProject: "kunde-a", ComposeService: "wordpress", ComposeDir: "/srv/kunde-a",
|
||||
State: "running", StartedAt: started, Health: "healthy",
|
||||
},
|
||||
"solo": {State: "exited"},
|
||||
}
|
||||
for _, w := range got {
|
||||
if !reflect.DeepEqual(w.Meta, want[w.Name]) {
|
||||
t.Errorf("%s: Meta = %+v, erwartet %+v", w.Name, w.Meta, want[w.Name])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user