manirajv06 commented on code in PR #1102:
URL: https://github.com/apache/yunikorn-core/pull/1102#discussion_r3550613096


##########
pkg/scheduler/objects/queue_test.go:
##########
@@ -2015,6 +2015,50 @@ func TestGetPartitionQueueDAOInfo(t *testing.T) {
        assert.Equal(t, leafDAO.SortingPolicy, "fifo", "incorrect policy 
returned")
 }
 
+func TestGetPartitionQueueDAOInfoBackoffAndQuotaPreemptionFields(t *testing.T) 
{
+       root, err := createRootQueue(nil)
+       assert.NilError(t, err, "failed to create basic root queue")
+
+       t.Run("default values", func(t *testing.T) {
+               rootDAO := root.GetPartitionQueueDAOInfo(false)
+               assert.Assert(t, rootDAO.QuotaPreemptionStartTime.IsZero(), 
"quota preemption start time should be zero by default")
+               assert.Equal(t, rootDAO.IsQuotaPreemptionRunning, false, "quota 
preemption should not be running by default")
+               assert.Equal(t, rootDAO.UnschedAskBackoff, uint64(0), "unsched 
ask backoff should be zero by default")
+               assert.Equal(t, rootDAO.AskBackoffDelay, 
configs.DefaultAskBackOffDelay.String(), "ask backoff delay should use default")
+       })
+
+       t.Run("configured backoff properties", func(t *testing.T) {
+               props := map[string]string{
+                       configs.ApplicationUnschedulableAsksBackoffDelay: 
"123s",
+                       configs.ApplicationUnschedulableAsksBackoff:      "12",
+               }
+               queue, err := createManagedQueueWithProps(root, 
"backoff-queue", false, nil, props)
+               assert.NilError(t, err, "failed to create queue with backoff 
properties")
+               queueDAO := queue.GetPartitionQueueDAOInfo(false)
+               assert.Equal(t, queueDAO.UnschedAskBackoff, uint64(12), 
"unsched ask backoff not exposed correctly")
+               assert.Equal(t, queueDAO.AskBackoffDelay, (123 * 
time.Second).String(), "ask backoff delay not exposed correctly")
+               assert.Equal(t, queueDAO.IsQuotaPreemptionRunning, false, 
"quota preemption should not be running")
+               assert.Assert(t, queueDAO.QuotaPreemptionStartTime.IsZero(), 
"quota preemption start time should be zero")
+       })
+
+       t.Run("quota preemption runtime fields", func(t *testing.T) {
+               queue, err := createManagedQueue(root, "quota-queue", false, 
map[string]string{"memory": "1000"})
+               assert.NilError(t, err, "failed to create queue")
+               startTime := time.Now().Add(time.Hour)
+               queue.quotaPreemptionStartTime = startTime
+               queue.isQuotaPreemptionRunning = true
+
+               queueDAO := queue.GetPartitionQueueDAOInfo(false)
+               assert.Equal(t, queueDAO.QuotaPreemptionStartTime, startTime, 
"quota preemption start time not exposed correctly")
+               assert.Equal(t, queueDAO.IsQuotaPreemptionRunning, true, "quota 
preemption running flag not exposed correctly")
+
+               queue.setQuotaPreemptionState(false)
+               queueDAO = queue.GetPartitionQueueDAOInfo(false)
+               assert.Assert(t, queueDAO.QuotaPreemptionStartTime.IsZero(), 
"quota preemption start time should be cleared")
+               assert.Equal(t, queueDAO.IsQuotaPreemptionRunning, false, 
"quota preemption running flag should be cleared")
+       })
+}

Review Comment:
   Same comment. We can have a test for queue with default settings as well



##########
pkg/scheduler/objects/queue_test.go:
##########
@@ -2015,6 +2015,50 @@ func TestGetPartitionQueueDAOInfo(t *testing.T) {
        assert.Equal(t, leafDAO.SortingPolicy, "fifo", "incorrect policy 
returned")
 }
 
+func TestGetPartitionQueueDAOInfoBackoffAndQuotaPreemptionFields(t *testing.T) 
{
+       root, err := createRootQueue(nil)
+       assert.NilError(t, err, "failed to create basic root queue")
+
+       t.Run("default values", func(t *testing.T) {
+               rootDAO := root.GetPartitionQueueDAOInfo(false)
+               assert.Assert(t, rootDAO.QuotaPreemptionStartTime.IsZero(), 
"quota preemption start time should be zero by default")
+               assert.Equal(t, rootDAO.IsQuotaPreemptionRunning, false, "quota 
preemption should not be running by default")
+               assert.Equal(t, rootDAO.UnschedAskBackoff, uint64(0), "unsched 
ask backoff should be zero by default")
+               assert.Equal(t, rootDAO.AskBackoffDelay, 
configs.DefaultAskBackOffDelay.String(), "ask backoff delay should use default")
+       })
+
+       t.Run("configured backoff properties", func(t *testing.T) {
+               props := map[string]string{
+                       configs.ApplicationUnschedulableAsksBackoffDelay: 
"123s",
+                       configs.ApplicationUnschedulableAsksBackoff:      "12",
+               }
+               queue, err := createManagedQueueWithProps(root, 
"backoff-queue", false, nil, props)
+               assert.NilError(t, err, "failed to create queue with backoff 
properties")
+               queueDAO := queue.GetPartitionQueueDAOInfo(false)
+               assert.Equal(t, queueDAO.UnschedAskBackoff, uint64(12), 
"unsched ask backoff not exposed correctly")
+               assert.Equal(t, queueDAO.AskBackoffDelay, (123 * 
time.Second).String(), "ask backoff delay not exposed correctly")
+               assert.Equal(t, queueDAO.IsQuotaPreemptionRunning, false, 
"quota preemption should not be running")
+               assert.Assert(t, queueDAO.QuotaPreemptionStartTime.IsZero(), 
"quota preemption start time should be zero")
+       })

Review Comment:
   Can we pass queue itself and other expected output as input to this test run 
to avoid repeating these multiple asserts?
   
   ```
        var tests = []struct {
                testName         string
                input1 string
           input2 string
           expectedOutput    string
        }{
                {"example", "test1", "test2", "test1test2"
        }
        for _, tt := range tests {
                t.Run(tt.testName, func(t *testing.T) {
           // assert expected output
           });
        }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to