From c5dad5e46116382ef8ec02a648e9c48d0ef1ea19 Mon Sep 17 00:00:00 2001 From: Nicholas Orlowsky Date: Thu, 11 May 2023 21:03:12 -0400 Subject: [PATCH] removed e2e tests for cgroups2 and associated functions --- pkg/util/runtime/cpu_linux.go | 4 -- pkg/util/runtime/cpu_notlinux.go | 6 +-- test/e2e/cgroups/cgroups_linux.go | 65 ---------------------------- test/e2e/cgroups/cgroups_notlinux.go | 42 ------------------ test/e2e/e2e.go | 41 +++++++++--------- 5 files changed, 21 insertions(+), 137 deletions(-) delete mode 100644 test/e2e/cgroups/cgroups_linux.go delete mode 100644 test/e2e/cgroups/cgroups_notlinux.go diff --git a/pkg/util/runtime/cpu_linux.go b/pkg/util/runtime/cpu_linux.go index e5e8db40a..c72f47f01 100644 --- a/pkg/util/runtime/cpu_linux.go +++ b/pkg/util/runtime/cpu_linux.go @@ -60,10 +60,6 @@ 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 3c4c6718b..0441af957 100644 --- a/pkg/util/runtime/cpu_notlinux.go +++ b/pkg/util/runtime/cpu_notlinux.go @@ -26,8 +26,4 @@ import ( // NumCPU ... func NumCPU() int { return runtime.NumCPU() -} - -func IsCgroupAvaliable() bool { - return false -} +} \ No newline at end of file diff --git a/test/e2e/cgroups/cgroups_linux.go b/test/e2e/cgroups/cgroups_linux.go deleted file mode 100644 index 18b3f837b..000000000 --- a/test/e2e/cgroups/cgroups_linux.go +++ /dev/null @@ -1,65 +0,0 @@ -//go:build linux -// +build linux - -/* -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 if cgroups is avaliable", func() { - assert.Equal(ginkgo.GinkgoT(), runtime.IsCgroupAvaliable(), 1) - }) - - ginkgo.It("detects cgroups version v1", func() { - assert.Equal(ginkgo.GinkgoT(), runtime.readCgroupFileToInt64(), 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) - }) -}) diff --git a/test/e2e/cgroups/cgroups_notlinux.go b/test/e2e/cgroups/cgroups_notlinux.go deleted file mode 100644 index 483db52cc..000000000 --- a/test/e2e/cgroups/cgroups_notlinux.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build !linux -// +build !linux - -/* -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 ( - "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 is not avaliable", func() { - assert.True(ginkgo.GinkgoT(), !runtime.IsCgroupAvaliable()) - }) -}) diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index a671e8793..57b047230 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -29,27 +29,26 @@ import ( "k8s.io/ingress-nginx/test/e2e/framework" // tests to run - // _ "k8s.io/ingress-nginx/test/e2e/admission" - // _ "k8s.io/ingress-nginx/test/e2e/annotations" - // _ "k8s.io/ingress-nginx/test/e2e/annotations/modsecurity" - _ "k8s.io/ingress-nginx/test/e2e/cgroups" - // _ "k8s.io/ingress-nginx/test/e2e/dbg" - // _ "k8s.io/ingress-nginx/test/e2e/defaultbackend" - // _ "k8s.io/ingress-nginx/test/e2e/endpointslices" - // _ "k8s.io/ingress-nginx/test/e2e/gracefulshutdown" - // _ "k8s.io/ingress-nginx/test/e2e/ingress" - // _ "k8s.io/ingress-nginx/test/e2e/leaks" - // _ "k8s.io/ingress-nginx/test/e2e/loadbalance" - // _ "k8s.io/ingress-nginx/test/e2e/lua" - // _ "k8s.io/ingress-nginx/test/e2e/nginx" - // _ "k8s.io/ingress-nginx/test/e2e/security" - // _ "k8s.io/ingress-nginx/test/e2e/servicebackend" - // _ "k8s.io/ingress-nginx/test/e2e/settings" - // _ "k8s.io/ingress-nginx/test/e2e/settings/modsecurity" - // _ "k8s.io/ingress-nginx/test/e2e/settings/ocsp" - // _ "k8s.io/ingress-nginx/test/e2e/ssl" - // _ "k8s.io/ingress-nginx/test/e2e/status" - // _ "k8s.io/ingress-nginx/test/e2e/tcpudp" + _ "k8s.io/ingress-nginx/test/e2e/admission" + _ "k8s.io/ingress-nginx/test/e2e/annotations" + _ "k8s.io/ingress-nginx/test/e2e/annotations/modsecurity" + _ "k8s.io/ingress-nginx/test/e2e/dbg" + _ "k8s.io/ingress-nginx/test/e2e/defaultbackend" + _ "k8s.io/ingress-nginx/test/e2e/endpointslices" + _ "k8s.io/ingress-nginx/test/e2e/gracefulshutdown" + _ "k8s.io/ingress-nginx/test/e2e/ingress" + _ "k8s.io/ingress-nginx/test/e2e/leaks" + _ "k8s.io/ingress-nginx/test/e2e/loadbalance" + _ "k8s.io/ingress-nginx/test/e2e/lua" + _ "k8s.io/ingress-nginx/test/e2e/nginx" + _ "k8s.io/ingress-nginx/test/e2e/security" + _ "k8s.io/ingress-nginx/test/e2e/servicebackend" + _ "k8s.io/ingress-nginx/test/e2e/settings" + _ "k8s.io/ingress-nginx/test/e2e/settings/modsecurity" + _ "k8s.io/ingress-nginx/test/e2e/settings/ocsp" + _ "k8s.io/ingress-nginx/test/e2e/ssl" + _ "k8s.io/ingress-nginx/test/e2e/status" + _ "k8s.io/ingress-nginx/test/e2e/tcpudp" ) // RunE2ETests checks configuration parameters (specified through flags) and then runs