Skip to content

Commit

Permalink
Test that persistence is working (#1919)
Browse files Browse the repository at this point in the history
  • Loading branch information
frelon authored Jan 29, 2024
1 parent 22c7e8a commit c2d9965
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/smoke/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ limitations under the License.
package elemental_test

import (
"fmt"
"math/rand"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

sut "github.com/rancher/elemental-toolkit/tests/vm"
)

Expand All @@ -37,13 +41,19 @@ var _ = Describe("Elemental Smoke tests", func() {
})

Context("After install", func() {

It("has default services on", func() {
for _, svc := range []string{"systemd-timesyncd"} {
sut.SystemdUnitIsActive(svc, s)
}
})

persistentFileName := fmt.Sprintf("file-%v.txt", rand.Int())
persistentData := rand.Uint32()
It("can save a file to persistent storage", func() {
_, err := s.Command(fmt.Sprintf("echo %v > %v", persistentData, persistentFileName))
Expect(err).ToNot(HaveOccurred())
})

It("can boot into passive", func() {
err := s.ChangeBootOnce(sut.Passive)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -80,6 +90,12 @@ var _ = Describe("Elemental Smoke tests", func() {
s.Reboot()
})

It("can read the file from persistent storage", func() {
data, err := s.Command(fmt.Sprintf("cat %v", persistentFileName))
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal(fmt.Sprintf("%v\n", persistentData)))
})

It("fails running elemental reset from COS_ACTIVE", func() {
out, err := s.Command(s.ElementalCmd("reset"))
Expect(err).To(HaveOccurred())
Expand Down

0 comments on commit c2d9965

Please sign in to comment.