kubo/fuse/node/mount_test.go
Marcin Rataj 9faefe316f
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / go-test (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
refactor(ci): optimize build workflows (#10973)
* ci: optimize build workflows

- use go version from go.mod instead of hardcoding
- group platforms by OS for parallel builds
- remove legacy try-build targets

* fix: checkout before setup-go in all workflows

setup-go needs go.mod to be present, so checkout must happen first

* chore: remove deprecated // +build syntax

go 1.17+ uses //go:build, the old syntax is no longer needed

* simplify: remove nofuse tag from CI workflows

- workflows now rely on platform build constraints
- keep make nofuse target for manual builds
- remove unused appveyor.yml

* ci: remove legacy travis variable and fix gateway-conformance

- remove TRAVIS env variable from 4 workflows
- fix gateway-conformance checkout path to match working-directory
- replace deprecated cache-go-action with built-in setup-go caching
2025-09-19 14:44:38 +02:00

93 lines
1.8 KiB
Go

//go:build !openbsd && !nofuse && !netbsd && !plan9
package node
import (
"context"
"os"
"strings"
"testing"
"time"
"bazil.org/fuse"
core "github.com/ipfs/kubo/core"
ipns "github.com/ipfs/kubo/fuse/ipns"
mount "github.com/ipfs/kubo/fuse/mount"
ci "github.com/libp2p/go-libp2p-testing/ci"
)
func maybeSkipFuseTests(t *testing.T) {
if ci.NoFuse() {
t.Skip("Skipping FUSE tests")
}
}
func mkdir(t *testing.T, path string) {
err := os.Mkdir(path, os.ModeDir|os.ModePerm)
if err != nil {
t.Fatal(err)
}
}
// Test externally unmounting, then trying to unmount in code.
func TestExternalUnmount(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// TODO: needed?
maybeSkipFuseTests(t)
node, err := core.NewNode(context.Background(), &core.BuildCfg{})
if err != nil {
t.Fatal(err)
}
err = ipns.InitializeKeyspace(node, node.PrivateKey)
if err != nil {
t.Fatal(err)
}
// get the test dir paths (/tmp/TestExternalUnmount)
dir := t.TempDir()
ipfsDir := dir + "/ipfs"
ipnsDir := dir + "/ipns"
mfsDir := dir + "/mfs"
mkdir(t, ipfsDir)
mkdir(t, ipnsDir)
mkdir(t, mfsDir)
err = Mount(node, ipfsDir, ipnsDir, mfsDir)
if err != nil {
if strings.Contains(err.Error(), "unable to check fuse version") || err == fuse.ErrOSXFUSENotFound {
t.Skip(err)
}
}
if err != nil {
t.Fatalf("error mounting: %v", err)
}
// Run shell command to externally unmount the directory
cmd, err := mount.UnmountCmd(ipfsDir)
if err != nil {
t.Fatal(err)
}
if err := cmd.Run(); err != nil {
t.Fatal(err)
}
// TODO(noffle): it takes a moment for the goroutine that's running fs.Serve to be notified and do its cleanup.
time.Sleep(time.Millisecond * 100)
// Attempt to unmount IPFS; it should unmount successfully.
err = node.Mounts.Ipfs.Unmount()
if err != mount.ErrNotMounted {
t.Fatal("Unmount should have failed")
}
}