craigcondit commented on code in PR #423:
URL: https://github.com/apache/yunikorn-k8shim/pull/423#discussion_r890396007


##########
test/Wrappers.go:
##########
@@ -0,0 +1,117 @@
+/*

Review Comment:
   this file should be named `wrappers.go` (lowercase).



##########
test/Wrappers.go:
##########
@@ -0,0 +1,117 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package tests
+
+import (
+       "time"
+
+       "gopkg.in/yaml.v2"
+       v1 "k8s.io/api/core/v1"
+
+       "github.com/apache/yunikorn-core/pkg/common/configs"
+
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/configmanager"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/common"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/k8s"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/yunikorn"
+
+       "github.com/onsi/ginkgo"
+       "github.com/onsi/gomega"
+)
+
+var k = k8s.KubeCtl{}
+
+func UpdateConfigMapWrapper(oldConfigMap *v1.ConfigMap, schedPolicy string, 
annotation string) {
+       Ω(k.SetClient()).To(BeNil())
+       By("Port-forward the scheduler pod")
+       fwdErr := k.PortForwardYkSchedulerPod()
+       Ω(fwdErr).NotTo(HaveOccurred())
+
+       By("Enabling new scheduling config")
+
+       // Save old configMap
+       Ω(k.SetClient()).To(BeNil())
+       var c, err = 
k.GetConfigMaps(configmanager.YuniKornTestConfig.YkNamespace,
+               configmanager.DefaultYuniKornConfigMap)
+       Ω(err).NotTo(HaveOccurred())
+       Ω(c).NotTo(BeNil())
+       c.DeepCopyInto(oldConfigMap)
+       Ω(c).Should(BeEquivalentTo(oldConfigMap))
+
+       // Create configMap with timestamp + schedPolicy
+       sc := common.CreateBasicConfigMap()
+       if schedPolicy != "" {
+               err = common.SetSchedulingPolicy(sc, "default", "root", 
schedPolicy)
+               Ω(err).NotTo(HaveOccurred())
+       }
+       ts, tsErr := common.SetQueueTimestamp(sc, "default", "root")
+       Ω(tsErr).NotTo(HaveOccurred())
+       configStr, yamlErr := common.ToYAML(sc)
+       Ω(yamlErr).NotTo(HaveOccurred())
+       c.Data[configmanager.DefaultPolicyGroup] = configStr
+       var d, err3 = k.UpdateConfigMap(c, 
configmanager.YuniKornTestConfig.YkNamespace)
+       Ω(err3).NotTo(HaveOccurred())
+       Ω(d).NotTo(BeNil())
+
+       // Updating scheduler pod annotation to trigger force refresh of 
configmaps
+       // YUNIKORN-334
+       
Ω(k.UpdateYunikornSchedulerPodAnnotation(annotation)).NotTo(HaveOccurred())
+       err = yunikorn.WaitForQueueTS("root", ts, 2*time.Minute)
+       Ω(err).NotTo(HaveOccurred())
+}
+
+func RestoreConfigMapWrapper(oldConfigMap *v1.ConfigMap, annotation string) {
+       Ω(k.SetClient()).To(BeNil())
+       By("Restoring the old config maps")
+       var c, err = 
k.GetConfigMaps(configmanager.YuniKornTestConfig.YkNamespace,
+               configmanager.DefaultYuniKornConfigMap)
+       Ω(err).NotTo(HaveOccurred())
+       Ω(c).NotTo(BeNil())
+
+       oldSC := new(configs.SchedulerConfig)
+       err = 
yaml.Unmarshal([]byte(oldConfigMap.Data[configmanager.DefaultPolicyGroup]), 
oldSC)
+       Ω(err).NotTo(HaveOccurred())
+       ts, tsErr := common.SetQueueTimestamp(oldSC, "default", "root")
+       Ω(tsErr).NotTo(HaveOccurred())
+       c.Data[configmanager.DefaultPolicyGroup], err = common.ToYAML(oldSC)
+       Ω(err).NotTo(HaveOccurred())
+
+       var e, err3 = k.UpdateConfigMap(c, 
configmanager.YuniKornTestConfig.YkNamespace)
+       Ω(err3).NotTo(HaveOccurred())
+       Ω(e).NotTo(BeNil())
+       // Updating scheduler pod annotation to trigger force refresh of 
configmaps
+       // YUNIKORN-334

Review Comment:
   See previous comment.



##########
go.mod:
##########
@@ -32,6 +32,7 @@ require (
        github.com/spf13/cobra v1.1.1
        github.com/spf13/pflag v1.0.5
        go.uber.org/zap v1.13.0
+       golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba // indirect

Review Comment:
   Changes to go.mod / go.sum are not needed for this PR. Please remove them.



##########
test/e2e/framework/helpers/k8s/pod_conf.go:
##########
@@ -77,39 +79,46 @@ func InitSleepPod(conf SleepPodConfig) *v1.Pod {
 }
 
 type TestPodConfig struct {
-       Name                              string
-       Namespace                         string
-       Affinity                          *v1.Affinity
-       Annotations, Labels, NodeSelector map[string]string
-       Resources                         *v1.ResourceRequirements
-       RuntimeClassHandler               *string
-       Tolerations                       []v1.Toleration
-       NodeName                          string
-       Ports                             []v1.ContainerPort
-       OwnerReferences                   []metav1.OwnerReference
-       PriorityClassName                 string
-       DeletionGracePeriodSeconds        *int64
-       TopologySpreadConstraints         []v1.TopologySpreadConstraint
-       Image                             string
-       RestartPolicy                     v1.RestartPolicy
-       Command                           []string
+       Name                       string
+       Namespace                  string
+       Affinity                   *v1.Affinity
+       Annotations                *PodAnnotation
+       Labels, NodeSelector       map[string]string
+       Resources                  *v1.ResourceRequirements
+       RuntimeClassHandler        *string
+       Tolerations                []v1.Toleration
+       NodeName                   string
+       Ports                      []v1.ContainerPort
+       OwnerReferences            []metav1.OwnerReference
+       PriorityClassName          string
+       DeletionGracePeriodSeconds *int64
+       TopologySpreadConstraints  []v1.TopologySpreadConstraint
+       Image                      string
+       RestartPolicy              v1.RestartPolicy
+       Command                    []string
+       InitContainerSleepSecs     int
 }
 
-func InitTestPod(conf TestPodConfig) *v1.Pod {
+func InitTestPod(conf TestPodConfig) (*v1.Pod, error) { //nolint:funlen
        var gracePeriod = int64(1)
        if conf.Image == "" {
                conf.Image = "alpine:latest"
        }
        if conf.Command == nil {
-               conf.Command = []string{"sleep", "30"}
+               conf.Command = []string{"sleep", "300"}
+       }
+
+       PodAnnotation, err := PodAnnotationToMap(conf.Annotations)

Review Comment:
   Local variable should be lowercase.



##########
test/e2e/framework/configmanager/constants.go:
##########
@@ -29,11 +29,13 @@ const (
        // that contain logs, outputs etc
        LogPerm = os.FileMode(0666)
 
-       YKScheduler   = "yunikorn-scheduler"
-       SchedulerName = "yunikorn"
-       YKAdmCtrl     = "yunikorn-admission-controller"
+       YKScheduler          = "yunikorn-scheduler"
+       YKSchedulerContainer = "yunikorn-scheduler-k8s"
+       SchedulerName        = "yunikorn"
+       YKAdmCtrl            = "yunikorn-admission-controller"
        // YuniKorn service name

Review Comment:
   As long as we are cleaning up, comment should go to the right (not above) 
the variable.



##########
test/Wrappers.go:
##########
@@ -0,0 +1,117 @@
+/*

Review Comment:
   Also, as this seems to be shared code, can we move it under 
`framework/helpers` somewhere instead? Possibly `k8s` or `yunikorn`.



##########
test/Wrappers.go:
##########
@@ -0,0 +1,117 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package tests
+
+import (
+       "time"
+
+       "gopkg.in/yaml.v2"
+       v1 "k8s.io/api/core/v1"
+
+       "github.com/apache/yunikorn-core/pkg/common/configs"
+
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/configmanager"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/common"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/k8s"
+       "github.com/apache/yunikorn-k8shim/test/e2e/framework/helpers/yunikorn"
+
+       "github.com/onsi/ginkgo"
+       "github.com/onsi/gomega"
+)
+
+var k = k8s.KubeCtl{}
+
+func UpdateConfigMapWrapper(oldConfigMap *v1.ConfigMap, schedPolicy string, 
annotation string) {
+       Ω(k.SetClient()).To(BeNil())
+       By("Port-forward the scheduler pod")
+       fwdErr := k.PortForwardYkSchedulerPod()
+       Ω(fwdErr).NotTo(HaveOccurred())
+
+       By("Enabling new scheduling config")
+
+       // Save old configMap
+       Ω(k.SetClient()).To(BeNil())
+       var c, err = 
k.GetConfigMaps(configmanager.YuniKornTestConfig.YkNamespace,
+               configmanager.DefaultYuniKornConfigMap)
+       Ω(err).NotTo(HaveOccurred())
+       Ω(c).NotTo(BeNil())
+       c.DeepCopyInto(oldConfigMap)
+       Ω(c).Should(BeEquivalentTo(oldConfigMap))
+
+       // Create configMap with timestamp + schedPolicy
+       sc := common.CreateBasicConfigMap()
+       if schedPolicy != "" {
+               err = common.SetSchedulingPolicy(sc, "default", "root", 
schedPolicy)
+               Ω(err).NotTo(HaveOccurred())
+       }
+       ts, tsErr := common.SetQueueTimestamp(sc, "default", "root")
+       Ω(tsErr).NotTo(HaveOccurred())
+       configStr, yamlErr := common.ToYAML(sc)
+       Ω(yamlErr).NotTo(HaveOccurred())
+       c.Data[configmanager.DefaultPolicyGroup] = configStr
+       var d, err3 = k.UpdateConfigMap(c, 
configmanager.YuniKornTestConfig.YkNamespace)
+       Ω(err3).NotTo(HaveOccurred())
+       Ω(d).NotTo(BeNil())
+
+       // Updating scheduler pod annotation to trigger force refresh of 
configmaps
+       // YUNIKORN-334

Review Comment:
   Can we remove references to a JIRA that was never implemented?



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