Repository navigation
test(linux): an end-to-end test of Flock on Arch, Ubuntu and Fedora #22
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fb4e657
fix(certs): read the system CA bundle where Linux distributions keep it
sineld 18df29e
feat(binaries): name linux-x64 and linux-arm64 in the manifest
sineld d06e02b
feat(daemon): check on Linux that .test lookups reach Flock's DNS server
sineld 8d4291e
fix(ports): a low port without permission isn't a taken one on Linux
sineld ecd6f1c
refactor(cli): share the shims and shell profile code of macOS with L…
sineld df13d6c
feat(cli): flock install, uninstall and restart on Linux
sineld befd5e3
ci: run the Go tests on Linux and build the CLI for it
sineld c195af1
fix(ports): find a port's holder through /proc on Linux, without lsof
sineld 838ed20
fix(cli): name the Linux CLI flock-php, util-linux owns flock(1)
sineld 043d519
fix(dns): route the TLD through a link of Flock's own on Linux
sineld 18d4050
fix(dns): keep NetworkManager off flock0, and report the link when it…
sineld 9d631ee
fix(dns): check flock0 and NetworkManager even while lookups work, so…
sineld 31d1957
feat(linux): release archives of the Linux CLI, and install.sh that i…
Nejcc 957985f
feat(linux): AUR package flock-php-bin
Nejcc 89d0784
fix(linux): ship the CLI as flock-php, as #12 now names it
Nejcc bba647a
test(linux): an end-to-end test of Flock on Arch, Ubuntu and Fedora
Nejcc de949b6
test(linux): check flock0's NetworkManager state in the test's own shell
Nejcc ebfdb53
test(linux): fail on a failed install, and on a dead daemon's status
Nejcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
| # The Linux end-to-end test (tools/linux-e2e/run.sh): Flock installed with install.sh, checked | ||
| # (DNS through flock0, NetworkManager, drift, HTTPS, a reboot) and uninstalled, in Arch, Ubuntu and | ||
| # Fedora containers booting systemd. Runs when the Linux setup changes, and by hand. | ||
| name: Linux e2e | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - internal/cli/** | ||
| - internal/dns/** | ||
| - internal/certs/** | ||
| - internal/ports/** | ||
| - internal/daemon/** | ||
| - cmd/flock/** | ||
| - go.mod | ||
| - go.sum | ||
| - install.sh | ||
| - Makefile | ||
| - tools/linux-e2e/** | ||
| - .github/workflows/linux-e2e.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: linux-e2e-${{ github.event.pull_request.number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| e2e: | ||
| name: ${{ matrix.distro }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| distro: [arch, ubuntu, fedora] | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| - uses: actions/setup-go@v7 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| # flock0 is a dummy link; a rootless container can't load the module itself. | ||
| - name: Load the dummy module | ||
| run: sudo modprobe dummy numdummies=0 | ||
|
|
||
| - name: Run | ||
| run: tools/linux-e2e/run.sh ${{ matrix.distro }} | ||
This file contains hidden or 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 hidden or 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 hidden or 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,66 @@ | ||
| #!/bin/sh | ||
| # Installs Flock on Linux (any distribution with glibc, x86-64 or arm64): downloads the flock CLI of | ||
| # the newest release, checks it against its SHA-256 and runs `flock-php install`, which copies it to | ||
| # ~/.config/Flock/bin and sets Flock up (asks for your password once). The CLI is flock-php on Linux: | ||
| # util-linux owns flock(1). | ||
| # | ||
| # curl -fsSL https://raw.githubusercontent.com/flock-php/flock/main/install.sh | sh | ||
| # | ||
| # FLOCK_VERSION=1.0.0 installs that release instead. Arguments go to `flock-php install`: | ||
| # | ||
| # curl -fsSL https://raw.githubusercontent.com/flock-php/flock/main/install.sh | sh -s -- --skip-privileged | ||
| # | ||
| # Running it again updates Flock. | ||
| set -eu | ||
|
|
||
| repo=flock-php/flock | ||
|
|
||
| die() { | ||
| echo "flock: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| [ "$(uname -s)" = Linux ] || die "this script is for Linux; for macOS and Windows get the app from https://github.com/$repo/releases" | ||
|
|
||
| case $(uname -m) in | ||
| x86_64 | amd64) arch=x64 ;; | ||
| aarch64 | arm64) arch=arm64 ;; | ||
| *) die "no Flock build for $(uname -m) (there are x86-64 and arm64 ones)" ;; | ||
| esac | ||
|
|
||
| for tool in curl tar sha256sum; do | ||
| command -v "$tool" >/dev/null || die "$tool is needed (Ubuntu: sudo apt install $tool)" | ||
| done | ||
|
|
||
| # The tag_name of the first release in a GitHub API response, without its v. | ||
| tag() { | ||
| sed -n 's/^ *"tag_name": *"v\{0,1\}\([^"]*\)".*/\1/p' | head -n 1 | ||
| } | ||
|
|
||
| version=${FLOCK_VERSION:-} | ||
| if [ -z "$version" ]; then | ||
| # The newest stable release; until there is one, the newest beta. | ||
| version=$(curl -fsSL "https://api.github.com/repos/$repo/releases/latest" 2>/dev/null | tag) | ||
| [ -n "$version" ] || version=$(curl -fsSL "https://api.github.com/repos/$repo/releases?per_page=1" | tag) | ||
| [ -n "$version" ] || die "could not find a release of $repo" | ||
| fi | ||
| version=${version#v} | ||
|
|
||
| name=flock-$version-linux-$arch.tar.gz | ||
| url=https://github.com/$repo/releases/download/v$version/$name | ||
|
|
||
| tmp=$(mktemp -d) | ||
| trap 'rm -rf "$tmp"' EXIT | ||
|
|
||
| echo "Downloading Flock $version ($arch)…" | ||
| curl -fsSL -o "$tmp/$name" "$url" || die "could not download $url" | ||
| curl -fsSL -o "$tmp/$name.sha256" "$url.sha256" || die "could not download $url.sha256" | ||
| (cd "$tmp" && sha256sum -c --status "$name.sha256") || die "$name doesn't match its SHA-256" | ||
| tar -xzf "$tmp/$name" -C "$tmp" flock-php | ||
|
|
||
| # Piped into sh, stdin is this script: the password prompt and any question need the terminal. | ||
| if [ ! -t 0 ] && (: </dev/tty) 2>/dev/null; then | ||
| "$tmp/flock-php" install "$@" </dev/tty | ||
| else | ||
| "$tmp/flock-php" install "$@" | ||
| fi |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
| //go:build !windows && !darwin | ||
|
|
||
| package certs | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestSystemRootsReadsTheFirstBundleThatExists(t *testing.T) { | ||
| dir := t.TempDir() | ||
| missing, empty, debian, alpine := filepath.Join(dir, "missing"), filepath.Join(dir, "empty"), filepath.Join(dir, "debian"), filepath.Join(dir, "alpine") | ||
| for path, data := range map[string]string{empty: "", debian: "debian roots", alpine: "alpine roots"} { | ||
| if err := os.WriteFile(path, []byte(data), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
| old := bundleFiles | ||
| bundleFiles = []string{missing, empty, debian, alpine} | ||
| t.Cleanup(func() { bundleFiles = old }) | ||
| t.Setenv("SSL_CERT_FILE", "") | ||
|
|
||
| if got := string(SystemRoots()); got != "debian roots" { | ||
| t.Errorf("SystemRoots() = %q, want the Debian bundle", got) | ||
| } | ||
|
|
||
| t.Setenv("SSL_CERT_FILE", alpine) | ||
| if got := string(SystemRoots()); got != "alpine roots" { | ||
| t.Errorf("with SSL_CERT_FILE: %q, want its bundle", got) | ||
| } | ||
|
|
||
| bundleFiles = []string{missing} | ||
| t.Setenv("SSL_CERT_FILE", "") | ||
| if got := SystemRoots(); got != nil { | ||
| t.Errorf("without a bundle: %q, want nil", got) | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drift report this test guards lives in
internal/daemon/wildcard.go:checkWildcardcallsdns.LinkProblemon Linux.internal/daemon/**isn't in the list, so a change there that broke the report wouldn't run the test.go.mod/go.sum(and maybecmd/flock/**) may be worth adding too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
internal/daemon/**,cmd/flock/**,go.modandgo.sumin ebfdb53. I'd missed thatcheckWildcard→dns.LinkProblempath.