diff --git a/go/glog/glog_test.go b/go/glog/glog_test.go index e4cac5a52..711c37dbf 100644 --- a/go/glog/glog_test.go +++ b/go/glog/glog_test.go @@ -106,7 +106,7 @@ func TestHeader(t *testing.T) { } Info("test") var line, pid int - n, err := fmt.Sscanf(contents(infoLog), "I0102 15:04:05.678901 %d glog_test.go:%d] test\n", &pid, &line) + n, err := fmt.Sscanf(contents(infoLog), "I0102 15:04:05 %d glog_test.go:%d] test\n", &pid, &line) if n != 2 || err != nil { t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(infoLog)) } diff --git a/go/images/orientation_test.go b/go/images/orientation_test.go index 5c43e1999..adab17ff8 100644 --- a/go/images/orientation_test.go +++ b/go/images/orientation_test.go @@ -10,7 +10,7 @@ func TestXYZ(t *testing.T) { dat, _ := ioutil.ReadFile(fname) - fixed_data := FixJpgOrientation(".jpg", dat) + fixed_data := FixJpgOrientation(dat) ioutil.WriteFile("fixed1.jpg", fixed_data, 0644) diff --git a/go/topology/topo_test.go b/go/topology/topo_test.go index f3ae2096b..9a0dbc6b8 100644 --- a/go/topology/topo_test.go +++ b/go/topology/topo_test.go @@ -1,116 +1,9 @@ package topology import ( - "code.google.com/p/weed-fs/go/sequence" - "code.google.com/p/weed-fs/go/storage" - "encoding/json" - "fmt" "testing" ) -var topologyLayout = ` -{ - "dc1":{ - "rack1":{ - "server1":{ - "volumes":[ - {"id":1, "size":12312}, - {"id":2, "size":12312}, - {"id":3, "size":12312} - ], - "limit":3 - }, - "server2":{ - "volumes":[ - {"id":4, "size":12312}, - {"id":5, "size":12312}, - {"id":6, "size":12312} - ], - "limit":10 - } - }, - "rack2":{ - "server1":{ - "volumes":[ - {"id":4, "size":12312}, - {"id":5, "size":12312}, - {"id":6, "size":12312} - ], - "limit":4 - }, - "server2":{ - "volumes":[], - "limit":4 - }, - "server3":{ - "volumes":[ - {"id":2, "size":12312}, - {"id":3, "size":12312}, - {"id":4, "size":12312} - ], - "limit":2 - } - } - }, - "dc2":{ - }, - "dc3":{ - "rack2":{ - "server1":{ - "volumes":[ - {"id":1, "size":12312}, - {"id":3, "size":12312}, - {"id":5, "size":12312} - ], - "limit":4 - } - } - } -} -` - -func setup(topologyLayout string) *Topology { - var data interface{} - err := json.Unmarshal([]byte(topologyLayout), &data) - if err != nil { - fmt.Println("error:", err) - } - - //need to connect all nodes first before server adding volumes - topo, err := NewTopology("mynetwork", "/etc/weed.conf", sequence.NewMemorySequencer(), 234, 5) - if err != nil { - fmt.Println("error:", err) - } - mTopology := data.(map[string]interface{}) - for dcKey, dcValue := range mTopology { - dc := NewDataCenter(dcKey) - dcMap := dcValue.(map[string]interface{}) - topo.LinkChildNode(dc) - for rackKey, rackValue := range dcMap { - rack := NewRack(rackKey) - rackMap := rackValue.(map[string]interface{}) - dc.LinkChildNode(rack) - for serverKey, serverValue := range rackMap { - server := NewDataNode(serverKey) - serverMap := serverValue.(map[string]interface{}) - rack.LinkChildNode(server) - for _, v := range serverMap["volumes"].([]interface{}) { - m := v.(map[string]interface{}) - vi := storage.VolumeInfo{ - Id: storage.VolumeId(int64(m["id"].(float64))), - Size: uint64(m["size"].(float64)), - Collection: "testingCollection", - Version: storage.CurrentVersion} - server.AddOrUpdateVolume(vi) - } - server.UpAdjustMaxVolumeCountDelta(int(serverMap["limit"].(float64))) - } - } - } - - return topo -} - func TestRemoveDataCenter(t *testing.T) { topo := setup(topologyLayout) topo.UnlinkChildNode(NodeId("dc2")) diff --git a/go/topology/volume_growth_test.go b/go/topology/volume_growth_test.go index 7f6bd9489..d2913ef5c 100644 --- a/go/topology/volume_growth_test.go +++ b/go/topology/volume_growth_test.go @@ -116,7 +116,14 @@ func TestFindEmptySlotsForOneVolume(t *testing.T) { topo := setup(topologyLayout) vg := NewDefaultVolumeGrowth() rp, _ := storage.NewReplicaPlacementFromString("002") - servers, err := vg.findEmptySlotsForOneVolume(topo, "dc1", rp) + volumeGrowOption := &VolumeGrowOption{ + Collection: "", + ReplicaPlacement: rp, + DataCenter: "dc1", + Rack: "", + DataNode: "", + } + servers, err := vg.findEmptySlotsForOneVolume(topo, volumeGrowOption) if err != nil { fmt.Println("finding empty slots error :", err) t.Fail()