This is an automated email from the ASF dual-hosted git repository.

pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 12f40150 [YUNIKORN-2573] Flaky test 
TestUpdateNodeCapacityWithMultipleNodes (#862)
12f40150 is described below

commit 12f401503b71841a88a2653d608c2940682560be
Author: ArthurWang <[email protected]>
AuthorDate: Fri May 3 09:38:30 2024 +0200

    [YUNIKORN-2573] Flaky test TestUpdateNodeCapacityWithMultipleNodes (#862)
    
    Closes: #862
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/scheduler/tests/operation_test.go | 11 +++++------
 pkg/scheduler/tests/utilities_test.go |  7 +++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/pkg/scheduler/tests/operation_test.go 
b/pkg/scheduler/tests/operation_test.go
index 49e55a19..0337ac89 100644
--- a/pkg/scheduler/tests/operation_test.go
+++ b/pkg/scheduler/tests/operation_test.go
@@ -517,14 +517,14 @@ partitions:
                RmID: "rm:123",
        })
        assert.NilError(t, err, "NodeRequest failed")
+
        waitForAvailableNodeResource(t, ms.scheduler.GetClusterContext(), 
"[rm:123]default",
                []string{"node-2:1234"}, 50000000, 1000)
+       waitForUpdatePartitionResource(t, partitionInfo, common.Memory, 
150000000, 1000)
+       waitForUpdatePartitionResource(t, partitionInfo, common.CPU, 30000, 
1000)
 
        newRes, err := 
resources.NewResourceFromConf(map[string]string{"memory": "150M", "vcore": 
"30"})
        assert.NilError(t, err, "failed to create resource")
-       if !resources.Equals(newRes, partitionInfo.GetTotalPartitionResource()) 
{
-               t.Errorf("Expected partition resource %s, doesn't match with 
actual partition resource %s", newRes, 
partitionInfo.GetTotalPartitionResource())
-       }
 
        if !resources.Equals(newRes, 
partitionInfo.GetQueue("root").GetMaxResource()) {
                t.Errorf("Expected partition resource %s, doesn't match with 
actual partition resource %s", newRes, 
partitionInfo.GetQueue("root").GetMaxResource())
@@ -552,12 +552,11 @@ partitions:
 
        waitForAvailableNodeResource(t, ms.scheduler.GetClusterContext(), 
"[rm:123]default",
                []string{"node-2:1234"}, 50000000, 1000)
+       waitForUpdatePartitionResource(t, partitionInfo, common.Memory, 
150000000, 1000)
+       waitForUpdatePartitionResource(t, partitionInfo, common.CPU, 30000, 
1000)
 
        newRes, err = resources.NewResourceFromConf(map[string]string{"memory": 
"150M", "vcore": "30"})
        assert.NilError(t, err, "failed to create resource")
-       if !resources.Equals(newRes, partitionInfo.GetTotalPartitionResource()) 
{
-               t.Errorf("Expected partition resource %s, doesn't match with 
actual partition resource %s", newRes, 
partitionInfo.GetTotalPartitionResource())
-       }
 
        if !resources.Equals(newRes, 
partitionInfo.GetQueue("root").GetMaxResource()) {
                t.Errorf("Expected partition resource %s, doesn't match with 
actual partition resource %s", newRes, 
partitionInfo.GetQueue("root").GetMaxResource())
diff --git a/pkg/scheduler/tests/utilities_test.go 
b/pkg/scheduler/tests/utilities_test.go
index df493517..0c40370a 100644
--- a/pkg/scheduler/tests/utilities_test.go
+++ b/pkg/scheduler/tests/utilities_test.go
@@ -131,6 +131,13 @@ func waitForRemovedNode(t *testing.T, context 
*scheduler.ClusterContext, nodeID
        assert.NilError(t, err, "Failed to wait for removal of scheduling node 
on partition %s, node %v, called from: %s", partitionName, nodeID, caller())
 }
 
+func waitForUpdatePartitionResource(t *testing.T, pc 
*scheduler.PartitionContext, resourcesName string, availableQuantity 
resources.Quantity, timeoutMs int) {
+       err := common.WaitFor(10*time.Millisecond, 
time.Duration(timeoutMs)*time.Millisecond, func() bool {
+               return pc.GetTotalPartitionResource().Resources[resourcesName] 
== availableQuantity
+       })
+       assert.NilError(t, err, "Failed to wait for available resource %v with 
target quantity %v, called from: %s", resourcesName, availableQuantity, 
caller())
+}
+
 func getApplication(pc *scheduler.PartitionContext, appID string) 
(*objects.Application, error) {
        for _, app := range pc.GetApplications() {
                if app.ApplicationID == appID {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to