Skip to content

Commit

Permalink
fix the bugs of 'make test' and 'getFullResult' (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
DuodenumL authored Nov 10, 2021
1 parent 7513bc0 commit a0b6f3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cloc:
cloc --exclude-dir=vendor,3rdmocks,mocks,tools,gen --not-match-f=test .

unit-test:
go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'`
go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'` && \
go test -race -timeout 240s -count=1 -cover ./utils/... \
./types/... \
./store/etcdv3/. \
Expand All @@ -66,7 +66,7 @@ unit-test:
./wal/. \
./wal/kv/. \
./store/redis/... \
./lock/redis/...
./lock/redis/... && \
go test -timeout 240s -count=1 -cover ./cluster/calcium/...

lint:
Expand Down
22 changes: 16 additions & 6 deletions scheduler/complex/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,23 @@ func (h *host) getFragmentsResult(resources []resourceInfo, fragments ...int64)
func (h *host) getFullResult(full int, resources []resourceInfo) []types.ResourceMap {
result := []types.ResourceMap{}

count := len(resources) / full
for i := 0; i < count; i++ {
plan := types.ResourceMap{}
for j := i * full; j < i*full+full; j++ {
plan[resources[j].id] = int64(h.share)
for len(resources)/full > 0 {
count, rem := len(resources)/full, len(resources)%full
newResources := []resourceInfo{}
for i := 0; i < count; i++ {
plan := types.ResourceMap{}
for j := i * full; j < i*full+full; j++ {
// 洗掉没配额的
last := resources[j].pieces - int64(h.share)
if last > 0 {
newResources = append(newResources, resourceInfo{resources[j].id, last})
}
plan[resources[j].id] = int64(h.share)
}
result = append(result, plan)
}
result = append(result, plan)

resources = append(newResources, resources[len(resources)-rem:]...)
}

return result
Expand Down

0 comments on commit a0b6f3a

Please sign in to comment.