Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
wusamzong committed Sep 15, 2023
1 parent f0f0c07 commit b193a6b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/e2e/resource_fairness/resource_fairness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var workerID2 string
var namespace *v1.Namespace
var err error
var queuePath string
var highestUtili int64
var basicUtiliz float64

var maxCPU int64 = 500
var maxMem int64 = 500
Expand Down Expand Up @@ -105,11 +105,13 @@ var _ = BeforeSuite(func() {

for _, node := range *nodesDAOInfo {
if node.NodeID == workerID1 || node.NodeID == workerID2 {
if node.Utilized["memory"] > highestUtili {
highestUtili = node.Utilized["memory"]
memUtiliz := 1.0 - float64(node.Available["memory"])/float64(node.Capacity["memory"])
cpuUtiliz := 1.0 - float64(node.Available["vcore"])/float64(node.Capacity["vcore"])
if memUtiliz > basicUtiliz {
basicUtiliz = memUtiliz
}
if node.Utilized["vcore"] > highestUtili {
highestUtili = node.Utilized["vcore"]
if cpuUtiliz > basicUtiliz {
basicUtiliz = cpuUtiliz
}
}
}
Expand Down Expand Up @@ -302,14 +304,12 @@ var _ = Describe("FairScheduling:", func() {
workerID1,
workerID2,
}
basicUtiliz := float64(highestUtili) / 100
increaseUtiliz := []map[string]float64{
{"vcore": 0.05, "memory": 0.05},
{"vcore": 0.10, "memory": 0.10},
{"vcore": 0.15, "memory": 0.15},
{"vcore": 0.15, "memory": 0.15},
}

// Deploy pod
for idx, config := range sleepPodConfs {
ginkgo.By("Deploy the sleep pod " + config.Name)
Expand All @@ -319,7 +319,7 @@ var _ = Describe("FairScheduling:", func() {
Ω(podErr).NotTo(HaveOccurred())
_, err = kClient.CreatePod(initPod, ns)
Ω(err).NotTo(HaveOccurred())
err = kClient.WaitForPodRunning(ns, config.Name, 3600*time.Second)
err = kClient.WaitForPodRunning(ns, config.Name, 60*time.Second)
Ω(err).NotTo(HaveOccurred())
}

Expand Down Expand Up @@ -395,7 +395,6 @@ var _ = Describe("FairScheduling:", func() {
workerID1,
workerID2,
}
basicUtiliz := float64(highestUtili) / 100
increaseUtiliz := []map[string]float64{
{"vcore": 0.05, "memory": 0.10},
{"vcore": 0.10, "memory": 0.05},
Expand Down Expand Up @@ -446,6 +445,6 @@ var _ = Describe("FairScheduling:", func() {
func fillNodeUtil(nodeId string, resourceType string, percent float64) int64 {
node, err := restClient.GetNode(constants.DefaultPartition, nodeId)
Ω(err).NotTo(HaveOccurred())
fillingResource := percent*float64(node.Capacity[resourceType]) - float64(node.Allocated[resourceType])
fillingResource := percent*float64(node.Capacity[resourceType]) - float64(node.Allocated[resourceType]+node.Occupied[resourceType])
return int64(fillingResource)
}

0 comments on commit b193a6b

Please sign in to comment.