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

test: test ignore MAC Address on restore feature #1187

Merged
merged 1 commit into from
Feb 8, 2023
Merged
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
20 changes: 17 additions & 3 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ DISTROS_WITHOUT_PODMAN_USER_RESTART = ['ubuntu-stable', 'ubuntu-2204']
DISTROS_WITHOUT_PODMAN_POD_VOLUMES = ['ubuntu-stable', 'ubuntu-2204', 'debian-testing']


def podman_version(cls):
version = cls.execute(False, "podman -v").strip().split(' ')[-1]
# HACK: handle possible rc versions such as 4.4.0-rc2
return tuple(int(v.split('-')[0]) for v in version.split('.'))
Comment on lines +36 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only we had a more machine readable API for determining the version. One should invent an RPC protocol over an Unix socket, and call it "data bus" or something such 🤔

(snarky comment aside -- this is ugly, but effective, thanks!)



def showImages(browser):
if browser.attr("#containers-images button.pf-c-expandable-section__toggle", "aria-expanded") == 'false':
browser.click("#containers-images button.pf-c-expandable-section__toggle")
Expand Down Expand Up @@ -1162,7 +1168,8 @@ class TestApplication(testlib.MachineCase):
return

# Run a container
self.execute(True, "podman run -dit --name swamped-crate --stop-timeout 0 busybox:latest sh; podman stop swamped-crate")
mac_address = '92:d0:c6:0a:29:38'
self.execute(True, f"podman run -dit --mac-address {mac_address} --name swamped-crate --stop-timeout 0 busybox:latest sh; podman stop swamped-crate")
b.wait(lambda: self.execute(True, "podman ps --all | grep -e swamped-crate -e Exited"))

# Check that the restore option is not present (i.e. start is a regular button)
Expand Down Expand Up @@ -1201,6 +1208,14 @@ class TestApplication(testlib.MachineCase):
b.click('.pf-c-modal-box button:contains(Restore)')
b.wait(lambda: self.getContainerAttr("swamped-crate", "State") in 'Running')

# A new MAC address should have been generated
# Fixed in podman 4.4.0 https://github.com/containers/podman/issues/16666
new_mac_address = self.execute(True, "podman inspect --format '{{.NetworkSettings.MacAddress}}' swamped-crate").strip()
if podman_version(self) >= (4, 4, 0):
self.assertNotEqual(new_mac_address, mac_address)
else:
self.assertEqual(new_mac_address, mac_address)

# Checkpoint the container without stopping
self.waitContainerRow("swamped-crate")
self.performContainerAction("swamped-crate", "Checkpoint")
Expand Down Expand Up @@ -1461,8 +1476,7 @@ class TestApplication(testlib.MachineCase):
# Just drop user images so we can use simpler selectors
if auth:
self.execute(False, "podman rmi alpine busybox quay.io/cockpit/registry:2")
_, _, version = self.execute(False, "podman -v").split(' ')
if int(version[0]) < 4:
if podman_version(self)[0] < 4:
self.execute(False, "podman rmi pause:3.5")

self.login(auth)
Expand Down