From 6d96e111c8e15081c36bf0448745cb3eb73b1cb4 Mon Sep 17 00:00:00 2001 From: Nicholas Orlowsky Date: Tue, 25 Apr 2023 19:24:34 -0500 Subject: [PATCH] try to figure out testing flags --- Makefile | 2 +- pkg/util/runtime/cpu_linux.go | 4 +++ pkg/util/runtime/cpu_notlinux.go | 4 +++ test/e2e/cgroups/cgroups.go | 58 -------------------------------- 4 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 test/e2e/cgroups/cgroups.go diff --git a/Makefile b/Makefile index 6037ac39d..357ef9827 100644 --- a/Makefile +++ b/Makefile @@ -167,7 +167,7 @@ kind-e2e-chart-tests: ## Run helm chart e2e tests e2e-test-binary: ## Build binary for e2e tests. @build/run-in-docker.sh \ MAC_OS=$(MAC_OS) \ - ginkgo build ./test/e2e + ginkgo build ./test/e2e -tags linux .PHONY: print-e2e-suite print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests. diff --git a/pkg/util/runtime/cpu_linux.go b/pkg/util/runtime/cpu_linux.go index c72f47f01..e5e8db40a 100644 --- a/pkg/util/runtime/cpu_linux.go +++ b/pkg/util/runtime/cpu_linux.go @@ -60,6 +60,10 @@ func NumCPU() int { return int(math.Ceil(float64(cpuQuota) / float64(cpuPeriod))) } +func IsCgroupAvaliable() bool { + return true +} + func getCgroupVersion() int64 { // /sys/fs/cgroup/cgroup.controllers will not exist with cgroupsv1 if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil { diff --git a/pkg/util/runtime/cpu_notlinux.go b/pkg/util/runtime/cpu_notlinux.go index 2a1b48252..3c4c6718b 100644 --- a/pkg/util/runtime/cpu_notlinux.go +++ b/pkg/util/runtime/cpu_notlinux.go @@ -27,3 +27,7 @@ import ( func NumCPU() int { return runtime.NumCPU() } + +func IsCgroupAvaliable() bool { + return false +} diff --git a/test/e2e/cgroups/cgroups.go b/test/e2e/cgroups/cgroups.go deleted file mode 100644 index 4ee6bf927..000000000 --- a/test/e2e/cgroups/cgroups.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed 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 cgroups - -import ( - "log" - "os" - - "github.com/onsi/ginkgo/v2" - "github.com/stretchr/testify/assert" - - "k8s.io/ingress-nginx/test/e2e/framework" - - "k8s.io/ingress-nginx/pkg/util/runtime" -) - -var _ = framework.IngressNginxDescribeSerial("[CGroups] cgroups", func() { - f := framework.NewDefaultFramework("cgroups") - - ginkgo.BeforeEach(func() { - f.NewEchoDeployment() - f.NewSlowEchoDeployment() - }) - - ginkgo.It("detects cgroups version v1", func() { - assert.Equal(ginkgo.GinkgoT(), runtime.getCgroupVersion(), 1) - }) - - ginkgo.It("detects number of CPUs properly in cgroups v1", func() { - assert.Equal(ginkgo.GinkgoT(), runtime.NumCPU(), -1) - }) - - ginkgo.It("detects cgroups version v2", func() { - // create cgroups2 files - if err := os.MkdirAll("a/b/c/d", os.ModePerm); err != nil { - log.Fatal(err) - } - - }) - - ginkgo.It("detects number of CPUs properly in cgroups v2", func() { - assert.Equal(ginkgo.GinkgoT(), runtime.NumCPU(), -1) - }) -})