Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-1978] Add e2e test for node sorting with the fairness policy #673

Closed
wants to merge 4 commits into from

Conversation

wusamzong
Copy link
Contributor

What is this PR for?

Create test cases for both the base case and the case with resource weights added.

What type of PR is it?

  • - Test

What is the Jira issue?

How should this be tested?

Screenshots (if appropriate)

Questions:

  • - The licenses files need update.
  • - There is breaking changes for older versions.
  • - It needs documentation.

@wusamzong wusamzong self-assigned this Sep 14, 2023
@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #673 (b193a6b) into master (56c159c) will increase coverage by 0.02%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #673      +/-   ##
==========================================
+ Coverage   71.90%   71.92%   +0.02%     
==========================================
  Files          51       51              
  Lines        8082     8082              
==========================================
+ Hits         5811     5813       +2     
+ Misses       2075     2073       -2     
  Partials      196      196              

see 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@wusamzong wusamzong closed this Sep 14, 2023
@wusamzong wusamzong reopened this Sep 14, 2023
Copy link
Contributor

@pbacsko pbacsko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments.

workerID1,
workerID2,
}
increaseUtiliz := []map[string]float64{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use the full word in the variable name, eg. increaseUtilization. Or perhaps incUtilization.

Comment on lines +399 to +402
{"vcore": 0.05, "memory": 0.10},
{"vcore": 0.10, "memory": 0.05},
{"vcore": 0.15, "memory": 0.15},
{"vcore": 0.15, "memory": 0.15},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract constants, not just here, but everywhere in this file. These literals are repeated way too often.

})
})

func fillNodeUtil(nodeId string, resourceType string, percent float64) int64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the function, it calulates something, but what? I suppose it's something based on a percentage. It could be sth like getFillResourceValue().
Add a comment to make this clear.

Comment on lines +436 to +441
// Delete all sleep pods
ginkgo.By("Delete all sleep pods")
err := kClient.DeletePods(ns)
if err != nil {
fmt.Fprintf(ginkgo.GinkgoWriter, "Failed to delete pods in namespace %s - reason is %s\n", ns, err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this and run all tests in separate namespace. Running multiple tests in the same namespace is asking for trouble. See #753 as an example.

Comment on lines +69 to +72
ginkgo.By("create development namespace")
namespace, err = kClient.CreateNamespace(ns, nil)
gomega.Ω(err).NotTo(gomega.HaveOccurred())
gomega.Ω(namespace.Status.Phase).To(gomega.Equal(v1.NamespaceActive))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this and run all tests in a separate namespace. Running multiple tests in the same namespace is asking for trouble. See #753 as an example.

var namespace *v1.Namespace
var err error
var queuePath string
var basicUtiliz float64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use the full word in the variable name, eg. basicUtilization. This sounds a bit strange to me.

Comment on lines +108 to +109
memUtiliz := 1.0 - float64(node.Available["memory"])/float64(node.Capacity["memory"])
cpuUtiliz := 1.0 - float64(node.Available["vcore"])/float64(node.Capacity["vcore"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "memUsage", "cpuUsage", etc.

Comment on lines +129 to +132
By(fmt.Sprintf("Creating test namespace %s", ns))
namespace, err = kClient.UpdateNamespace(ns, map[string]string{"vcore": "500m", "memory": "500M"})
Ω(err).ShouldNot(HaveOccurred())
Ω(namespace.Status.Phase).Should(Equal(v1.NamespaceActive))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explained, create this in BeforeEach() and clean up in AfterEach().

@pbacsko
Copy link
Contributor

pbacsko commented Dec 27, 2023

I added comments to the JIRA. Testing this with e2e might not be the best place. Messing around with taints to check node ordering is a hassle. I'm not giving -1 right now, but we need to make sure that we validate things on the right abstraction level.

Consider moving this to the scheduler-core using MockScheduler. Check examples under core pkg/scheduler/tests.

It's probably even better to start with partition_test.go. I can imagine a test case like TestFairnessPolicyAllocation and TestBinPackingAllocation. It becomes a much faster and stabler test.

@wusamzong
Copy link
Contributor Author

@pbacsko Thank you for your insightful review. I understand your concerns. I'll close the current PR and create a new JIRA issue to focus on unit testing.

@wusamzong wusamzong closed this Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants