當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fs.NewPath函數代碼示例

本文整理匯總了Golang中gostore/services/fs.NewPath函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewPath函數的具體用法?Golang NewPath怎麽用?Golang NewPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewPath函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestHeaderSize

func TestHeaderSize(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestHeaderSize...")

	header, err := tc.nodes[2].Fss.Header(fs.NewPath("/header/should/not/exists"), nil)
	if err != nil {
		t.Errorf("1) Header returned an an error for: %s\n", err)
	}
	if header.Size > 0 {
		t.Errorf("2) Header Size shouldn't higher than 0: %d", header.Size)
	}

	byts := []byte("salut!")
	buf := bytes.NewBuffer(byts)
	tc.nodes[3].Fss.Write(fs.NewPath("/header/tests/io/size"), int64(len(byts)), "", buf, nil)
	header, err = tc.nodes[1].Fss.Header(fs.NewPath("/header/tests/io/size"), nil)
	if err != nil {
		t.Errorf("3) Header returned an an error for: %s\n", err)
	}
	if header.Size != 6 {
		t.Errorf("4) Header Exists should be equal to 6: %s", header.Size)
	}

	byts = []byte("ca")
	buf = bytes.NewBuffer(byts)
	tc.nodes[3].Fss.Write(fs.NewPath("/header/tests/io/size"), int64(len(byts)), "", buf, nil)
	header, err = tc.nodes[1].Fss.Header(fs.NewPath("/header/tests/io/size"), nil)
	if err != nil {
		t.Errorf("5) Header returned an an error for: %s\n", err)
	}
	if header.Size != 2 {
		t.Errorf("6) Header Exists should be equal to 2: %s", header.Size)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:34,代碼來源:header_test.go

示例2: TestHeaderMimeType

func TestHeaderMimeType(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestHeaderMimeType...")

	byts := []byte("salut!")
	buf := bytes.NewBuffer(byts)
	tc.nodes[3].Fss.Write(fs.NewPath("/header/tests/mimetype"), int64(len(byts)), "text/html", buf, nil)
	header, err := tc.nodes[1].Fss.Header(fs.NewPath("/header/tests/mimetype"), nil)
	if err != nil {
		t.Errorf("1) Header returned an an error for: %s\n", err)
	}
	if header.MimeType != "text/html" {
		t.Errorf("2) Header type should be equal to text/html: %s", header.MimeType)
	}

	byts = []byte("salut!")
	buf = bytes.NewBuffer(byts)
	tc.nodes[3].Fss.Write(fs.NewPath("/header/tests/mimetype"), int64(len(byts)), "text/css", buf, nil)
	header, err = tc.nodes[1].Fss.Header(fs.NewPath("/header/tests/mimetype"), nil)
	if err != nil {
		t.Errorf("3) Header returned an an error for: %s\n", err)
	}
	if header.MimeType != "text/css" {
		t.Errorf("4) Header type should be equal to text/css: %s", header.MimeType)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:26,代碼來源:header_test.go

示例3: TestExists

func TestExists(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestExists...")

	exists, err := tc.nodes[1].Fss.Exists(fs.NewPath("/should/not/exists"), nil)
	if err != nil {
		t.Errorf("1) Exists returned an an error for: %s\n", err)
	}
	if exists == true {
		t.Errorf("2) Exists returned bad value: %s", exists)
	}

	exists, err = tc.nodes[2].Fss.Exists(fs.NewPath("/should/not/exists"), nil)
	if err != nil {
		t.Errorf("3) Exists returned an an error for: %s\n", err)
	}
	if exists == true {
		t.Errorf("4) Exists returned bad value: %s", exists)
	}

	byts := []byte("salut!")
	buf := bytes.NewBuffer(byts)
	tc.nodes[0].Fss.Write(fs.NewPath("/tests/io/exists"), int64(len(byts)), "", buf, nil)
	exists, err = tc.nodes[2].Fss.Exists(fs.NewPath("/tests/io/exists"), nil)
	if err != nil {
		t.Errorf("5) Exists returned an an error for: %s\n", err)
	}
	if exists == false {
		t.Errorf("6) Exists returned bad value: %s", exists)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:31,代碼來源:io_test.go

示例4: TestBaseName

func TestBaseName(t *testing.T) {
	path := fs.NewPath("/home")
	if path.BaseName() != "home" {
		t.Errorf("1) BaseName should be 'home' but received '%s'\n", path.BaseName())
	}

	path = fs.NewPath("/home/..")
	if path.BaseName() != "" {
		t.Errorf("2) BaseName should be '' but received '%s'\n", path.BaseName())
	}

	path = fs.NewPath("/")
	if path.BaseName() != "" {
		t.Errorf("3) BaseName should be '' but received '%s'\n", path.BaseName())
	}

	path = fs.NewPath("/..")
	if path.BaseName() != "" {
		t.Errorf("4) BaseName should be '' but received '%s'\n", path.BaseName())
	}

	path = fs.NewPath("/home/test/..")
	if path.BaseName() != "home" {
		t.Errorf("5) BaseName should be 'home' but received '%s'\n", path.BaseName())
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:26,代碼來源:path_test.go

示例5: TestHeaderExists

func TestHeaderExists(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestHeaderExists...")

	//t.Errorf("%s", tc.nodes[1].Cluster.Resolve("/header/should/not/exists").Get(0))
	header, err := tc.nodes[4].Fss.Header(fs.NewPath("/header/should/not/exists"), nil)
	if err != nil {
		t.Errorf("1) Header returned an an error for: %s\n", err)
	}
	if header.Exists {
		t.Errorf("2) Header Exists shouldn't be true: %s\n", header.Exists)
	}

	header, err = tc.nodes[2].Fss.Header(fs.NewPath("/header/should/not/exists"), nil)
	if err != nil {
		t.Errorf("3) Header returned an an error for: %s\n", err)
	}
	if header.Exists {
		t.Errorf("4) Header Exists shouldn't be true: %s", header.Exists)
	}

	byts := []byte("salut!")
	buf := bytes.NewBuffer(byts)
	tc.nodes[3].Fss.Write(fs.NewPath("/header/tests/io/exists"), int64(len(byts)), "", buf, nil)
	header, err = tc.nodes[1].Fss.Header(fs.NewPath("/header/tests/io/exists"), nil)
	if err != nil {
		t.Errorf("5) Header returned an an error for: %s\n", err)
	}
	if !header.Exists {
		t.Errorf("6) Header Exists shouldn't be false: %s", header.Exists)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:32,代碼來源:header_test.go

示例6: TestChildAddReplication

func TestChildAddReplication(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestChildAddReplication...")

	_, other := GetProcessForPath("/tests/replication/write/childadd")
	resolv := tc.nodes[0].Cluster.Rings.GetGlobalRing().Resolve("/tests/replication/write")
	_, otherparent := GetProcessForPath("/tests/replication/write")

	buf := buffer.NewFromString("write1")
	err := other.Fss.Write(fs.NewPath("/tests/replication/write/childadd"), buf.Size, "application/mytest", buf, nil)
	if err != nil {
		t.Errorf("1) Got an error while write: %s", err)
	}

	// check if its not on another node
	context := tc.nodes[0].Fss.NewContext()
	context.ForceLocal = true
	children, err := otherparent.Fss.Children(fs.NewPath("/tests/replication/write"), context)
	if err == nil && len(children) != 0 {
		t.Errorf("2) Children should not exists on another node")
	}

	// check on first secondary
	secondaryid := resolv.GetOnline(1).Id
	context = tc.nodes[secondaryid].Fss.NewContext()
	context.ForceLocal = true
	children, err = tc.nodes[secondaryid].Fss.Children(fs.NewPath("/tests/replication/write"), context)
	if err != nil {
		t.Errorf("3) Got an error while exists: %s", err)
	}
	found := false
	for _, child := range children {
		if child.Name == "childadd" {
			found = true
		}
	}
	if !found {
		t.Errorf("4) Couldn't find child 'childadd'")
	}

	// check on second secondary
	secondaryid = resolv.GetOnline(1).Id
	context = tc.nodes[secondaryid].Fss.NewContext()
	context.ForceLocal = true
	children, err = tc.nodes[secondaryid].Fss.Children(fs.NewPath("/tests/replication/write"), context)
	if err != nil {
		t.Errorf("5) Got an error while exists: %s", err)
	}
	found = false
	for _, child := range children {
		if child.Name == "childadd" {
			found = true
		}
	}
	if !found {
		t.Errorf("6) Couldn't find child 'childadd'")
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:58,代碼來源:replication_test.go

示例7: TestWriteReadReplication

func TestWriteReadReplication(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestWriteReadReplication...")

	_, other := GetProcessForPath("/tests/replication/write/read")
	resolv := tc.nodes[0].Cluster.Rings.GetGlobalRing().Resolve("/tests/replication/write/read")

	buf := buffer.NewFromString("write1")
	err := other.Fss.Write(fs.NewPath("/tests/replication/write/read"), buf.Size, "application/mytest", buf, nil)
	if err != nil {
		t.Errorf("1) Got an error while write: %s", err)
	}

	// test force local on exists
	context := tc.nodes[0].Fss.NewContext()
	context.ForceLocal = true
	bufwriter := bytes.NewBuffer(make([]byte, 0))
	buffer := io.Writer(bufwriter)
	n, err := other.Fss.Read(fs.NewPath("/tests/replication/write/read"), 0, -1, 0, buffer, context)
	if err != fs.ErrorFileNotFound {
		t.Errorf("2) File shouldn't exists on another node: %s", err)
	}

	// force local replication on each secondary
	tc.nodes[resolv.GetOnline(1).Id].Fss.Flush()
	tc.nodes[resolv.GetOnline(2).Id].Fss.Flush()

	// check on first secondary
	secondaryid := resolv.GetOnline(1).Id
	context = tc.nodes[secondaryid].Fss.NewContext()
	context.ForceLocal = true
	bufwriter = bytes.NewBuffer(make([]byte, 0))
	buffer = io.Writer(bufwriter)
	n, err = tc.nodes[secondaryid].Fss.Read(fs.NewPath("/tests/replication/write/read"), 0, -1, 0, buffer, context)
	if err != nil {
		t.Errorf("3) Got an error from read: %s", err)
	}
	if n != buf.Size || bytes.Compare(bufwriter.Bytes(), buf.Bytes()) != 0 {
		t.Errorf("4) Didn't read what was written: %s!=%s", buf.Bytes(), bufwriter)
	}

	// check on second secondary
	secondaryid = resolv.GetOnline(2).Id
	context = tc.nodes[secondaryid].Fss.NewContext()
	context.ForceLocal = true
	bufwriter = bytes.NewBuffer(make([]byte, 0))
	buffer = io.Writer(bufwriter)
	n, err = tc.nodes[secondaryid].Fss.Read(fs.NewPath("/tests/replication/write/read"), 0, -1, 0, buffer, context)
	if err != nil {
		t.Errorf("3) Got an error from read: %s", err)
	}
	if n != buf.Size || bytes.Compare(bufwriter.Bytes(), buf.Bytes()) != 0 {
		t.Errorf("4) Didn't read what was written: %s!=%s", buf.Bytes(), bufwriter)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:55,代碼來源:replication_test.go

示例8: TestFsChildAddWriteNeedNetworkTimeout

func TestFsChildAddWriteNeedNetworkTimeout(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestFsChildAddWriteNeedNetworkTimeout...")

	resp2, other2 := GetProcessForPath("/tests/timeout2/write")
	resp1, other1 := GetProcessForPath("/tests/timeout2")

	initadr := resp2.Cluster.Nodes.Get(resp1.Cluster.MyNode.Id).Address
	resp2.Cluster.Nodes.Get(resp1.Cluster.MyNode.Id).Address = net.ParseIP("224.0.0.2")

	// Create the child, it should never get added to the parent
	buf := buffer.NewFromString("write1")
	err := other2.Fss.Write(fs.NewPath("/tests/timeout2/write"), buf.Size, "", buf, nil)
	if err != nil && err != comm.ErrorTimeout {
		t.Error("1) Received an error: %s", err)
	}
	time.Sleep(900000000)
	children, _ := other1.Fss.Children(fs.NewPath("/tests/timeout2"), nil)
	found := false
	for _, child := range children {
		if child.Name == "write" {
			found = true
		}
	}
	if found {
		t.Error("2) Child should not have been added")
	}

	// Test one timeout + 1 retry, no error
	buf = buffer.NewFromString("write1")

	go func() {
		time.Sleep(1500 * 1000 * 1000)
		// set the address back
		resp2.Cluster.Nodes.Get(resp1.Cluster.MyNode.Id).Address = initadr
	}()

	err = other2.Fss.Write(fs.NewPath("/tests/timeout2/write3"), buf.Size, "", buf, nil)
	if err != nil {
		t.Error("3) Received an error: %s", err)
	}

	children, err = other1.Fss.Children(fs.NewPath("/tests/timeout2"), nil)
	found = false
	for _, child := range children {
		if child.Name == "write3" {
			found = true
		}
	}
	if !found {
		t.Error("4) Child should have been added")
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:53,代碼來源:timeouts_test.go

示例9: TestChildPath

func TestChildPath(t *testing.T) {
	path := fs.NewPath("/home")
	child := path.ChildPath("test")
	if child.String() != "/home/test" {
		t.Errorf("1) Wrong child path: %s %s\n", child, path.Parts)
	}

	path = fs.NewPath("/")
	child = path.ChildPath("home")
	if child.String() != "/home" {
		t.Errorf("2) Wrong child path: %s %s\n", child, path.Parts)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:13,代碼來源:path_test.go

示例10: TestFsDeleteNetworkTimeout

func TestFsDeleteNetworkTimeout(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestFsDeleteNetworkTimeout...")

	resp, other := GetProcessForPath("/tests/timeouts/delete1")
	buf := buffer.NewFromString("write1")
	other.Fss.Write(fs.NewPath("/tests/timeouts/delete1"), buf.Size, "", buf, nil)

	initadr := other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address
	other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address = net.ParseIP("224.0.0.2")

	// Test full timeout and return of an error
	timeoutTest(1500*4, func() {
		buf = buffer.NewFromString("write1")
		err := other.Fss.Delete(fs.NewPath("/tests/timeouts/delete1"), false, nil)
		if err != comm.ErrorTimeout {
			t.Error("1) Didn't receive timeout error: %s", err)
		}
	},
		func(returned bool) {
			if !returned {
				t.Error("2) Write network timeout is endlessly sleeping")
			}
		})

	resp, other = GetProcessForPath("/tests/timeouts/delete2")
	buf = buffer.NewFromString("write1")
	other.Fss.Write(fs.NewPath("/tests/timeouts/delete2"), buf.Size, "", buf, nil)

	// Test one timeout + 1 retry, no error
	timeoutTest(1500*4, func() {
		// wait 50ms and change addr of the remote node
		go func() {
			time.Sleep(500000000)
			other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address = initadr
		}()

		buf = buffer.NewFromString("write1")
		err := other.Fss.Write(fs.NewPath("/tests/timeouts/delete2"), buf.Size, "", buf, nil)
		if err == comm.ErrorTimeout {
			t.Error("3) Received timeout error: %s", err)
		}
	},
		func(returned bool) {
			if !returned {
				t.Error("4) Write network timeout is endlessly sleeping")
			}
		})
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:49,代碼來源:timeouts_test.go

示例11: TestIsRoot

func TestIsRoot(t *testing.T) {
	path := fs.NewPath("/home")
	if path.IsRoot() {
		t.Errorf("1) /home should not considered root\n")
	}

	path = fs.NewPath("/")
	if !path.IsRoot() {
		t.Errorf("2) / should be considered root: '%s'\n", path.Parts[0])
	}

	path = fs.NewPath("/test/..")
	if !path.IsRoot() {
		t.Errorf("3) /test/.. should be considered root\n")
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:16,代碼來源:path_test.go

示例12: TestReadWrite

func TestReadWrite(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestReadWrite...")

	// Read write test
	path := fs.NewPath("/tests/io/write1")
	byts := []byte("write1")
	buf := bytes.NewBuffer(byts)
	err := tc.nodes[0].Fss.Write(path, int64(len(byts)), "", buf, nil)
	if err != nil {
		t.Errorf("1) Write returned an an error for: %s\n", err)
	}

	// Check if read data is the same as written
	bufwriter := bytes.NewBuffer(make([]byte, 0))
	buffer := io.Writer(bufwriter)
	n, err := tc.nodes[2].Fss.Read(path, 0, -1, 0, buffer, nil)
	if n != int64(len(byts)) || bytes.Compare(bufwriter.Bytes(), byts) != 0 {
		t.Errorf("2) Didn't read written data correctly: %s!=%s\n", byts, bufwriter)
	}

	// Get from another node
	bufwriter = bytes.NewBuffer(make([]byte, 0))
	buffer = io.Writer(bufwriter)
	n, err = tc.nodes[6].Fss.Read(path, 0, -1, 0, buffer, nil)
	if n != int64(len(byts)) || bytes.Compare(bufwriter.Bytes(), byts) != 0 {
		t.Errorf("3) Didn't read written data correctly: %s!=%s\n", byts, bufwriter)
	}

	// Rewrite on a file with new data
	path = fs.NewPath("/tests/io/write1")
	byts = []byte("this is new data blabla")
	buf = bytes.NewBuffer(byts)
	err = tc.nodes[4].Fss.Write(path, int64(len(byts)), "", buf, nil)
	if err != nil {
		t.Errorf("4) Write returned an an error for: %s\n", err)
	}

	// Check written data
	bufwriter = bytes.NewBuffer(make([]byte, 0))
	buffer = io.Writer(bufwriter)
	n, err = tc.nodes[9].Fss.Read(path, 0, -1, 0, buffer, nil)
	if n != int64(len(byts)) || bytes.Compare(bufwriter.Bytes(), byts) != 0 {
		t.Errorf("5) Didn't read written data correctly: %s!=%s\n", byts, bufwriter)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:46,代碼來源:io_test.go

示例13: TestWriteExistsReplication

func TestWriteExistsReplication(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestWriteExistsReplication...")

	_, other := GetProcessForPath("/tests/replication/write/exists")
	resolv := tc.nodes[0].Cluster.Rings.GetGlobalRing().Resolve("/tests/replication/write/exists")

	buf := buffer.NewFromString("write1")
	err := other.Fss.Write(fs.NewPath("/tests/replication/write/exists"), buf.Size, "application/mytest", buf, nil)
	if err != nil {
		t.Errorf("1) Got an error while write: %s", err)
	}

	// test force local on exists
	context := tc.nodes[0].Fss.NewContext()
	context.ForceLocal = true
	exists, err := other.Fss.Exists(fs.NewPath("/tests/replication/write/exists"), context)
	if err != nil {
		t.Errorf("2) Got an error while exists: %s", err)
	}
	if exists {
		t.Errorf("3) Shouldn't exists on another node when forced local")
	}

	// check on first secondary
	secondaryid := resolv.GetOnline(1).Id
	context = tc.nodes[secondaryid].Fss.NewContext()
	context.ForceLocal = true
	exists, err = tc.nodes[secondaryid].Fss.Exists(fs.NewPath("/tests/replication/write/exists"), context)
	if err != nil {
		t.Errorf("4) Got an error while exists: %s", err)
	}
	if !exists {
		t.Errorf("5) Received exists = false, should be true")
	}

	// check on second secondary
	secondaryid = resolv.GetOnline(2).Id
	exists, err = tc.nodes[secondaryid].Fss.Exists(fs.NewPath("/tests/replication/write/exists"), context)
	if err != nil {
		t.Errorf("6) Got an error while exists: %s", err)
	}
	if !exists {
		t.Errorf("7) Received exists = false, should be true")
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:46,代碼來源:replication_test.go

示例14: TestWriteHeaderReplication

func TestWriteHeaderReplication(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestWriteHeaderReplication...")

	resp, other := GetProcessForPath("/tests/replication/write/header")
	resolv := tc.nodes[0].Cluster.Rings.GetGlobalRing().Resolve("/tests/replication/write/header")

	buf := buffer.NewFromString("write1")
	err := other.Fss.Write(fs.NewPath("/tests/replication/write/header"), buf.Size, "application/mytest", buf, nil)

	if err != nil {
		t.Error("1) Got an error while write: %s", err)
	}

	// check header on master
	header, err := resp.Fss.Header(fs.NewPath("/tests/replication/write/header"), nil)
	version := header.Version

	// check on first secondary
	secondaryid := resolv.GetOnline(1).Id
	header, err = tc.nodes[secondaryid].Fss.Header(fs.NewPath("/tests/replication/write/header"), nil)
	if header.Version != version {
		t.Errorf("2) Version on secondary node wasn't the same as on master: %d != %d", version, header.Version)
	}
	if header.MimeType != "application/mytest" {
		t.Errorf("3) Mimetype on secondary node wasn't the same as on master: %s != %s", "application/mytest", header.MimeType)
	}
	if header.Size != buf.Size {
		t.Errorf("4) Size on secondary node wasn't the same as on master: %d != %d", 6, header.Size)
	}

	// check on second secondary
	secondaryid = resolv.GetOnline(2).Id
	header, err = tc.nodes[secondaryid].Fss.Header(fs.NewPath("/tests/replication/write/header"), nil)
	if header.Version != version {
		t.Errorf("5) Version on secondary node wasn't the same as on master: %d != %d", version, header.Version)
	}
	if header.MimeType != "application/mytest" {
		t.Errorf("6) Mimetype on secondary node wasn't the same as on master: %s != %s", "application/mytest", header.MimeType)
	}
	if header.Size != buf.Size {
		t.Errorf("7) Size on secondary node wasn't the same as on master: %d != %d", 6, header.Size)
	}
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:44,代碼來源:replication_test.go

示例15: TestFsReadNetworkTimeout

func TestFsReadNetworkTimeout(t *testing.T) {
	SetupCluster()
	log.Info("Testing TestFsReadNetworkTimeout...")

	bufwriter := bytes.NewBuffer(make([]byte, 0))
	buffer := io.Writer(bufwriter)

	resp, other := GetProcessForPath("/")

	initadr := other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address
	other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address = net.ParseIP("224.0.0.2")

	// Test full timeout and return of an error
	timeoutTest(1500*4, func() {
		_, err := other.Fss.Read(fs.NewPath("/"), 0, -1, 0, buffer, nil)
		if err != comm.ErrorTimeout {
			t.Error("1) Didn't receive timeout error: %s", err)
		}
	},
		func(returned bool) {
			if !returned {
				t.Error("2) Read network timeout is endlessly sleeping")
			}
		})

	// Test one timeout + 1 retry, no error
	timeoutTest(1500*4, func() {
		// wait 50ms and change addr of the remote node
		go func() {
			time.Sleep(500000000)
			other.Cluster.Nodes.Get(resp.Cluster.MyNode.Id).Address = initadr
		}()

		_, err := other.Fss.Read(fs.NewPath("/"), 0, -1, 0, buffer, nil)
		if err == comm.ErrorTimeout {
			t.Error("3) Received timeout error: %s", err)
		}
	},
		func(returned bool) {
			if !returned {
				t.Error("4) Read network timeout is endlessly sleeping")
			}
		})
}
開發者ID:appaquet,項目名稱:gostore,代碼行數:44,代碼來源:timeouts_test.go


注:本文中的gostore/services/fs.NewPath函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。