mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
adjusted tests
This commit is contained in:
parent
c51884ce23
commit
a467d5081c
|
@ -161,11 +161,9 @@ func TestRemoveDataCenter(t *testing.T) {
|
||||||
func TestReserveOneVolume(t *testing.T) {
|
func TestReserveOneVolume(t *testing.T) {
|
||||||
topo := setup()
|
topo := setup()
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
ret, vid := topo.RandomlyReserveOneVolume()
|
ret, node, vid := topo.RandomlyReserveOneVolume()
|
||||||
fmt.Println("topology:", topo.Node)
|
fmt.Println("topology:", topo.Node)
|
||||||
fmt.Println("assigned :", ret)
|
fmt.Println("assigned :", ret)
|
||||||
|
fmt.Println("assigned node :", node)
|
||||||
fmt.Println("assigned volume id:", vid)
|
fmt.Println("assigned volume id:", vid)
|
||||||
if topo.reservedVolumeCount != 1 {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package topology
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"pkg/storage"
|
"pkg/storage"
|
||||||
"fmt"
|
_ "fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Topology struct {
|
type Topology struct {
|
||||||
|
@ -19,7 +19,6 @@ func NewTopology(id NodeId) *Topology{
|
||||||
func (t *Topology) RandomlyReserveOneVolume() (bool, *Node, storage.VolumeId) {
|
func (t *Topology) RandomlyReserveOneVolume() (bool, *Node, storage.VolumeId) {
|
||||||
slots := t.Node.maxVolumeCount-t.Node.activeVolumeCount
|
slots := t.Node.maxVolumeCount-t.Node.activeVolumeCount
|
||||||
r := rand.Intn(slots)
|
r := rand.Intn(slots)
|
||||||
fmt.Println("slots:", slots, "random :", r)
|
|
||||||
vid := t.nextVolumeId()
|
vid := t.nextVolumeId()
|
||||||
ret, node := t.Node.ReserveOneVolume(r,vid)
|
ret, node := t.Node.ReserveOneVolume(r,vid)
|
||||||
return ret, node, vid
|
return ret, node, vid
|
||||||
|
|
Loading…
Reference in a new issue