forked from kairos-io/kairos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🤖 Add reset tests * 🤖 Do not run build_images tests on PRs anymore
- Loading branch information
Showing
3 changed files
with
147 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package mos_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"time" | ||
|
||
"github.com/kairos-io/kairos/tests/machine" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("kairos reset test", Label("reset-test"), func() { | ||
BeforeEach(func() { | ||
if os.Getenv("CLOUD_INIT") == "" || !filepath.IsAbs(os.Getenv("CLOUD_INIT")) { | ||
Fail("CLOUD_INIT must be set and must be pointing to a file as an absolute path") | ||
} | ||
|
||
machine.EventuallyConnects() | ||
}) | ||
|
||
AfterEach(func() { | ||
if CurrentGinkgoTestDescription().Failed { | ||
gatherLogs() | ||
} | ||
}) | ||
|
||
Context("live cd", func() { | ||
It("has default service active", func() { | ||
if os.Getenv("FLAVOR") == "alpine" { | ||
out, _ := machine.SSHCommand("sudo rc-status") | ||
Expect(out).Should(ContainSubstring("kairos")) | ||
Expect(out).Should(ContainSubstring("kairos-agent")) | ||
fmt.Println(out) | ||
} else { | ||
// Eventually(func() string { | ||
// out, _ := machine.SSHCommand("sudo systemctl status kairosososososos-agent") | ||
// return out | ||
// }, 30*time.Second, 10*time.Second).Should(ContainSubstring("no network token")) | ||
|
||
out, _ := machine.SSHCommand("sudo systemctl status kairos") | ||
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled;")) | ||
fmt.Println(out) | ||
} | ||
|
||
out, _ := machine.SSHCommand("ls -liah /oem") | ||
fmt.Println(out) | ||
// Expect(out).To(ContainSubstring("userdata.yaml")) | ||
out, _ = machine.SSHCommand("cat /oem/userdata") | ||
fmt.Println(out) | ||
out, _ = machine.SSHCommand("sudo ps aux") | ||
fmt.Println(out) | ||
|
||
out, _ = machine.SSHCommand("sudo lsblk") | ||
fmt.Println(out) | ||
|
||
}) | ||
}) | ||
|
||
Context("auto installs", func() { | ||
It("to disk with custom config", func() { | ||
Eventually(func() string { | ||
out, _ := machine.SSHCommand("sudo ps aux") | ||
return out | ||
}, 30*time.Minute, 1*time.Second).Should( | ||
Or( | ||
ContainSubstring("elemental install"), | ||
)) | ||
}) | ||
}) | ||
|
||
Context("reboots and passes functional tests", func() { | ||
It("has grubenv file", func() { | ||
Eventually(func() string { | ||
out, _ := machine.SSHCommand("sudo cat /oem/grubenv") | ||
return out | ||
}, 40*time.Minute, 1*time.Second).Should( | ||
Or( | ||
ContainSubstring("foobarzz"), | ||
)) | ||
}) | ||
|
||
It("resets", func() { | ||
_, err := machine.Sudo("echo 'test' > /usr/local/test") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
_, err = machine.Sudo("echo 'testoem' > /oem/test") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
machine.HasFile("/oem/test") | ||
machine.HasFile("/usr/local/test") | ||
|
||
_, err = machine.Sudo("grub2-editenv /oem/grubenv set next_entry=statereset") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
machine.Reboot() | ||
|
||
Eventually(func() string { | ||
out, _ := machine.Sudo("if [ -f /usr/local/test ]; then echo ok; else echo wrong; fi") | ||
return out | ||
}, 40*time.Minute, 1*time.Second).Should( | ||
Or( | ||
ContainSubstring("wrong"), | ||
)) | ||
Eventually(func() string { | ||
out, _ := machine.Sudo("if [ -f /oem/test ]; then echo ok; else echo wrong; fi") | ||
return out | ||
}, 40*time.Minute, 1*time.Second).Should( | ||
Or( | ||
ContainSubstring("ok"), | ||
)) | ||
}) | ||
}) | ||
}) |