Skip to content

Commit e29b975

Browse files
deal with extremely small resource rate (#456)
1 parent 1ce0832 commit e29b975

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

strategy/global_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,32 @@ func TestGlobal3(t *testing.T) {
7878
assert.NoError(t, err)
7979
assert.Equal(t, r["n1"], 10)
8080
}
81+
82+
func TestGlobalIssue455(t *testing.T) {
83+
infos := []Info{
84+
{
85+
Nodename: "spp-qa-vm-node-1",
86+
Usage: 0.07999999999999996,
87+
Rate: 3.725290298461914e-08,
88+
Capacity: 10726691,
89+
Count: 7,
90+
},
91+
{
92+
Nodename: "spp-qa-vm-node-2",
93+
Usage: 0.24,
94+
Rate: 3.725290298461914e-08,
95+
Capacity: 4290676,
96+
Count: 5,
97+
},
98+
{
99+
Nodename: "spp-qa-vm-node-3",
100+
Usage: 0.45999999999999996,
101+
Rate: 3.725290298461914e-08,
102+
Capacity: 4290676,
103+
Count: 6,
104+
},
105+
}
106+
deployMap, err := GlobalPlan(context.TODO(), infos, 1, 19308043, 1)
107+
assert.NoError(t, err)
108+
assert.EqualValues(t, 1, deployMap["spp-qa-vm-node-1"])
109+
}

types/helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import "math"
44

55
// Round for float64 to int
66
func Round(f float64) float64 {
7-
return math.Round(f*1000000) / 1000000
7+
return math.Round(f*1000000000) / 1000000000
88
}

0 commit comments

Comments
 (0)