Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer E2E stack traces #3382

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9189b9e
Add initial helpers.go
mociarain Jan 23, 2024
f40d93f
Apply to one file
mociarain Jan 23, 2024
4a68234
Update doc comment
mociarain Jan 23, 2024
fd86d27
Remove unneeded import
mociarain Jan 29, 2024
899d815
Leverage the type system for drier code
mociarain Jan 30, 2024
adbc182
Actually tease out a MVP
mociarain Jan 30, 2024
bfb9e3e
Tidy up the helpers
mociarain Jan 30, 2024
a53ee31
Attempt to conform to Go conventions
mociarain Jan 30, 2024
727c6cd
Update adminapi_delete_managedresources.go
mociarain Jan 30, 2024
9ced6d8
Add list function
mociarain Jan 30, 2024
05af225
Update adminapi_drainnode
mociarain Jan 30, 2024
00572ec
Update adminapi_kubernetesobjects.go
mociarain Jan 30, 2024
9817482
Fix typos
mociarain Jan 30, 2024
75b7801
Bring the helpers into the relevant file
mociarain Jan 31, 2024
cd80877
Update the other straightforward cases
mociarain Jan 31, 2024
8bf77a5
Lint
mociarain Jan 31, 2024
8f73072
Add a GetLogs helper
mociarain Jan 31, 2024
df725d4
Move project into the helpers
mociarain Jan 31, 2024
3e86f4e
Update dns.go
mociarain Jan 31, 2024
51034b4
Use consistent naming]
mociarain Jan 31, 2024
c130a65
Fix import ordering
mociarain Jan 31, 2024
2c3fbcd
Up the default time
mociarain Feb 1, 2024
892af82
Fix incorrect API
mociarain Feb 1, 2024
b9aa6bd
Increase verifyResolvConfTimeout
mociarain Feb 1, 2024
ebf3710
Clean up redeploymv.go
mociarain Feb 1, 2024
67dc78c
Reuse the same variable name for the same thing
mociarain Feb 2, 2024
a9bef33
s/(.*)Call/$1Func
mociarain Feb 5, 2024
0cf4271
Bind repeated string to a constant
mociarain Feb 5, 2024
da49ae8
Tidy up naming conventions and comments
mociarain Feb 5, 2024
60285e6
Add consistent cleanup logic
mociarain Feb 1, 2024
7840c2f
Tidy up post rebase
mociarain Feb 5, 2024
48dd855
Bump Ginkgo to 2.14.0
mociarain Feb 6, 2024
c62550c
Add GinkgoHelper to the helpers
mociarain Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang/mock v1.6.0
github.com/google/gnostic v0.5.7-v3refs
github.com/google/go-cmp v0.5.9
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.0
github.com/gorilla/csrf v1.7.1
github.com/gorilla/mux v1.8.0
Expand All @@ -51,8 +51,8 @@ require (
github.com/microsoft/kiota-serialization-multipart-go v1.0.0
github.com/microsoft/kiota-serialization-text-go v1.0.0
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0
github.com/onsi/ginkgo/v2 v2.7.0
github.com/onsi/gomega v1.26.0
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/open-policy-agent/frameworks/constraint v0.0.0-20221109005544-7de84dff5081
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible
Expand All @@ -77,9 +77,9 @@ require (
golang.org/x/crypto v0.18.0
golang.org/x/net v0.20.0
golang.org/x/oauth2 v0.10.0
golang.org/x/sync v0.3.0
golang.org/x/sync v0.5.0
golang.org/x/text v0.14.0
golang.org/x/tools v0.10.0
golang.org/x/tools v0.16.1
k8s.io/api v0.28.3
k8s.io/apiextensions-apiserver v0.25.0
k8s.io/apimachinery v0.28.3
Expand Down Expand Up @@ -156,7 +156,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/godbus/dbus/v5 v5.1.1-0.20221029134443-4b691ce883d5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -255,7 +255,7 @@ require (
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.starlark.net v0.0.0-20220328144851-d1966c6b9fcd // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
Expand Down Expand Up @@ -332,6 +334,8 @@ github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.14.0 h1:z58vMqHxuwvAsVwvKEkmVBz2TlgBgH5k6koEXBtlYkw=
github.com/google/go-containerregistry v0.14.0/go.mod h1:aiJ2fp/SXvkWgmYHioXnbMdlgB8eXiiYOY55gfN91Wk=
github.com/google/go-github/v27 v27.0.4/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0=
Expand Down Expand Up @@ -534,6 +538,8 @@ github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47
github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
github.com/onsi/ginkgo/v2 v2.7.0 h1:/XxtEV3I3Eif/HobnVx9YmJgk8ENdRsuUmM+fLCFNow=
github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY=
github.com/onsi/ginkgo/v2 v2.14.0/go.mod h1:JkUdW7JkN0V6rFvsHcJ478egV3XH9NxpD27Hal/PhZw=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
Expand All @@ -544,6 +550,8 @@ github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9
github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q=
github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/open-cluster-management/api v0.0.0-20210527013639-a6845f2ebcb1/go.mod h1:ot+A1DWq+v1IV+e1S7nhIteYAmNByFgtazvzpoeAfRQ=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20221109005544-7de84dff5081 h1:LcxhUNtgAf1dvHIDfOI/sO0LQALSxQCBHxTZ/5CrBxo=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20221109005544-7de84dff5081/go.mod h1:GUTpjwsUA3319pmI5srJxch5LyeBqb6fdcvLyS+O5qo=
Expand Down Expand Up @@ -757,12 +765,16 @@ golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8=
golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
Expand All @@ -773,6 +785,8 @@ golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg=
golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM=
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY=
gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
Expand Down
20 changes: 6 additions & 14 deletions test/e2e/adminapi_cluster_getlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,16 @@ func testGetPodLogsOK(ctx context.Context, containerName, podName, namespace str
expectedLog := "mock-pod-logs"

By("creating a test pod in openshift-azure-operator namespace with some known logs")
pod := mockPod(containerName, podName, namespace, expectedLog)
pod, err := clients.Kubernetes.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
podDefinition := mockPod(containerName, podName, namespace, expectedLog)
CreateK8sObjectWithRetry(
ctx, clients.Kubernetes.CoreV1().Pods(namespace).Create, podDefinition, metav1.CreateOptions{},
)

defer func() {
By("deleting the test pod")
err = clients.Kubernetes.CoreV1().Pods(namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
By("cleaning up the test pod")
CleanupK8sResource[*corev1.Pod](ctx, clients.Kubernetes.CoreV1().Pods(namespace), podName)
}()

By("waiting for the pod to successfully terminate")
Eventually(func(g Gomega, ctx context.Context) {
pod, err = clients.Kubernetes.CoreV1().Pods(namespace).Get(ctx, pod.Name, metav1.GetOptions{})
g.Expect(err).NotTo(HaveOccurred())

g.Expect(pod.Status.Phase).To(Equal(corev1.PodSucceeded))
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())

By("requesting logs via RP admin API")
params := url.Values{
"container": []string{containerName},
Expand Down
17 changes: 9 additions & 8 deletions test/e2e/adminapi_csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ var _ = Describe("[Admin API] CertificateSigningRequest action", func() {
By("creating mock CSRs via Kubernetes API")
for i := 0; i < csrCount; i++ {
csr := mockCSR(prefix+strconv.Itoa(i), namespace, csrData)
_, err := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Create(ctx, csr, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

createFunc := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Create
CreateK8sObjectWithRetry(ctx, createFunc, csr, metav1.CreateOptions{})
}
})

AfterEach(func(ctx context.Context) {
By("deleting the mock CSRs via Kubernetes API")
for i := 0; i < csrCount; i++ {
err := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Delete(ctx, prefix+strconv.Itoa(i), metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
deleteFunc := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Delete
DeleteK8sObjectWithRetry(ctx, deleteFunc, prefix+strconv.Itoa(i), metav1.DeleteOptions{})
}
})

Expand All @@ -70,8 +71,8 @@ func testCSRApproveOK(ctx context.Context, objName, namespace string) {
Expect(resp.StatusCode).To(Equal(http.StatusOK))

By("checking that the CSR was approved via Kubernetes API")
testcsr, err := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Get(ctx, objName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
getFunc := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Get
testcsr, _ := GetK8sObjectWithRetry(ctx, getFunc, objName, metav1.GetOptions{})

approved := false
for _, condition := range testcsr.Status.Conditions {
Expand All @@ -93,8 +94,8 @@ func testCSRMassApproveOK(ctx context.Context, namePrefix, namespace string, csr

By("checking that all CSRs were approved via Kubernetes API")
for i := 1; i < csrCount; i++ {
testcsr, err := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Get(ctx, namePrefix+strconv.Itoa(i), metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
getFunc := clients.Kubernetes.CertificatesV1().CertificateSigningRequests().Get
testcsr, _ := GetK8sObjectWithRetry(ctx, getFunc, namePrefix+strconv.Itoa(i), metav1.GetOptions{})

approved := false
for _, condition := range testcsr.Status.Conditions {
Expand Down
27 changes: 10 additions & 17 deletions test/e2e/adminapi_delete_managedresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/Azure/ARO-RP/pkg/util/stringutils"
Expand Down Expand Up @@ -45,29 +44,23 @@ var _ = Describe("[Admin API] Delete managed resource action", func() {
var fipConfigID string
var pipAddressID string

const namespace = "default"

By("creating a test service of type loadbalancer")
_, err := clients.Kubernetes.CoreV1().Services("default").Create(ctx, &loadBalancerService, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
creationFunc := clients.Kubernetes.CoreV1().Services("default").Create
CreateK8sObjectWithRetry(ctx, creationFunc, &loadBalancerService, metav1.CreateOptions{})

defer func() {
By("cleaning up the k8s loadbalancer service")
// wait for deletion to prevent flakes on retries
Eventually(func(g Gomega, ctx context.Context) {
err := clients.Kubernetes.CoreV1().Services("default").Delete(ctx, "test", metav1.DeleteOptions{})
g.Expect((err == nil || kerrors.IsNotFound(err))).To(BeTrue(), "expect Service to be deleted")
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())

By("confirming that the k8s loadbalancer service is gone")
Eventually(func(g Gomega, ctx context.Context) {
_, err := clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(kerrors.IsNotFound(err)).To(BeTrue())
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
CleanupK8sResource[*corev1.Service](
ctx, clients.Kubernetes.CoreV1().Services(namespace), loadBalancerService.Name,
)
}()

// wait for ingress IP to be assigned as this indicate the service is ready
Eventually(func(g Gomega, ctx context.Context) {
service, err = clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(err).NotTo(HaveOccurred())
getFunc := clients.Kubernetes.CoreV1().Services("default").Get
service, _ = GetK8sObjectWithRetry(ctx, getFunc, "test", metav1.GetOptions{})
g.Expect(service.Status.LoadBalancer.Ingress).To(HaveLen(1))
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())

Expand Down Expand Up @@ -115,7 +108,7 @@ var _ = Describe("[Admin API] Delete managed resource action", func() {
oc, err := clients.OpenshiftClustersPreview.Get(ctx, vnetResourceGroup, clusterName)
Expect(err).NotTo(HaveOccurred())

// Fake name prevents accidently deleting the PLS but still validates gaurdrail logic works.
// Fake name prevents accidentally deleting the PLS but still validates guardrail logic works.
plsResourceID := fmt.Sprintf("%s/providers/Microsoft.Network/PrivateLinkServices/%s", *oc.OpenShiftClusterProperties.ClusterProfile.ResourceGroupID, "fake-pls")

resp, err := adminRequest(ctx, http.MethodPost, "/admin"+clusterResourceID+"/deletemanagedresource", url.Values{"managedResourceID": []string{plsResourceID}}, true, nil, nil)
Expand Down
20 changes: 11 additions & 9 deletions test/e2e/adminapi_drainnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ var _ = Describe("[Admin API] Cordon and Drain node actions", func() {

It("should be able to cordon, drain, and uncordon nodes", func(ctx context.Context) {
By("selecting a worker node in the cluster")
nodes, err := clients.Kubernetes.CoreV1().Nodes().List(ctx, metav1.ListOptions{
LabelSelector: "node-role.kubernetes.io/worker",
})
Expect(err).NotTo(HaveOccurred())
nodes := ListK8sObjectWithRetry(
ctx,
clients.Kubernetes.CoreV1().Nodes().List,
metav1.ListOptions{
LabelSelector: "node-role.kubernetes.io/worker",
})

Expect(nodes.Items).ShouldNot(BeEmpty())
node := nodes.Items[0]
nodeName := node.Name
Expand All @@ -48,7 +51,7 @@ var _ = Describe("[Admin API] Cordon and Drain node actions", func() {

defer func() {
By("uncordoning the node via Kubernetes API")
err = drain.RunCordonOrUncordon(drainer, &node, false)
err := drain.RunCordonOrUncordon(drainer, &node, false)
Expect(err).NotTo(HaveOccurred())
}()

Expand All @@ -69,8 +72,8 @@ func testCordonNodeOK(ctx context.Context, nodeName string) {
Expect(resp.StatusCode).To(Equal(http.StatusOK))

By("checking that node was cordoned via Kubernetes API")
node, err := clients.Kubernetes.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
node, _ := GetK8sObjectWithRetry(ctx, clients.Kubernetes.CoreV1().Nodes().Get, nodeName, metav1.GetOptions{})

Expect(node.Name).To(Equal(nodeName))
Expect(node.Spec.Unschedulable).Should(BeTrue())
}
Expand All @@ -86,8 +89,7 @@ func testUncordonNodeOK(ctx context.Context, nodeName string) {
Expect(resp.StatusCode).To(Equal(http.StatusOK))

By("checking that node was uncordoned via Kubernetes API")
node, err := clients.Kubernetes.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
node, _ := GetK8sObjectWithRetry(ctx, clients.Kubernetes.CoreV1().Nodes().Get, nodeName, metav1.GetOptions{})
Expect(node.Name).To(Equal(nodeName))
Expect(node.Spec.Unschedulable).Should(BeFalse())
}
Expand Down
Loading
Loading