Skip to content

Commit 096feda

Browse files
Merge pull request #144 from razo7/check-recent-event-e2e
Check for Recent Event on E2E Tests
2 parents 1f5a9fd + 09aabfd commit 096feda

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

test/e2e/e2e_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/apimachinery/pkg/api/errors"
29-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030

3131
"github.com/medik8s/node-maintenance-operator/api/v1beta1"
3232
)
@@ -41,7 +41,7 @@ var (
4141
// The ns for test deployments
4242
testNsName string
4343
testNamespace *corev1.Namespace
44-
//namespace leases are created in
44+
// namespace leases are created in
4545
leaseNs = "medik8s-leases"
4646
)
4747

@@ -52,7 +52,7 @@ var _ = BeforeSuite(func() {
5252
testNsName = os.Getenv("TEST_NAMESPACE")
5353
Expect(testNsName).ToNot(BeEmpty(), "TEST_NAMESPACE env var not set, can't start e2e test")
5454
testNamespace = &corev1.Namespace{
55-
ObjectMeta: v1.ObjectMeta{
55+
ObjectMeta: metav1.ObjectMeta{
5656
Name: testNsName,
5757
},
5858
}

test/e2e/node_maintenance_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"k8s.io/apimachinery/pkg/labels"
2121
"k8s.io/apimachinery/pkg/types"
2222
"k8s.io/apimachinery/pkg/util/wait"
23-
"k8s.io/utils/pointer"
23+
"k8s.io/utils/ptr"
2424
"sigs.k8s.io/controller-runtime/pkg/client"
2525

2626
nmo "github.com/medik8s/node-maintenance-operator/api/v1beta1"
@@ -33,7 +33,8 @@ const (
3333
testWorkerMaintenance = "test-maintenance"
3434
retryInterval = time.Second * 5
3535
eventInterval = time.Second * 10
36-
timeout = time.Second * 120
36+
deploymentTimeout = time.Second * 120
37+
eventsTimeout = time.Second * 180
3738
testDeployment = "test-deployment"
3839
)
3940

@@ -223,7 +224,6 @@ var _ = Describe("Starting Maintenance", func() {
223224
waitForTestDeployment(1)
224225

225226
})
226-
227227
})
228228
})
229229

@@ -253,14 +253,14 @@ func getNodes() ([]string, []string) {
253253
return controlPlaneNodes, workers
254254
}
255255

256-
func getNodeMaintenance(objectname, nodeName string) *nmo.NodeMaintenance {
256+
func getNodeMaintenance(name, nodeName string) *nmo.NodeMaintenance {
257257
return &nmo.NodeMaintenance{
258258
TypeMeta: metav1.TypeMeta{
259259
Kind: maintenanceKind,
260260
APIVersion: "nodemaintenance.medik8s.io/v1beta1",
261261
},
262262
ObjectMeta: metav1.ObjectMeta{
263-
Name: objectname,
263+
Name: name,
264264
},
265265
Spec: nmo.NodeMaintenanceSpec{
266266
NodeName: nodeName,
@@ -301,7 +301,7 @@ func createTestDeployment() {
301301
Namespace: testNsName,
302302
},
303303
Spec: appsv1.DeploymentSpec{
304-
Replicas: pointer.Int32Ptr(1),
304+
Replicas: ptr.To[int32](1),
305305
Selector: &metav1.LabelSelector{
306306
MatchLabels: podLabel,
307307
},
@@ -342,7 +342,7 @@ func createTestDeployment() {
342342
Args: []string{"-c", "while true; do echo hello; sleep 10;done"},
343343
}},
344344
// make sure we run into the drain timeout at least once
345-
TerminationGracePeriodSeconds: pointer.Int64Ptr(int64(nodemaintenance.DrainerTimeout.Seconds()) + 50),
345+
TerminationGracePeriodSeconds: ptr.To[int64](int64(nodemaintenance.DrainerTimeout.Seconds()) + 50),
346346
},
347347
},
348348
},
@@ -374,7 +374,7 @@ func waitForTestDeployment(offset int) {
374374
logInfoln("test deployment not available yet")
375375
return fmt.Errorf("test deploymemt not ready yet")
376376

377-
}, timeout, retryInterval).ShouldNot(HaveOccurred(), "test deployment failed")
377+
}, deploymentTimeout, retryInterval).ShouldNot(HaveOccurred(), "test deployment failed")
378378

379379
}
380380

@@ -464,7 +464,7 @@ func isLeaseInvalidated(nodeName string) {
464464
// by its name and reason
465465
func waitForEvent(ctx context.Context, eventReason, eventIdentifier string) error {
466466
// Wait for events with a timeout
467-
return wait.PollUntilContextTimeout(ctx, retryInterval, timeout, true, func(ctx context.Context) (bool, error) {
467+
return wait.PollUntilContextTimeout(ctx, retryInterval, eventsTimeout, true, func(ctx context.Context) (bool, error) {
468468
events, err := KubeClient.CoreV1().Events("").List(ctx, metav1.ListOptions{
469469
FieldSelector: fmt.Sprintf("involvedObject.kind=%s", maintenanceKind),
470470
})

0 commit comments

Comments
 (0)