Skip to content

Commit

Permalink
Add machine display (kairos-io#726)
Browse files Browse the repository at this point in the history
* 🔧 Enable spice in scripts/start_vm_qemu.sh

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 add option specify display for qemu

This works only with spectrocloud/peg#2
merged.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 add option to enable KVM

ISO=/home/oznt/Software/spectro-cloud/kairos/build/kairos-core-opensuse.iso \
   CREATE_VM=true USE_QEMU=true \
   MACHINE_DISPLAY="-vga qxl -spice port=5903,addr=127.0.0.1,disable-ticketing=yes" \
   KVM=true ginkgo run -v tests

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Fix failing tests - qemu does not have /dev/sda

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Update peg dependency

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
  • Loading branch information
oz123 authored Jan 27, 2023
1 parent 7b79808 commit 5879135
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/onsi/gomega v1.26.0
github.com/pterm/pterm v0.12.54
github.com/qeesung/image2ascii v1.0.1
github.com/spectrocloud/peg v0.0.0-20230125111803-cdce2247919f
github.com/spectrocloud/peg v0.0.0-20230126082901-925f4b5310f4
github.com/twpayne/go-vfs v1.7.2
github.com/urfave/cli/v2 v2.24.1
golang.org/x/net v0.5.0
Expand All @@ -40,13 +40,13 @@ require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 // indirect
github.com/bramvdbogaerde/go-scp v1.2.0 // indirect
github.com/bramvdbogaerde/go-scp v1.2.1 // indirect
github.com/cavaliergopher/grab/v3 v3.0.1 // indirect
github.com/charmbracelet/bubbles v0.10.3 // indirect
github.com/charmbracelet/bubbletea v0.20.0 // indirect
github.com/charmbracelet/lipgloss v0.5.0 // indirect
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 // indirect
github.com/codingsince1985/checksum v1.2.4 // indirect
github.com/codingsince1985/checksum v1.2.6 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
Expand Down Expand Up @@ -95,8 +95,8 @@ require (
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/image v0.0.0-20191206065243-da761ea9ff43 // indirect
golang.org/x/sys v0.4.0 // indirect
Expand Down
24 changes: 10 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bramvdbogaerde/go-scp v1.2.0 h1:mNF1lCXQ6jQcxCBBuc2g/CQwVy/4QONaoD5Aqg9r+Zg=
github.com/bramvdbogaerde/go-scp v1.2.0/go.mod h1:s4ZldBoRAOgUg8IrRP2Urmq5qqd2yPXQTPshACY8vQ0=
github.com/bramvdbogaerde/go-scp v1.2.1 h1:BKTqrqXiQYovrDlfuVFaEGz0r4Ou6EED8L7jCXw6Buw=
github.com/bramvdbogaerde/go-scp v1.2.1/go.mod h1:s4ZldBoRAOgUg8IrRP2Urmq5qqd2yPXQTPshACY8vQ0=
github.com/cavaliergopher/grab v2.0.0+incompatible/go.mod h1:6ICNRTQPwkMP0m2sKIDv/9XkhFJJwiEOQyZ+8E4H7Yg=
github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4=
github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4=
Expand All @@ -74,8 +74,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/codingsince1985/checksum v1.2.4 h1:kQUpBE1b43jrthLR/RYO4ucEXcZJCq3LpGsMfPDVJYQ=
github.com/codingsince1985/checksum v1.2.4/go.mod h1:c9FdM+lYMC4fx7uCOy+0DQaFWM6sbU9R/jnm9AHZD50=
github.com/codingsince1985/checksum v1.2.6 h1:UjCDls6oaRQeLPG14TvjLvOos2XL1qHdMl8uGMkzpi8=
github.com/codingsince1985/checksum v1.2.6/go.mod h1:Pe5wfeiqzQC1qEXLWEFmxQ3W/OklJEJGiJO62graCJU=
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
Expand Down Expand Up @@ -427,12 +427,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spectrocloud/peg v0.0.0-20221005172954-aa887438fafc h1:8HlU/wVlyQNgEA6u52Tj4q+mkw9R+/5UFI8ontDqdhg=
github.com/spectrocloud/peg v0.0.0-20221005172954-aa887438fafc/go.mod h1:H0Vd1P9FdZfrv1QIiQetY4ckDpiD9R71OcUyuvJadno=
github.com/spectrocloud/peg v0.0.0-20230124153255-14235c0d3ebd h1:a5aTS3QPIwTs6tReS6Lgnaxg0RzE/b0YHU0+5XbWEHs=
github.com/spectrocloud/peg v0.0.0-20230124153255-14235c0d3ebd/go.mod h1:H0Vd1P9FdZfrv1QIiQetY4ckDpiD9R71OcUyuvJadno=
github.com/spectrocloud/peg v0.0.0-20230125111803-cdce2247919f h1:RZzpFyl3Ra+I5QkctOSTHdY9isHeAa47NL4NEe/Vt9Y=
github.com/spectrocloud/peg v0.0.0-20230125111803-cdce2247919f/go.mod h1:YMaL3lRGnHWV5lfAorzH1dTwc5BL7gU0ILLYbS6elPw=
github.com/spectrocloud/peg v0.0.0-20230126082901-925f4b5310f4 h1:pmgQfIqkgb1svmiloglanEvj8fJ6tOwYYTyW8vXzCUg=
github.com/spectrocloud/peg v0.0.0-20230126082901-925f4b5310f4/go.mod h1:YMaL3lRGnHWV5lfAorzH1dTwc5BL7gU0ILLYbS6elPw=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
Expand Down Expand Up @@ -511,14 +507,14 @@ go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
3 changes: 3 additions & 0 deletions scripts/start_vm_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fi

[[ -n "${ENABLE_KVM}" ]] && KVM=(-enable-kvm)

[[ -n ${ENABLE_SPICE} ]] && SPICE=(-vga qxl -spice port=5900,disable-ticketing)

qemu-system-x86_64 \
-m ${MEMORY:=2096} \
-smp cores=2 \
Expand All @@ -14,6 +16,7 @@ qemu-system-x86_64 \
-serial mon:stdio \
-rtc base=utc,clock=rt \
-chardev socket,path=qga.sock,server,nowait,id=qga0 \
"${SPICE[@]}" \
-device virtio-serial \
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
-drive if=virtio,media=disk,file=disk.img \
Expand Down
6 changes: 3 additions & 3 deletions tests/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var _ = Describe("kairos install test", Label("install-test"), func() {
testInstall(`
install:
auto: true
device: /dev/sda
device: auto
stages:
initramfs:
- name: "Set user and password"
Expand All @@ -80,7 +80,7 @@ bundles:
testInstall(`#cloud-config
install:
auto: true
device: /dev/sda
device: auto
users:
- name: "kairos"
passwd: "kairos"
Expand All @@ -101,7 +101,7 @@ stages:
testInstall(`
install:
auto: true
device: /dev/sda
device: auto
config_url: "https://gist.githubusercontent.com/mudler/6db795bad8f9e29ebec14b6ae331e5c0/raw/01137c458ad62cfcdfb201cae2f8814db702c6f9/testgist.yaml"`, func() string {
var out string
out, _ = Sudo("/usr/local/bin/usr/bin/edgevpn --help")
Expand Down
14 changes: 14 additions & 0 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ var _ = BeforeSuite(func() {
opts = append(opts, types.VBoxEngine)
}

display := os.Getenv("MACHINE_DISPLAY") // display is already taken on Linux X sessions
if display != "" {
opts = append(opts, types.WithDisplay(display))
}

memory := os.Getenv("MEMORY")
if memory != "" {
opts = append(opts, types.WithMemory(os.Getenv("MEMORY")))
Expand All @@ -122,6 +127,15 @@ var _ = BeforeSuite(func() {
opts = append(opts, types.WithCPU(os.Getenv("CPUS")))
}

if os.Getenv("KVM") == "true" {
opts = append(opts, func(m *types.MachineConfig) error {
m.Args = append(m.Args,
"-enable-kvm",
)
return nil
})
}

m, err := machine.New(opts...)
if err != nil {
Fail(err.Error())
Expand Down

0 comments on commit 5879135

Please sign in to comment.