Skip to content

Commit 9d83ef0

Browse files
bwagner5AndrewMitchell25
authored andcommitted
add suite test for status check interruptions
1 parent dba1bc2 commit 9d83ef0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/suites/interruption/suite_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,42 @@ var _ = Describe("Interruption", func() {
267267
env.EventuallyExpectNotFound(node)
268268
env.EventuallyExpectHealthyPodCount(selector, 1)
269269
})
270+
FIt("should terminate the node when receiving an instance status failure", func() {
271+
numPods := 1
272+
dep := coretest.Deployment(coretest.DeploymentOptions{
273+
Replicas: int32(numPods),
274+
PodOptions: coretest.PodOptions{
275+
ObjectMeta: metav1.ObjectMeta{
276+
Labels: map[string]string{"app": "my-app"},
277+
},
278+
TerminationGracePeriodSeconds: lo.ToPtr(int64(0)),
279+
},
280+
})
281+
selector := labels.SelectorFromSet(dep.Spec.Selector.MatchLabels)
282+
283+
// schedule the interface to go down after 70 seconds.
284+
// this has to be above a minute so that the instance status check initializes to healthy.
285+
nodeClass.Spec.UserData = lo.ToPtr(`#!/usr/bin/env bash
286+
(
287+
sleep 30
288+
IFACE=$(ip route show default | awk '{print $5}' | head -n1)
289+
ip link set dev "$IFACE" down
290+
) >>/var/log/disable-net.log 2>&1 &`)
291+
292+
env.ExpectCreated(nodeClass, nodePool, dep)
293+
294+
env.EventuallyExpectHealthyPodCount(selector, numPods)
295+
env.ExpectCreatedNodeCount("==", 1)
296+
297+
node := env.Monitor.CreatedNodes()[0]
298+
299+
Eventually(func(g Gomega) {
300+
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
301+
g.Expect(!node.DeletionTimestamp.IsZero()).To(BeTrue())
302+
}).WithTimeout(15 * time.Minute).Should(Succeed())
303+
env.EventuallyExpectNotFound(node)
304+
env.EventuallyExpectHealthyPodCount(selector, 1)
305+
})
270306
})
271307

272308
func scheduledChangeMessage(region, accountID, involvedInstanceID string) scheduledchange.Message {

0 commit comments

Comments
 (0)