Skip to content

Commit cbf891d

Browse files
committed
Initial networking for test
1 parent c5d096d commit cbf891d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/api/api/api_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import (
2525
// newTestService creates an ApiService for testing with automatic cleanup
2626
func newTestService(t *testing.T) *ApiService {
2727
cfg := &config.Config{
28-
DataDir: t.TempDir(),
28+
DataDir: t.TempDir(),
29+
BridgeName: "vmbr0",
30+
SubnetCIDR: "10.100.0.0/16",
31+
DNSServer: "1.1.1.1",
2932
}
3033

3134
p := paths.New(cfg.DataDir)
@@ -44,6 +47,11 @@ func newTestService(t *testing.T) *ApiService {
4447
}
4548
instanceMgr := instances.NewManager(p, imageMgr, systemMgr, networkMgr, deviceMgr, volumeMgr, limits, "", nil, nil)
4649

50+
// Initialize network manager (creates bridge for network-enabled tests)
51+
if err := networkMgr.Initialize(ctx(), nil); err != nil {
52+
t.Logf("Warning: failed to initialize network manager: %v (network tests may fail)", err)
53+
}
54+
4755
// Register cleanup for orphaned Cloud Hypervisor processes
4856
t.Cleanup(func() {
4957
cleanupOrphanedProcesses(t, cfg.DataDir)
@@ -54,6 +62,7 @@ func newTestService(t *testing.T) *ApiService {
5462
ImageManager: imageMgr,
5563
InstanceManager: instanceMgr,
5664
VolumeManager: volumeMgr,
65+
NetworkManager: networkMgr,
5766
DeviceManager: deviceMgr,
5867
ResourceManager: resourceMgr,
5968
}

0 commit comments

Comments
 (0)