From 4b84996dca998205a14e745f5ccc86b9ebf63fec Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 10 Oct 2024 17:01:28 +0200 Subject: [PATCH] test: Add test for Machine.clone_container() API Check that we can clone a container and that it is isolated from the host. --- test/browser/run-test.sh | 1 + test/verify/check-connection | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/browser/run-test.sh b/test/browser/run-test.sh index dcafcfcbace9..acc8ba68be79 100644 --- a/test/browser/run-test.sh +++ b/test/browser/run-test.sh @@ -47,6 +47,7 @@ if [ "$PLAN" = "main" ]; then TestAccounts TestBonding TestBridge + TestConnection.testCloneContainer TestFirewall TestJournal TestKdump diff --git a/test/verify/check-connection b/test/verify/check-connection index 219344054343..779a090c474a 100755 --- a/test/verify/check-connection +++ b/test/verify/check-connection @@ -1222,6 +1222,25 @@ UnixPath=/run/cockpit/session self.assertGreater(len(bridges), 0) self.assertIn('sudo', bridge_names) + @testlib.skipOstree("OSTree doesn't have networkd") + @testlib.nondestructive + def testCloneContainer(self): + m = self.machine + m2 = m.clone_container() + + # the two now have independent file systems + m.write("/tmp/stamp-host", "host") + m.write("/run/stamp-host", "host") + m2.write("/tmp/stamp-container", "container") + m2.write("/run/stamp-container", "container") + m.execute("! ls /tmp/stamp-container; ! ls /run/stamp-container") + m2.execute("! ls /tmp/stamp-host; ! ls /run/stamp-host") + + # and independent systemd + m.execute("systemctl stop systemd-hostnamed.service") + m2.execute("systemctl start systemd-hostnamed.service") + m.execute("! systemctl status systemd-hostnamed.service") + class TestReverseProxy(testlib.MachineCase):