Add Cloud Map seeder discovery with VPC Lattice operator templates.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Agents poll AETHERFORGE_CLOUD_MAP_ENDPOINT to sync know_node gossip; deploy plans attach route_via DNS hints for standalone operator registries.
This commit is contained in:
43
agent/deploy/cloud_map_test.go
Normal file
43
agent/deploy/cloud_map_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFetchCloudMapRegistry(t *testing.T) {
|
||||
SetCloudMapHTTPGetForTest(func(url string) ([]byte, error) {
|
||||
return []byte(`{"namespace":"prod.local","service":"seeder","instances":[{"agent_id":"seed-a","dns_name":"seeder.svc.prod.local","healthy":true,"fetch_url":"http://10.0.1.50/manifest"}]}`), nil
|
||||
})
|
||||
defer SetCloudMapHTTPGetForTest(nil)
|
||||
doc, err := FetchCloudMapRegistry("http://registry.local/v1/seeder")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
records := CloudMapKnowNodeRecords(doc)
|
||||
if len(records) != 1 || records[0].TargetAgentID != "seed-a" {
|
||||
t.Fatalf("records=%+v", records)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppendSpreadRouteTelemetryIncludesRouteVia(t *testing.T) {
|
||||
got := appendSpreadRouteTelemetry("joined", &SpreadRouteHint{EgressAgentID: "egress-1", RouteVia: "seeder.svc.prod.local"})
|
||||
if got == "" || !strings.Contains(got, "route_via=seeder.svc.prod.local") {
|
||||
t.Fatalf("got=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudMapEndpointFromEnv(t *testing.T) {
|
||||
t.Setenv(cloudMapEnvEndpoint, "http://127.0.0.1:8080/registry.json")
|
||||
if got := CloudMapEndpoint(); got != "http://127.0.0.1:8080/registry.json" {
|
||||
t.Fatalf("got=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudMapEndpointUnset(t *testing.T) {
|
||||
_ = os.Unsetenv(cloudMapEnvEndpoint)
|
||||
if got := CloudMapEndpoint(); got != "" {
|
||||
t.Fatalf("got=%q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user