Skip to content

Commit

Permalink
Remove redundant cluster version check in e2e tests
Browse files Browse the repository at this point in the history
- Kubernetes 1.22 is already end of life
- Also improve test description

Co-authored-by: Danail Branekov <danailster@gmail.com>
  • Loading branch information
georgethebeatle and danail-branekov committed Aug 17, 2023
1 parent 3ee700c commit 90bbe0a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
5 changes: 1 addition & 4 deletions scripts/create-new-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ createCert() {
-nodes \
-subj "/CN=${username}" 2>/dev/null

# note: we need 'validate=false' here in order to install on k8s clusters with
# version <= 1.21, which don't support expirationSeconds. Those environments will
# end up with long-lived certificates.
cat <<EOF | kubectl create --validate=false -f -
cat <<EOF | kubectl create -f -
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
Expand Down
7 changes: 1 addition & 6 deletions tests/e2e/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ var _ = Describe("Orgs", func() {
))
})

It("doesn't set an HTTP warning header for long certs", func() {
clusterVersionMajor, clusterVersionMinor := helpers.GetClusterVersion()
if clusterVersionMajor < 1 || (clusterVersionMajor == 1 && clusterVersionMinor < 22) {
GinkgoWriter.Printf("Skipping certificate warning test as k8s v%d.%d doesn't support creation of short lived test client certificates\n", clusterVersionMajor, clusterVersionMinor)
return
}
It("doesn't set an HTTP warning header for short lived certs", func() {
Expect(resp.Header().Get("X-Cf-Warnings")).To(BeEmpty())
})

Expand Down
22 changes: 0 additions & 22 deletions tests/helpers/k8s.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package helpers

import (
"fmt"
"strconv"

. "github.com/onsi/ginkgo/v2" //lint:ignore ST1001 this is a test file
. "github.com/onsi/gomega" //lint:ignore ST1001 this is a test file
"k8s.io/client-go/kubernetes"
Expand All @@ -23,25 +20,6 @@ func getClientSet() *kubernetes.Clientset {
return clientSet
}

func GetClusterVersion() (int, int) {
GinkgoHelper()

serverVersion, err := getClientSet().ServerVersion()
Expect(err).NotTo(HaveOccurred())

majorVersion, err := strconv.Atoi(serverVersion.Major)
if err != nil {
Skip(fmt.Sprintf("cannot determine kubernetes server major version: %v", err))
}

minorVersion, err := strconv.Atoi(serverVersion.Minor)
if err != nil {
Skip(fmt.Sprintf("cannot determine kubernetes server minor version: %v", err))
}

return majorVersion, minorVersion
}

func AddUserToKubeConfig(userName, userToken string) {
GinkgoHelper()

Expand Down

0 comments on commit 90bbe0a

Please sign in to comment.