pbacsko commented on code in PR #608: URL: https://github.com/apache/yunikorn-k8shim/pull/608#discussion_r1218195576
########## test/e2e/preemption/preemption_test.go: ########## @@ -0,0 +1,337 @@ +/* + 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 preemption_test + +import ( + "fmt" + "strings" + "time" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + v1 "k8s.io/api/core/v1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/apache/yunikorn-k8shim/pkg/common/constants" + tests "github.com/apache/yunikorn-k8shim/test/e2e" + "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" +) + +var kClient k8s.KubeCtl +var restClient yunikorn.RClient +var ns *v1.Namespace +var dev = "dev" + common.RandSeq(5) +var oldConfigMap = new(v1.ConfigMap) +var annotation = "ann-" + common.RandSeq(10) + +// Nodes +var Worker = "" +var WorkerMemRes int64 +var sleepPodMemLimit int64 +var taintKey = "e2e_test_preemption" +var nodesToTaint []string + +// Queues +var preemptionQueueYamlFormat = ` +partitions: + - name: default + queues: + - name: root + submitacl: '*' + queues: + - name: sandbox1 + submitacl: '*' + properties: + preemption.delay: 1s + resources: + guaranteed: + memory: %dM + - name: sandbox2 + submitacl: '*' + properties: + preemption.policy: %s + preemption.delay: 1s + resources: + guaranteed: + memory: %dM +` + +var _ = ginkgo.BeforeSuite(func() { + // Initializing kubectl client + kClient = k8s.KubeCtl{} + Ω(kClient.SetClient()).To(gomega.BeNil()) + // Initializing rest client + restClient = yunikorn.RClient{} + Ω(restClient).NotTo(gomega.BeNil()) + + annotation = "ann-" + common.RandSeq(10) + yunikorn.EnsureYuniKornConfigsPresent() + yunikorn.UpdateConfigMapWrapper(oldConfigMap, "", annotation) + + ginkgo.By("Port-forward the scheduler pod") + var err = kClient.PortForwardYkSchedulerPod() + Ω(err).NotTo(gomega.HaveOccurred()) + + ginkgo.By("create development namespace") + ns, err = kClient.CreateNamespace(dev, nil) + gomega.Ω(err).NotTo(gomega.HaveOccurred()) + gomega.Ω(ns.Status.Phase).To(gomega.Equal(v1.NamespaceActive)) + + var nodes *v1.NodeList + nodes, err = kClient.GetNodes() + Ω(err).NotTo(gomega.HaveOccurred()) + Ω(len(nodes.Items)).NotTo(gomega.BeZero(), "Nodes cant be empty") + + // Extract node allocatable resources + for _, node := range nodes.Items { + // skip master if it's marked as such + node := node + if k8s.IsMasterNode(&node) || !k8s.IsComputeNode(&node) { + continue + } + if Worker == "" { + Worker = node.Name + } else { + nodesToTaint = append(nodesToTaint, node.Name) + } + } + Ω(Worker).NotTo(gomega.BeEmpty(), "Worker node not found") + + ginkgo.By("Tainting some nodes..") Review Comment: Do we need to taint nodes? If we have proper queue config (guaranteed, max), what happens if we don't do this? -- 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: reviews-unsubscr...@yunikorn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org