ryankert01 commented on code in PR #871:
URL: https://github.com/apache/yunikorn-k8shim/pull/871#discussion_r1689379686


##########
pkg/cache/task_test.go:
##########
@@ -704,6 +705,135 @@ func TestSimultaneousTaskCompleteAndAllocate(t 
*testing.T) {
        assert.Equal(t, task1.GetTaskState(), TaskStates().Completed)
 }
 
+// nolint: funlen
+func TestCheckTaskPodWithoutConflictMetadata(t *testing.T) {
+       const (
+               appID      = "app01"
+               app2ID     = "app02"
+               queueName  = "root.sandbox1"
+               queue2Name = "root.sandbox2"
+       )
+       var appIdInconsitentErr = fmt.Errorf("application ID is not 
consistently set in pod's labels and annotations. [%s]", 
constants.TaskPodInconsistMetadataFailure)
+       var queueInconsitentErr = fmt.Errorf("queue is not consistently set in 
pod's labels and annotations. [%s]", constants.TaskPodInconsistMetadataFailure)
+
+       testCases := []struct {
+               name           string
+               podLabels      map[string]string
+               podAnnotations map[string]string
+               expected       error
+       }{
+               {
+                       "empty label and empty annotation in pod", nil, nil, 
nil,
+               },
+               {
+                       "appId and queueName have no conflict",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApp:                    appID,
+                               constants.CanonicalLabelQueueName:     
queueName,
+                               constants.LabelQueueName:              
queueName,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                               constants.AnnotationQueueName:     queueName,
+                       },
+                       nil,
+               },
+               {
+                       "have conflict appId in canonical label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: app2ID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in spark label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             app2ID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in legacy label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          app2ID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in annotation",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: app2ID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in canonical label",

Review Comment:
   I think you mean `queueName`.



##########
pkg/cache/task_test.go:
##########
@@ -704,6 +705,135 @@ func TestSimultaneousTaskCompleteAndAllocate(t 
*testing.T) {
        assert.Equal(t, task1.GetTaskState(), TaskStates().Completed)
 }
 
+// nolint: funlen
+func TestCheckTaskPodWithoutConflictMetadata(t *testing.T) {
+       const (
+               appID      = "app01"
+               app2ID     = "app02"
+               queueName  = "root.sandbox1"
+               queue2Name = "root.sandbox2"
+       )
+       var appIdInconsitentErr = fmt.Errorf("application ID is not 
consistently set in pod's labels and annotations. [%s]", 
constants.TaskPodInconsistMetadataFailure)
+       var queueInconsitentErr = fmt.Errorf("queue is not consistently set in 
pod's labels and annotations. [%s]", constants.TaskPodInconsistMetadataFailure)
+
+       testCases := []struct {
+               name           string
+               podLabels      map[string]string
+               podAnnotations map[string]string
+               expected       error
+       }{
+               {
+                       "empty label and empty annotation in pod", nil, nil, 
nil,
+               },
+               {
+                       "appId and queueName have no conflict",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApp:                    appID,
+                               constants.CanonicalLabelQueueName:     
queueName,
+                               constants.LabelQueueName:              
queueName,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                               constants.AnnotationQueueName:     queueName,
+                       },
+                       nil,
+               },
+               {
+                       "have conflict appId in canonical label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: app2ID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in spark label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             app2ID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in legacy label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          app2ID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in annotation",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: app2ID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in canonical label",
+                       map[string]string{
+                               constants.CanonicalLabelQueueName: queue2Name,
+                               constants.LabelQueueName:          queueName,
+                       }, map[string]string{
+                               constants.AnnotationQueueName: queueName,
+                       },
+                       queueInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in legacy label",

Review Comment:
   ditto.



##########
pkg/cache/task_test.go:
##########
@@ -704,6 +705,135 @@ func TestSimultaneousTaskCompleteAndAllocate(t 
*testing.T) {
        assert.Equal(t, task1.GetTaskState(), TaskStates().Completed)
 }
 
+// nolint: funlen
+func TestCheckTaskPodWithoutConflictMetadata(t *testing.T) {
+       const (
+               appID      = "app01"
+               app2ID     = "app02"
+               queueName  = "root.sandbox1"
+               queue2Name = "root.sandbox2"
+       )
+       var appIdInconsitentErr = fmt.Errorf("application ID is not 
consistently set in pod's labels and annotations. [%s]", 
constants.TaskPodInconsistMetadataFailure)
+       var queueInconsitentErr = fmt.Errorf("queue is not consistently set in 
pod's labels and annotations. [%s]", constants.TaskPodInconsistMetadataFailure)
+
+       testCases := []struct {
+               name           string
+               podLabels      map[string]string
+               podAnnotations map[string]string
+               expected       error
+       }{
+               {
+                       "empty label and empty annotation in pod", nil, nil, 
nil,
+               },
+               {
+                       "appId and queueName have no conflict",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApp:                    appID,
+                               constants.CanonicalLabelQueueName:     
queueName,
+                               constants.LabelQueueName:              
queueName,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                               constants.AnnotationQueueName:     queueName,
+                       },
+                       nil,
+               },
+               {
+                       "have conflict appId in canonical label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: app2ID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in spark label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             app2ID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in legacy label",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          app2ID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: appID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict appId in annotation",
+                       map[string]string{
+                               constants.CanonicalLabelApplicationID: appID,
+                               constants.SparkLabelAppID:             appID,
+                               constants.LabelApplicationID:          appID,
+                       }, map[string]string{
+                               constants.AnnotationApplicationID: app2ID,
+                       },
+                       appIdInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in canonical label",
+                       map[string]string{
+                               constants.CanonicalLabelQueueName: queue2Name,
+                               constants.LabelQueueName:          queueName,
+                       }, map[string]string{
+                               constants.AnnotationQueueName: queueName,
+                       },
+                       queueInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in legacy label",
+                       map[string]string{
+                               constants.CanonicalLabelQueueName: queueName,
+                               constants.LabelQueueName:          queue2Name,
+                       }, map[string]string{
+                               constants.AnnotationQueueName: queueName,
+                       },
+                       queueInconsitentErr,
+               },
+               {
+                       "have conflict queueNmae in annotation",

Review Comment:
   ditto



-- 
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