mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 23:42:20 +08:00
Mounts detect unmounts and track mount state.
This lets FUSE mounts to track whether they are active or not by tracking when fs.Serve terminates. License: MIT Signed-off-by: Stephen Whitmore <noffle@ipfs.io>
This commit is contained in:
@ -15,12 +15,11 @@ import (
|
||||
racedet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-detect-race"
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
||||
//mfs "github.com/ipfs/go-ipfs/mfs"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
offroute "github.com/ipfs/go-ipfs/routing/offline"
|
||||
u "github.com/ipfs/go-ipfs/util"
|
||||
ci "github.com/ipfs/go-ipfs/util/testutil/ci"
|
||||
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
||||
)
|
||||
|
||||
func maybeSkipFuseTests(t *testing.T) {
|
||||
@ -437,111 +436,6 @@ func TestFSThrash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestFastRepublish(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
// make timeout noticeable.
|
||||
osrt := shortRepublishTimeout
|
||||
shortRepublishTimeout = time.Millisecond * 100
|
||||
|
||||
olrt := longRepublishTimeout
|
||||
longRepublishTimeout = time.Second
|
||||
|
||||
node, mnt := setupIpnsTest(t, nil)
|
||||
|
||||
h, err := node.PrivateKey.GetPublic().Hash()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pubkeyPath := "/ipns/" + u.Key(h).String()
|
||||
|
||||
// set them back
|
||||
defer func() {
|
||||
shortRepublishTimeout = osrt
|
||||
longRepublishTimeout = olrt
|
||||
mnt.Close()
|
||||
}()
|
||||
|
||||
closed := make(chan struct{})
|
||||
dataA := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||
dataB := []byte("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
|
||||
|
||||
fname := mnt.Dir + "/local/file"
|
||||
|
||||
// get first resolved hash
|
||||
log.Debug("publishing first hash")
|
||||
writeFileData(t, dataA, fname) // random
|
||||
<-time.After(shortRepublishTimeout * 2)
|
||||
log.Debug("resolving first hash")
|
||||
resolvedHash, err := node.Namesys.Resolve(context.Background(), pubkeyPath)
|
||||
if err != nil {
|
||||
t.Fatal("resolve err:", pubkeyPath, err)
|
||||
}
|
||||
|
||||
// constantly keep writing to the file
|
||||
go func(timeout time.Duration) {
|
||||
for {
|
||||
select {
|
||||
case <-closed:
|
||||
return
|
||||
|
||||
case <-time.After(timeout * 8 / 10):
|
||||
writeFileData(t, dataB, fname)
|
||||
}
|
||||
}
|
||||
}(shortRepublishTimeout)
|
||||
|
||||
hasPublished := func() bool {
|
||||
res, err := node.Namesys.Resolve(context.Background(), pubkeyPath)
|
||||
if err != nil {
|
||||
t.Fatalf("resolve err: %v", err)
|
||||
}
|
||||
return res != resolvedHash
|
||||
}
|
||||
|
||||
// test things
|
||||
|
||||
// at this point, should not have written dataA and not have written dataB
|
||||
rbuf, err := ioutil.ReadFile(fname)
|
||||
if err != nil || !bytes.Equal(rbuf, dataA) {
|
||||
t.Fatalf("Data inconsistent! %v %v", err, string(rbuf))
|
||||
}
|
||||
|
||||
if hasPublished() {
|
||||
t.Fatal("published (wrote)")
|
||||
}
|
||||
|
||||
<-time.After(shortRepublishTimeout * 11 / 10)
|
||||
|
||||
// at this point, should have written written dataB, but not published it
|
||||
rbuf, err = ioutil.ReadFile(fname)
|
||||
if err != nil || !bytes.Equal(rbuf, dataB) {
|
||||
t.Fatalf("Data inconsistent! %v %v", err, string(rbuf))
|
||||
}
|
||||
|
||||
if hasPublished() {
|
||||
t.Fatal("published (wrote)")
|
||||
}
|
||||
|
||||
<-time.After(longRepublishTimeout * 11 / 10)
|
||||
|
||||
// at this point, should have written written dataB, and published it
|
||||
rbuf, err = ioutil.ReadFile(fname)
|
||||
if err != nil || !bytes.Equal(rbuf, dataB) {
|
||||
t.Fatalf("Data inconsistent! %v %v", err, string(rbuf))
|
||||
}
|
||||
|
||||
if !hasPublished() {
|
||||
t.Fatal("not published")
|
||||
}
|
||||
|
||||
close(closed)
|
||||
}
|
||||
*/
|
||||
|
||||
// Test writing a medium sized file one byte at a time
|
||||
func TestMultiWrite(t *testing.T) {
|
||||
|
||||
|
Reference in New Issue
Block a user