-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use older disk version for preparing upgrade-test Signed-off-by: Fredrik Lönnegren <[email protected]> * Run upgrade command in podman This commit uses podman to run the latest version of the elemental-cli to run the update command. Signed-off-by: Fredrik Lönnegren <[email protected]> * Pass UPGRADE_ARGS in test-upgrade workflow Signed-off-by: Fredrik Lönnegren <[email protected]> * Some cleanup Signed-off-by: Fredrik Lönnegren <[email protected]> * Add downgrade test Signed-off-by: Fredrik Lönnegren <[email protected]> --------- Signed-off-by: Fredrik Lönnegren <[email protected]>
- Loading branch information
Showing
9 changed files
with
208 additions
and
42 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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
name: "Setup cos config" | ||
name: "Debug hooks" | ||
stages: | ||
after-upgrade-chroot: | ||
- commands: | ||
- echo > /after-upgrade-chroot | ||
after-reset-chroot: | ||
- commands: | ||
- echo > /after-reset-chroot | ||
- echo > /after-reset-chroot |
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,75 @@ | ||
/* | ||
Copyright © 2022 - 2024 SUSE LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package elemental_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
sut "github.com/rancher/elemental-toolkit/tests/vm" | ||
|
||
comm "github.com/rancher/elemental-toolkit/tests/common" | ||
) | ||
|
||
func TestTests(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Elemental upgrade test Suite") | ||
} | ||
|
||
var _ = Describe("Elemental Feature tests", func() { | ||
var s *sut.SUT | ||
BeforeEach(func() { | ||
s = sut.NewSUT() | ||
s.EventuallyConnects() | ||
s.EventuallyBootedFrom(sut.Active) | ||
}) | ||
|
||
Context("After install", func() { | ||
It("downgrades to a signed 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())) | ||
|
||
out, err := s.Command(s.ElementalCmd("upgrade", "--system", comm.UpgradeImage())) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(out).Should(ContainSubstring("Upgrade completed")) | ||
|
||
s.Reboot() | ||
s.EventuallyBootedFrom(sut.Active) | ||
currentVersion := s.GetOSRelease("TIMESTAMP") | ||
Expect(currentVersion).NotTo(Equal(originalVersion)) | ||
|
||
_, err = s.Command("cat /after-upgrade-chroot") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
_, err = s.Command("cat /after-reset-chroot") | ||
Expect(err).To(HaveOccurred()) | ||
|
||
s.Reset() | ||
currentVersion = s.GetOSRelease("TIMESTAMP") | ||
Expect(currentVersion).To(Equal(originalVersion)) | ||
_, err = s.Command("cat /after-reset-chroot") | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
}) | ||
}) |
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,67 @@ | ||
/* | ||
Copyright © 2022 - 2024 SUSE LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package vm | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type PodmanRunCommand struct { | ||
sut *SUT | ||
privileged bool | ||
image string | ||
mounts []VolumeMount | ||
entrypoint string | ||
command string | ||
} | ||
|
||
type VolumeMount struct { | ||
from string | ||
to string | ||
} | ||
|
||
func (p *PodmanRunCommand) Privileged() *PodmanRunCommand { | ||
p.privileged = true | ||
return p | ||
} | ||
|
||
func (p *PodmanRunCommand) WithMount(from, to string) *PodmanRunCommand { | ||
p.mounts = append(p.mounts, VolumeMount{from: from, to: to}) | ||
return p | ||
} | ||
|
||
func (p *PodmanRunCommand) Run() (string, error) { | ||
priv := "" | ||
if p.privileged { | ||
priv = "--privileged" | ||
} | ||
|
||
mounts := []string{} | ||
for _, m := range p.mounts { | ||
mounts = append(mounts, fmt.Sprintf("-v %s:%s", m.from, m.to)) | ||
} | ||
|
||
entrypoint := "" | ||
if p.entrypoint != "" { | ||
entrypoint = fmt.Sprintf("--entrypoint=%s", p.entrypoint) | ||
} | ||
|
||
cmd := fmt.Sprintf("podman run %s %s %s %s %s", priv, strings.Join(mounts, " "), entrypoint, p.image, p.command) | ||
fmt.Printf("Running podman command: '%s'", cmd) | ||
return p.sut.Command(cmd) | ||
} |
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