Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Cover fleet torrent DHT fetch, cloud map/venue/meta IMDS mocks, S3 shard fetch order, zero-server policy polling, self-surgery reorder, contingency skip paths, epidemiology fix guards, and ssm_document deploy lane.
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package deploy
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseOrganizationalUnit(t *testing.T) {
|
|
if got := parseOrganizationalUnit("organizational_unit=ou/Batch\n"); got != "ou/Batch" {
|
|
t.Fatalf("got=%q", got)
|
|
}
|
|
if got := parseOrganizationalUnit("AETHERFORGE_OU=ou/GPU\n"); got != "ou/GPU" {
|
|
t.Fatalf("got=%q", got)
|
|
}
|
|
}
|
|
|
|
func TestReadCloudVenueProbeMockIMDS(t *testing.T) {
|
|
prev := ec2IMDSReadVenue
|
|
t.Cleanup(func() { ec2IMDSReadVenue = prev })
|
|
ec2IMDSReadVenue = func(ctx context.Context) (*CloudVenueProbe, error) {
|
|
return &CloudVenueProbe{
|
|
CloudProvider: "aws",
|
|
Environment: "prod",
|
|
Workload: "batch",
|
|
InstanceType: "m5.large",
|
|
InstanceLifecycle: "spot",
|
|
AvailabilityZone: "us-east-1a",
|
|
OrganizationalUnit: "ou/Batch",
|
|
EC2Tags: map[string]string{"Environment": "prod", "Workload": "batch"},
|
|
}, nil
|
|
}
|
|
probe := ReadCloudVenueProbe()
|
|
if probe == nil || probe.InstanceType != "m5.large" || probe.InstanceLifecycle != "spot" {
|
|
t.Fatalf("probe=%+v", probe)
|
|
}
|
|
if probe.Environment != "prod" || probe.Workload != "batch" {
|
|
t.Fatalf("env=%q workload=%q", probe.Environment, probe.Workload)
|
|
}
|
|
}
|
|
|
|
func TestReadCloudVenueProbeNonAWSReturnsNil(t *testing.T) {
|
|
prev := ec2IMDSReadVenue
|
|
t.Cleanup(func() { ec2IMDSReadVenue = prev })
|
|
ec2IMDSReadVenue = func(ctx context.Context) (*CloudVenueProbe, error) {
|
|
return nil, context.DeadlineExceeded
|
|
}
|
|
if ReadCloudVenueProbe() != nil {
|
|
t.Fatal("expected nil probe off AWS")
|
|
}
|
|
}
|