mirror of
https://github.com/containers/podman.git
synced 2025-06-19 08:09:12 +08:00
Merge pull request #21232 from ashley-cui/vfkitport
Assign separate ports for each appleHV machine
This commit is contained in:
@ -12,16 +12,16 @@ import (
|
|||||||
"github.com/containers/podman/v4/pkg/machine"
|
"github.com/containers/podman/v4/pkg/machine"
|
||||||
"github.com/containers/podman/v4/pkg/machine/compression"
|
"github.com/containers/podman/v4/pkg/machine/compression"
|
||||||
"github.com/containers/podman/v4/pkg/machine/define"
|
"github.com/containers/podman/v4/pkg/machine/define"
|
||||||
"github.com/containers/podman/v4/pkg/machine/vmconfigs"
|
|
||||||
"github.com/containers/podman/v4/pkg/machine/ignition"
|
"github.com/containers/podman/v4/pkg/machine/ignition"
|
||||||
|
"github.com/containers/podman/v4/pkg/machine/vmconfigs"
|
||||||
vfConfig "github.com/crc-org/vfkit/pkg/config"
|
vfConfig "github.com/crc-org/vfkit/pkg/config"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultVFKitEndpoint = "http://localhost:8081"
|
localhostURI = "http://localhost"
|
||||||
ignitionSocketName = "ignition.sock"
|
ignitionSocketName = "ignition.sock"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppleHVVirtualization struct {
|
type AppleHVVirtualization struct {
|
||||||
|
@ -116,7 +116,12 @@ func (m *MacMachine) setVfkitInfo(cfg *config.Config, readySocket define.VMFile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Vfkit.VirtualMachine.Devices = defaultDevices
|
m.Vfkit.VirtualMachine.Devices = defaultDevices
|
||||||
m.Vfkit.Endpoint = defaultVFKitEndpoint
|
randPort, err := utils.GetRandomPort()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Vfkit.Endpoint = localhostURI + ":" + strconv.Itoa(randPort)
|
||||||
m.Vfkit.VfkitBinaryPath = vfkitBinaryPath
|
m.Vfkit.VfkitBinaryPath = vfkitBinaryPath
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -13,7 +13,7 @@ func (i *inspectMachine) buildCmd(m *machineTestBuilder) []string {
|
|||||||
if len(i.format) > 0 {
|
if len(i.format) > 0 {
|
||||||
cmd = append(cmd, "--format", i.format)
|
cmd = append(cmd, "--format", i.format)
|
||||||
}
|
}
|
||||||
cmd = append(cmd, m.names...)
|
cmd = append(cmd, m.name)
|
||||||
i.cmd = cmd
|
i.cmd = cmd
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func (m *machineTestBuilder) setCmd(mc machineCommand) *machineTestBuilder {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *machineTestBuilder) setTimeout(timeout time.Duration) *machineTestBuilder {
|
func (m *machineTestBuilder) setTimeout(timeout time.Duration) *machineTestBuilder { //nolint: unparam
|
||||||
m.timeout = timeout
|
m.timeout = timeout
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/machine/define"
|
"github.com/containers/podman/v4/pkg/machine/define"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -84,4 +86,36 @@ var _ = Describe("podman machine start", func() {
|
|||||||
Expect(startSession).To(Exit(125))
|
Expect(startSession).To(Exit(125))
|
||||||
Expect(startSession.errorToString()).To(ContainSubstring("VM already running or starting"))
|
Expect(startSession.errorToString()).To(ContainSubstring("VM already running or starting"))
|
||||||
})
|
})
|
||||||
|
It("start only starts specified machine", func() {
|
||||||
|
i := initMachine{}
|
||||||
|
startme := randomString()
|
||||||
|
session, err := mb.setName(startme).setCmd(i.withImagePath(mb.imagePath)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(session).To(Exit(0))
|
||||||
|
|
||||||
|
j := initMachine{}
|
||||||
|
dontstartme := randomString()
|
||||||
|
session2, err := mb.setName(dontstartme).setCmd(j.withImagePath(mb.imagePath)).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(session2).To(Exit(0))
|
||||||
|
|
||||||
|
s := startMachine{}
|
||||||
|
session3, err := mb.setName(startme).setCmd(s).setTimeout(time.Minute * 10).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(session3).Should(Exit(0))
|
||||||
|
|
||||||
|
inspect := new(inspectMachine)
|
||||||
|
inspect = inspect.withFormat("{{.State}}")
|
||||||
|
inspectSession, err := mb.setName(startme).setCmd(inspect).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(inspectSession).To(Exit(0))
|
||||||
|
Expect(inspectSession.outputToString()).To(Equal(define.Running))
|
||||||
|
|
||||||
|
inspect2 := new(inspectMachine)
|
||||||
|
inspect2 = inspect2.withFormat("{{.State}}")
|
||||||
|
inspectSession2, err := mb.setName(dontstartme).setCmd(inspect2).run()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(inspectSession2).To(Exit(0))
|
||||||
|
Expect(inspectSession2.outputToString()).To(Not(Equal(define.Running)))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user