Skip to content

Commit

Permalink
Run ginkgo in verbose mode and refactor qrcode test (still failing)
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
  • Loading branch information
jimmykarily committed Apr 7, 2023
1 parent 5717872 commit 057a68d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/run_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo
ginkgo --label-filter "$1" --fail-fast -r ./tests/
ginkgo --label-filter "$1" --fail-fast -v -r ./tests/
98 changes: 45 additions & 53 deletions tests/install_qrcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,59 @@ var _ = Describe("kairos qr code install", Label("qrcode-install"), func() {
vm.Destroy(nil)
})

Context("install", func() {
It("to disk with custom config", func() {
By("checking if is has default service active", func() {
if isFlavor("alpine") {
out, _ := vm.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"))
It("installs to disk with custom config", func() {
By("checking if is has default service active")
if isFlavor("alpine") {
out, _ := vm.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, _ := vm.Sudo("systemctl status kairos")
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled; vendor preset: disabled)"))
}
})
out, _ := vm.Sudo("systemctl status kairos")
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled; vendor preset: disabled)"))
}

By("checking cmdline", func() {
v, _ := vm.Sudo("cat /proc/cmdline")
Expect(v).To(ContainSubstring("rd.cos.disable"))
})
By("checking cmdline")
v, err := vm.Sudo("cat /proc/cmdline")
Expect(err).ToNot(HaveOccurred(), v)
Expect(v).To(ContainSubstring("rd.cos.disable"))

By("waiting until the qr code is shown", func() {
// sleep enough to give time to qr code to display.
// TODO: This can be enhanced
time.Sleep(5 * time.Minute)
})
// sleep enough to give time to qr code to display.
// TODO: This can be enhanced
By("waiting until the qr code is shown")
time.Sleep(5 * time.Minute)

// Wait until we reboot into active, after the system is installed
By("registering with a screenshot", func() {
file, err := vm.Screenshot()
Expect(err).ToNot(HaveOccurred())
//defer os.RemoveAll(file)
// Wait until we reboot into active, after the system is installed
By("registering with a screenshot")
file, err := vm.Screenshot()
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(file)

out, err := utils.SH(fmt.Sprintf("kairos register --device /dev/sda --config %s %s", os.Getenv("CLOUD_INIT"), file))
Expect(err).ToNot(HaveOccurred(), out)
})
out, err := utils.SH(fmt.Sprintf("kairos register --device /dev/sda --config %s %s", os.Getenv("CLOUD_INIT"), file))
Expect(err).ToNot(HaveOccurred(), out)

By("checking that the installer is running", func() {
Eventually(func() string {
v, _ := vm.Sudo("ps aux")
return v
}, 20*time.Minute, 10*time.Second).Should(ContainSubstring("elemental install"))
})
By("checking that the installer is running")
Eventually(func() string {
v, _ := vm.Sudo("ps aux")
return v
}, 20*time.Minute, 10*time.Second).Should(ContainSubstring("elemental install"))

By("checking that the installer has terminated", func() {
Eventually(func() string {
v, _ := vm.Sudo("ps aux")
return v
}, 10*time.Minute, 10*time.Second).ShouldNot(ContainSubstring("elemental install"))
})
By("checking that the installer has terminated")
Eventually(func() string {
v, _ := vm.Sudo("ps aux")
return v
}, 10*time.Minute, 10*time.Second).ShouldNot(ContainSubstring("elemental install"))

By("restarting on the installed system", func() {
vm.Reboot()
By("restarting on the installed system")
vm.Reboot()

Eventually(func() string {
v, _ := vm.Sudo("cat /proc/cmdline")
return v
}, 10*time.Minute, 10*time.Second).ShouldNot(ContainSubstring("rd.cos.disable"))
})
})
Eventually(func() string {
v, _ := vm.Sudo("cat /proc/cmdline")
return v
}, 10*time.Minute, 10*time.Second).ShouldNot(ContainSubstring("rd.cos.disable"))
})
})

0 comments on commit 057a68d

Please sign in to comment.