Files
mesh-catalog/modules/minio/cmd/object-store/manifest_test.go
T
jschoubben 35ff67bda0
mesh/delivery-group group feat/774-l3-reland rejected: composed together: the checker's verdict at the members' heads (b48c90fea31f): integration: mesh-self-ch…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: integration: mesh-self-check/cmd/mesh-self-check.TestTheSelfCheckWholeRunsOnTheBus: the run answered {Run:doctor-1793351737-1 At:20…
Design 47's last milestones: the keeper, self-check, healers, hand-acts, provisioner, vault, artifact sweep, disk readings, credential forms (issues 774, 1952, 1953, 1954, 1955)
One commit with exactly the tree of the reviewed head 35b4509c0a, on main 12c2574c9d, so two compiled programs added and removed on the branch leave no trace in history (issue 1577).
2026-10-30 02:21:51 +01:00

108 lines
3.7 KiB
Go

package main
import (
"encoding/json"
"os"
"strings"
"testing"
)
func manifest(t *testing.T) map[string]any {
t.Helper()
raw, err := os.ReadFile("../../module.json")
if err != nil {
t.Fatal(err)
}
var m map[string]any
if err := json.Unmarshal(raw, &m); err != nil {
t.Fatal(err)
}
return m
}
// 1516/AC6: minio claims object-store (scope mesh) serving link, reads the placement seat's seat-holders, builds the Go
// bundle, and no tool named minio_presigned_url remains.
func TestManifestClaimsTheSeat(t *testing.T) {
m := manifest(t)
seats, _ := m["seats"].([]any)
if len(seats) != 1 || seats[0].(map[string]any)["name"] != "object-store" || seats[0].(map[string]any)["scope"] != "mesh" ||
len(seats[0].(map[string]any)["serves"].([]any)) != 1 || seats[0].(map[string]any)["serves"].([]any)[0] != "link" {
t.Fatalf("the seat object-store is not declared in seats (the mesh defines no seat a module does not declare): %v", seats)
}
claims := m["claims"].([]any)
if len(claims) != 1 {
t.Fatalf("claims: %v", claims)
}
c := claims[0].(map[string]any)
serves := c["serves"].([]any)
if c["name"] != "object-store" || c["scope"] != "mesh" || len(serves) != 1 || serves[0] != "link" {
t.Fatalf("claim: %v", c)
}
reads, _ := m["reads"].([]any)
if _, invokes := m["invokes"]; invokes || len(reads) != 1 || reads[0] != "mesh-delivery-assigner.seat-holders" {
t.Fatalf("reads %v and invokes %v: it reads the placement seat's holders and calls nothing", reads, m["invokes"])
}
var goBundle map[string]any
for _, a := range m["build"].(map[string]any)["artifacts"].([]any) {
if a.(map[string]any)["from"] == "cmd/object-store" {
goBundle = a.(map[string]any)
}
}
if goBundle == nil || goBundle["language"] != "go" || goBundle["kind"] != "bundle" {
t.Fatalf("no Go bundle for cmd/object-store: %v", goBundle)
}
env := goBundle["env"].(map[string]any)
for _, word := range []string{ConfigWord, LinksWord, ReceivesWord} {
if env[word] == nil {
t.Errorf("the Go bundle's env lacks %s", word)
}
}
for _, f := range []string{"../../tools/index.ts", "../../client.ts"} {
raw, err := os.ReadFile(f)
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(raw), "minio_presigned_url") || strings.Contains(string(raw), "presignedUrl") {
t.Errorf("%s still has the root-signed link", f)
}
}
}
// 1516/AC1: the file the Go tool reads is rendered from files/object-store.json with the facts the s3-bucket binding
// renders for a consumer: at is the providing machine's `at`, port the S3 endpoint's port (brother's files/store.json
// is the writer of that shape: scheme, at, port, region).
func TestStoreFileSaysWhatTheBindingSays(t *testing.T) {
raw, err := os.ReadFile("../../files/object-store.json")
if err != nil {
t.Fatal(err)
}
var f map[string]string
if err := json.Unmarshal(raw, &f); err != nil {
t.Fatal(err)
}
if f["at"] != "${machine:at}" || f["port"] != "${port:9000}" || f["scheme"] != "http" || f["region"] != "eu-west" {
t.Fatalf("object-store.json: %v", f)
}
brother, err := os.ReadFile("../../../brother/files/store.json")
if err != nil {
t.Fatal(err)
}
var b map[string]string
if err := json.Unmarshal(brother, &b); err != nil {
t.Fatal(err)
}
for _, k := range []string{"scheme", "at", "port", "region"} {
if _, ok := b[k]; !ok {
t.Errorf("brother's store.json has no %s: the shape moved", k)
}
if _, ok := f[k]; !ok {
t.Errorf("object-store.json has no %s", k)
}
}
// The same values: minio's serves.s3-bucket.port is the port its S3 listen declares.
m := manifest(t)
if port := m["serves"].(map[string]any)["s3-bucket"].(map[string]any)["port"]; port != float64(9000) {
t.Errorf("serves port %v", port)
}
}