Skip to content

test(preflight): cover nfs4 mount type in preflight-fs-networked BATS#1126

Draft
yasinBursali wants to merge 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:test/preflight-bats-nfs4
Draft

test(preflight): cover nfs4 mount type in preflight-fs-networked BATS#1126
yasinBursali wants to merge 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:test/preflight-bats-nfs4

Conversation

@yasinBursali
Copy link
Copy Markdown
Contributor

What

Add one new BATS test case to dream-server/tests/bats-tests/preflight-fs-networked.bats (the file added by #1083) covering the nfs4 filesystem type.

Why

#1083's Linux production case statement at 01-preflight.sh:121 matches nfs|nfs4|cifs|fuse.smbnetfs|fuse.glusterfs|ocfs2, but the BATS fixture only exercises nfs / cifs / ext / exfat — leaving nfs4 untested. A future change that broke the nfs4 arm of the regex-OR would slip past CI.

How

21-line test case mirroring the existing linux preflight: nfs warns and does not exit fatally test, with the stat stub returning nfs4 instead of nfs. Asserts:

  • the warning fires (networked filesystem)
  • the type appears in the warning message (nfs4)
  • the script does not exit fatally (EXIT_OK)

Testing

  • bash dream-server/tests/run-bats.sh dream-server/tests/bats-tests/preflight-fs-networked.bats: 8/8 PASS

Review

Critique Guardian: APPROVED. Production warn line at 01-preflight.sh:122 includes ($fs_type), so the nfs4 partial-match is reliable. Test scope honors the plan (nfs4 only); fuse.glusterfs and ocfs2 are also untested but out of scope here.

Known Considerations

  • macOS preflight-fs.sh does not include nfs4 in its case statement — that's a separate production gap in feat(preflight): warn when INSTALL_DIR is on networked filesystem #1083 itself, not a test-only gap, and is out of scope for this PR.
  • fuse.smbnetfs, fuse.glusterfs, ocfs2 Linux types are similarly untested by the fixture but match the same case statement; follow-up worth filing.

Platform Impact

  • macOS: BATS runs on macOS shell; this test targets Linux preflight only. No-op on macOS.
  • Linux: primary target.
  • Windows: N/A.

This branch contains two commits: the first is a rebased copy of #1083's commit on current upstream/main (so this PR's diff is self-contained); the second is the new BATS case. Must merge after #1083 — when #1083 lands, rebase this branch onto upstream/main and the #1083 commit drops out cleanly.

NFS / SMB / CIFS / AFP / WebDAV mounts have a quirk: POSIX permissions
are *advisory* — the local kernel accepts chmod 600 and reports back
the new mode, but actual access control is governed by the server's
ACL system. For users mounting a NAS share at INSTALL_DIR, chmod 600
.env LOOKS enforced from the local machine but is world-readable from
another client of the same share. Same trap on Windows networked
drives — local NTFS ACLs do not bind across the share.

Adds warn-only detection on all three platforms. Existing FATAL
behavior for non-POSIX filesystems (exfat/msdos/etc.) is preserved.

macOS: stat -f %T returns nfs/smbfs/afpfs/webdav personality strings.
Linux: stat -fc %T returns nfs/nfs4/cifs/fuse.smbnetfs/fuse.glusterfs/
ocfs2.
Windows: PowerShell DriveInfo.DriveType reports 'Network' for SMB-
mapped drives; UNC paths (^\\\\) are flagged regardless. Reuses the
existing FS-FATAL block's DriveInfo, short-circuit-guarded for null
safety against the catch path.

Each platform branch sets a separate state variable so the fatal-vs-
warn logic stays cleanly separated. New tests/bats-tests/preflight-fs-
networked.bats covers macOS+Linux (Windows lacks Pester infra in this
repo today; manual verification documented).
Linux production preflight (installers/phases/01-preflight.sh) matches
nfs|nfs4|cifs|fuse.smbnetfs|fuse.glusterfs|ocfs2 in its networked-FS
case statement, but the BATS fixture added in Light-Heart-Labs#1083 only exercised nfs
and cifs. Add a single mirrored test case for nfs4 so the legitimate
production code path is covered.

Mirrors the existing nfs case structure: GNU stat stub, _extract_linux_fs_fn
extraction, warn() shim, asserts on "networked filesystem" + "nfs4" partial
match + non-fatal exit.

Must merge after upstream PR Light-Heart-Labs#1083 (creates the file).
Copy link
Copy Markdown
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

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

Blocking this because the branch makes the Windows preflight script unparsable.

The new Windows advisory string in installers/windows/phases/01-preflight.ps1 contains mojibake for an em dash (—). PowerShell treats the embedded smart-quote character in that sequence as a string delimiter, so parsing the file fails before the installer can run. Reproduction:

$src = Get-Content -Raw dream-server/installers/windows/phases/01-preflight.ps1
[scriptblock]::Create($src)

That reports The string is missing the terminator: ' and points at the later causing 'model not found' line because the earlier advisory string was prematurely closed. Please replace the advisory dash with plain ASCII (-) or otherwise ensure the file parses cleanly, and update the PR title/body because this is not test-only: it changes Linux, macOS, and Windows preflight behavior in addition to adding BATS coverage.

The Linux/macOS BATS target itself passed locally (8/8) and the shell syntax checks passed; the blocker is the Windows script parse failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants