Skip to content

Commit

Permalink
🤖 Don't run installation twice on installation tests (kairos-io#811)
Browse files Browse the repository at this point in the history
* 🤖 Don't run installation twice on installation tests

Signed-off-by: mudler <mudler@c3os.io>

* 🐛 Scan provided config in manual-install

Signed-off-by: mudler <mudler@c3os.io>

* 🤖 Git unshallow before running tests

Signed-off-by: mudler <mudler@c3os.io>

---------

Signed-off-by: mudler <mudler@c3os.io>
  • Loading branch information
mudler authored Feb 3, 2023
1 parent f1a9ce5 commit 028ae0e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
- flavor: "opensuse-leap"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -176,6 +178,8 @@ jobs:
- flavor: "ubuntu-22-lts"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand All @@ -200,6 +204,8 @@ jobs:
- flavor: "opensuse-leap"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -245,6 +251,8 @@ jobs:
# - flavor: "ubuntu"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -273,6 +281,8 @@ jobs:
- flavor: "ubuntu"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- run: |
./earthly.sh +run-qemu-netboot-test --TEST_SUITE=netboot-test --FLAVOR=${{ matrix.flavor }}
Expand All @@ -289,6 +299,8 @@ jobs:
# - flavor: "ubuntu"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -353,6 +365,8 @@ jobs:
# - flavor: "ubuntu"
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand Down
23 changes: 20 additions & 3 deletions internal/agent/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -61,12 +62,28 @@ func displayInfo(agentConfig *Config) {
}
}

func ManualInstall(config string, options map[string]string) error {
dat, err := os.ReadFile(config)
func ManualInstall(c string, options map[string]string) error {
dat, err := os.ReadFile(c)
if err != nil {
return err
}
options["cc"] = string(dat)

dir, err := os.MkdirTemp("", "kairos-install")
if err != nil {
return err
}
defer os.RemoveAll(dir)

if err := os.WriteFile(filepath.Join(dir, "config.yaml"), dat, 0600); err != nil {
return err
}

cc, err := config.Scan(config.Directories(dir), config.MergeBootLine)
if err != nil {
return err
}

options["cc"] = cc.String()

return RunInstall(options)
}
Expand Down
14 changes: 1 addition & 13 deletions tests/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ func testInstall(cloudConfig string, actual interface{}, m types.GomegaMatcher,
err = Machine.SendFile(t.Name(), "/tmp/config.yaml", "0770")
Expect(err).ToNot(HaveOccurred())

out, err := Sudo("sudo mv /tmp/config.yaml /oem/")
Expect(err).ToNot(HaveOccurred(), out)

out, err = Sudo("kairos-agent install")
out, err := Sudo(`kairos-agent manual-install --device "auto" /tmp/config.yaml`)
Expect(err).ToNot(HaveOccurred(), out)
Expect(out).Should(ContainSubstring("Running after-install hook"))
Sudo("sync")
Expand Down Expand Up @@ -59,9 +56,6 @@ var _ = Describe("kairos install test", Label("install-test"), func() {

It("with bundles", func() {
testInstall(`
install:
auto: true
device: auto
stages:
initramfs:
- name: "Set user and password"
Expand All @@ -80,9 +74,6 @@ bundles:
})
It("cloud-config syntax mixed with extended syntax", func() {
testInstall(`#cloud-config
install:
auto: true
device: auto
users:
- name: "kairos"
passwd: "kairos"
Expand All @@ -101,9 +92,6 @@ stages:
})
It("with config_url", func() {
testInstall(`
install:
auto: true
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

0 comments on commit 028ae0e

Please sign in to comment.