Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use v2.0.0 reference image for tests #2003

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test-fsck: test-active

.PHONY: test-downgrade
test-downgrade: test-active
VM_PID=$$(scripts/run_vm.sh vmpid) go run $(GINKGO) $(GINKGO_ARGS) ./tests/downgrade
VM_PID=$$(scripts/run_vm.sh vmpid) go run $(GINKGO) $(GINKGO_ARGS) ./tests/downgrade -- $(UPGRADE_ARGS)

.PHONY: test-upgrade
test-upgrade: test-active
Expand Down
12 changes: 7 additions & 5 deletions tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ limitations under the License.

package common

import "flag"
import (
"flag"
)

const defaultUpgradeImage = "ghcr.io/rancher/elemental-toolkit/elemental-green:v1.1.4"
const defaultToolkitImage = "ghcr.io/rancher/elemental-toolkit/elemental-cli:v1.1.4"
const DefaultUpgradeImage = "ghcr.io/rancher/elemental-toolkit/elemental-green:v2.0.0"
const DefaultToolkitImage = "ghcr.io/rancher/elemental-toolkit/elemental-cli:v2.0.0"

var upgradeImage string
var toolkitImage string

func init() {
flag.StringVar(&upgradeImage, "upgrade-image", defaultUpgradeImage, "Default image to use in `upgrade` calls")
flag.StringVar(&toolkitImage, "toolkit-image", defaultToolkitImage, "Default image to use when calling `upgrade`")
flag.StringVar(&upgradeImage, "upgrade-image", DefaultUpgradeImage, "Default image to use in `upgrade` calls")
flag.StringVar(&toolkitImage, "toolkit-image", DefaultToolkitImage, "Default image to use when calling `upgrade`")
}

func UpgradeImage() string {
Expand Down
24 changes: 19 additions & 5 deletions tests/downgrade/downgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ var _ = Describe("Elemental Feature tests", func() {
})

Context("After install", func() {
It("downgrades to a signed image including upgrade and reset hooks", func() {
It("downgrades to an onlder image including upgrade and reset hooks", func() {
By("setting /oem/chroot_hooks.yaml")
err := s.SendFile("../assets/chroot_hooks.yaml", "/oem/chroot_hooks.yaml", "0770")
Expect(err).ToNot(HaveOccurred())
originalVersion := s.GetOSRelease("TIMESTAMP")

By(fmt.Sprintf("and upgrading the to %s", comm.UpgradeImage()))
By(fmt.Sprintf("and upgrading the to %s", comm.DefaultUpgradeImage))

out, err := s.Command(s.ElementalCmd("upgrade", "--system", comm.UpgradeImage()))
out, err := s.Command(s.ElementalCmd("upgrade", "--system", comm.DefaultUpgradeImage))
Expect(err).ToNot(HaveOccurred())
Expect(out).Should(ContainSubstring("Upgrade completed"))

Expand All @@ -65,9 +65,23 @@ var _ = Describe("Elemental Feature tests", func() {
_, err = s.Command("cat /after-reset-chroot")
Expect(err).To(HaveOccurred())

s.Reset()
By("Rebooting to passive")
s.ChangeBootOnce(sut.Passive)
s.Reboot()
s.EventuallyBootedFrom(sut.Passive)
passiveVersion := s.GetOSRelease("TIMESTAMP")

By(fmt.Sprintf("Upgrading again from passive to image %s", comm.UpgradeImage()))
out, err = s.Command(s.ElementalCmd("upgrade", "--system", comm.UpgradeImage()))
Expect(err).ToNot(HaveOccurred())
Expect(out).Should(ContainSubstring("Upgrade completed"))

By("Rebooting to active")
s.Reboot()
s.EventuallyBootedFrom(sut.Active)

currentVersion = s.GetOSRelease("TIMESTAMP")
Expect(currentVersion).To(Equal(originalVersion))
Expect(currentVersion).NotTo(Equal(passiveVersion))
_, err = s.Command("cat /after-reset-chroot")
Expect(err).ToNot(HaveOccurred())
})
Expand Down
4 changes: 2 additions & 2 deletions tests/recovery/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ var _ = Describe("Elemental Recovery upgrade tests", func() {
When("using specific images", func() {
It("upgrades to a specific image and reset back to the installed version", Label("third-test"), func() {
By(fmt.Sprintf("upgrading to %s", comm.UpgradeImage()))
cmd := s.ElementalCmd("upgrade", "--recovery", "--recovery-system.uri", comm.UpgradeImage())
cmd := s.ElementalCmd("upgrade-recovery", "--recovery-system.uri", comm.UpgradeImage())
By(fmt.Sprintf("running %s", cmd))
out, err := s.Command(cmd)
_, _ = fmt.Fprintln(GinkgoWriter, out)
Expect(err).ToNot(HaveOccurred())
Expect(out).Should(ContainSubstring("Upgrade completed"))
Expect(out).Should(ContainSubstring("Recovery upgrade completed"))

// TODO: Check state.yaml changed

Expand Down
4 changes: 2 additions & 2 deletions tests/vm/sut.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (s *SUT) ChangeBootOnce(b string) error {
case Active:
bootEntry = "active"
case Passive:
bootEntry = "passive_1"
bootEntry = "1"
case Recovery:
bootEntry = "recovery"
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func (s *SUT) EventuallyBootedFrom(image string) {
Eventually(func() error {
actual := s.BootFrom()
if actual != image {
return fmt.Errorf("Expected boot from %s, actual %s", image, actual)
return fmt.Errorf("expected boot from %s, actual %s", image, actual)
}

return nil
Expand Down
Loading