tests/destructive: Turn off global sync()
authorColin Walters <walters@verbum.org>
Fri, 28 Jul 2023 21:54:37 +0000 (17:54 -0400)
committerColin Walters <walters@verbum.org>
Fri, 28 Jul 2023 21:59:28 +0000 (17:59 -0400)
Let's verify that things work with that off, as they should.

Previously:
https://github.com/ostreedev/ostree/pull/2519/commits/cb731294837736e957ee595ce11ab115277dbb36
"deploy: Add a 5s max timeout on global filesystem sync()"

But we may still have problems even with that, see
https://issues.redhat.com/browse/OCPBUGS-15917
where it might be that even a thread doesn't work because
we're locked in the kernel.

tests/inst/src/destructive.rs

index 2cc3a0c2669b1db2eb7daa804f34dc06ff7dc0a1..eb04d68be43094d3e4c237d88090a97433357ede 100644 (file)
@@ -388,6 +388,17 @@ fn impl_transaction_test<M: AsRef<str>>(
 
     assert_ne!(commitstates.booted.as_str(), commitstates.target.as_str());
 
+    // Also verify we didn't do a global sync()
+    {
+        let out = cmd!(
+            sh,
+            "journalctl -u ostree-finalize-staged --grep='Starting global sync'"
+        )
+        .ignore_status()
+        .read()?;
+        assert!(!out.contains("Starting global sync"));
+    }
+
     let rt = tokio::runtime::Runtime::new()?;
     let cycle_time_ms = (tdata.cycle_time.as_secs_f64() * 1000f64 * FORCE_REBOOT_AFTER_MUL) as u64;
     // Set when we're trying an interrupt strategy that isn't a reboot, so we will
@@ -537,6 +548,18 @@ fn impl_transaction_test<M: AsRef<str>>(
     }
 }
 
+// See ostree-sysroot.c; we want this off for our tests
+fn suppress_ostree_global_sync(sh: &xshell::Shell) -> Result<()> {
+    let dropindir = "/etc/systemd/system/ostree-finalize-staged.service.d";
+    std::fs::create_dir_all(dropindir)?;
+    std::fs::write(
+        Path::new(dropindir).join("50-suppress-sync.conf"),
+        "[Service]\nEnvironment=OSTREE_SYSROOT_OPTS=skip-sync\n",
+    )?;
+    cmd!(sh, "systemctl daemon-reload").run()?;
+    Ok(())
+}
+
 pub(crate) fn itest_transactionality() -> Result<()> {
     let sh = xshell::Shell::new()?;
     testinit()?;
@@ -582,6 +605,7 @@ pub(crate) fn itest_transactionality() -> Result<()> {
             // in our reboots, and it currently fails to start.  The less
             // we have in each reboot, the faster reboots are.
             cmd!(sh, "systemctl disable --now zincati").run()?;
+            suppress_ostree_global_sync(&sh)?;
             // And prepare for updates
             cmd!(sh, "rpm-ostree cleanup -pr").run()?;
             generate_update(&commit)?;