You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package capability
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"g.luoli.live/root/virt/agent/internal/hypervisor"
|
|
)
|
|
|
|
func TestBackendProviderSeparatesAgentStartupScriptFromHostObservation(t *testing.T) {
|
|
caps := hypervisor.DefaultCapabilitySnapshot()
|
|
caps.Backend = "libvirt-domcapabilities"
|
|
caps.CloudInit = false
|
|
caps.StartupScript = false
|
|
snapshot := snapshotFromCapabilities("host-103", "v1", caps)
|
|
if snapshot.Features["cloud_init"] {
|
|
t.Fatal("cloud_init must remain the unproven host/guest observation")
|
|
}
|
|
for _, key := range []string{"startup_script", "startup_script_agent", "nocloud_seed_artifact"} {
|
|
if !snapshot.Features[key] {
|
|
t.Fatalf("feature %q = false, Agent artifact implementation should advertise it", key)
|
|
}
|
|
}
|
|
if snapshot.Features["startup_script_host"] {
|
|
t.Fatal("startup_script_host must preserve the false host observation")
|
|
}
|
|
}
|
|
|
|
func TestBackendProviderDoesNotUseStaticProviderForHostFeatures(t *testing.T) {
|
|
snapshot, err := (StaticProvider{AgentID: "host-103", ProtocolVersion: "v1"}).Snapshot(context.Background())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if snapshot.Features["startup_script"] || snapshot.Features["nocloud_seed_artifact"] {
|
|
t.Fatal("static development provider must remain conservative")
|
|
}
|
|
}
|