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.
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
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)
|
|
}
|
|
}
|