Skip to content

Commit

Permalink
Enable tmp mount on ubuntu (kairos-io#136)
Browse files Browse the repository at this point in the history
* ⚙️ Enable tmp mount on ubuntu image

* 🤖 Add upgrade test

* 🤖 Bump waiting time after reboot

* 📝 Update README badge
  • Loading branch information
mudler authored Sep 21, 2022
1 parent d3d9894 commit 9484c3f
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,50 @@ jobs:
./earthly.sh +datasource-iso --CLOUD_CONFIG=tests/assets/autoinstall.yaml
./earthly.sh +run-qemu-tests --FLAVOR=${{ matrix.flavor }} --FROM_ARTIFACTS=true
upgrade-with-cli-test:
needs:
- build
runs-on: macos-12
strategy:
fail-fast: false
matrix:
include:
- flavor: "alpine"
node: "A" # Arbitrary field
- flavor: "opensuse"
node: "B"
# - flavor: "alpine"
# node: "C"
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: kairos-${{ matrix.flavor }}.iso.zip
- name: Install deps
run: |
brew install cdrtools jq
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
- run: |
ls -liah
export ISO=$PWD/$(ls kairos-core-*.iso)
export GOPATH="/Users/runner/go"
export CONTAINER_IMAGE=ttl.sh/kairos-${{ matrix.flavor }}-${{ github.sha }}:8h
export PATH=$PATH:$GOPATH/bin
export CLOUD_INIT=$PWD/tests/assets/config.yaml
export CREATE_VM=true
export FLAVOR=${{ matrix.flavor }}
./.github/run_test.sh "upgrade-with-cli"
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ matrix.flavor }}-upgrade-test.logs.zip
path: tests/**/logs/*
if-no-files-found: warn

upgrade-latest-with-cli-test:
needs:
- build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h3 align="center">Kairos - Kubernetes-focused, Cloud Native Linux meta-distribution</h3>
<p align="center">
<a href="https://github.com/kairos-io/kairos/issues"><img src="https://img.shields.io/github/issues/kairos-io/kairos"></a>
<a href="https://quay.io/repository/kairos/kairos"> <img src="https://quay.io/repository/kairos/kairos/status"></a>
<a href="https://github.com/kairos-io/kairos/actions/workflows/image.yaml"> <img src="https://github.com/kairos-io/kairos/actions/workflows/image.yaml/badge.svg"></a>
</p>

<p align="center">
Expand Down
4 changes: 4 additions & 0 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ RUN systemctl enable ssh
RUN echo "auto lo" > /etc/network/interfaces
RUN echo "iface lo inet loopback" >> /etc/network/interfaces

# Enable tmp
RUN cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
RUN systemctl enable tmp.mount

# Fixup sudo perms
RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo

Expand Down
15 changes: 13 additions & 2 deletions tests/autoinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ var _ = Describe("kairos autoinstall test", Label("autoinstall-test"), func() {
})
})

Context("reboots", func() {
Context("reboots and passes functional tests", func() {
It("has grubenv file", func() {
Eventually(func() string {
out, _ := machine.SSHCommand("sudo cat /oem/grubenv")
return out
}, 30*time.Minute, 1*time.Second).Should(
}, 40*time.Minute, 1*time.Second).Should(
Or(
ContainSubstring("foobarzz"),
))
})

It("has custom cmdline", func() {
Eventually(func() string {
out, _ := machine.SSHCommand("sudo cat /proc/cmdline")
Expand All @@ -84,5 +85,15 @@ var _ = Describe("kairos autoinstall test", Label("autoinstall-test"), func() {
ContainSubstring("foobarzz"),
))
})

It("has writeable tmp", func() {
_, err := machine.SSHCommand("sudo echo 'foo' > /tmp/bar")
Expect(err).ToNot(HaveOccurred())

out, err := machine.SSHCommand("sudo cat /tmp/bar")
Expect(err).ToNot(HaveOccurred())

Expect(out).To(ContainSubstring("foo"))
})
})
})
98 changes: 98 additions & 0 deletions tests/upgrade_cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package mos_test

import (
"fmt"
"os"
"time"

"github.com/kairos-io/kairos/tests/machine"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("k3s upgrade manual test", Label("upgrade-with-cli"), func() {

containerImage := os.Getenv("CONTAINER_IMAGE")

BeforeEach(func() {
machine.EventuallyConnects()
})

AfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
gatherLogs()
}
})

Context("live cd", func() {

It("has default service active", func() {
if containerImage == "" {
Fail("CONTAINER_IMAGE needs to be set")
}

if os.Getenv("FLAVOR") == "alpine" {
out, _ := machine.Sudo("rc-status")
Expect(out).Should(ContainSubstring("kairos"))
Expect(out).Should(ContainSubstring("kairos-agent"))
} else {
// Eventually(func() string {
// out, _ := machine.SSHCommand("sudo systemctl status kairos-agent")
// return out
// }, 30*time.Second, 10*time.Second).Should(ContainSubstring("no network token"))

out, _ := machine.Sudo("systemctl status kairos")
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled"))
}
})
})

Context("install", func() {
It("to disk with custom config", func() {
err := machine.SendFile("assets/config.yaml", "/tmp/config.yaml", "0770")
Expect(err).ToNot(HaveOccurred())

out, _ := machine.Sudo("elemental install --cloud-init /tmp/config.yaml /dev/sda")
Expect(out).Should(ContainSubstring("Running after-install hook"))
fmt.Println(out)
machine.Sudo("sync")
machine.DetachCD()
machine.Restart()
})
})

Context("upgrades", func() {
It("can upgrade to current image", func() {

currentVersion, err := machine.SSHCommand("source /etc/os-release; echo $VERSION")
Expect(err).ToNot(HaveOccurred())
Expect(currentVersion).To(ContainSubstring("v"))
_, err = machine.Sudo("kairos-agent")
if err == nil {
out, err := machine.Sudo("kairos-agent upgrade --force --image " + containerImage)
Expect(err).ToNot(HaveOccurred(), string(out))
Expect(out).To(ContainSubstring("Upgrade completed"))
Expect(out).To(ContainSubstring(containerImage))
} else {
out, err := machine.Sudo("kairos upgrade --force --image " + containerImage)
Expect(err).ToNot(HaveOccurred(), string(out))
Expect(out).To(ContainSubstring("Upgrade completed"))
Expect(out).To(ContainSubstring(containerImage))
}
machine.Sudo("reboot")
machine.EventuallyConnects(750)

Eventually(func() error {
_, err := machine.SSHCommand("source /etc/os-release; echo $VERSION")
return err
}, 10*time.Minute, 10*time.Second).ShouldNot(HaveOccurred())

var v string
Eventually(func() string {
v, _ = machine.SSHCommand("source /etc/os-release; echo $VERSION")
return v
// TODO: Add regex semver check here
}, 10*time.Minute, 10*time.Second).Should(ContainSubstring("v"))
})
})
})

0 comments on commit 9484c3f

Please sign in to comment.