Skip to content

Commit c22fe8c

Browse files
committed
Running functional pipeline
1 parent 76c4722 commit c22fe8c

File tree

1 file changed

+48
-73
lines changed

1 file changed

+48
-73
lines changed

tests/suite/graceful_recovery_test.go

+48-73
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("functional", "gracefu
107107
runRestartNodeTest(teaURL, coffeeURL, files, &ns, true)
108108
})
109109

110-
//It("recovers when node is restarted abruptly", func() {
111-
// runRestartNodeTest(teaURL, coffeeURL, files, &ns, false)
112-
//})
110+
It("recovers when node is restarted abruptly", func() {
111+
// FIXME(bjee19) remove Skip() when https://github.com/nginxinc/nginx-gateway-fabric/issues/1108 is completed.
112+
Skip("Test currently fails due to this issue: https://github.com/nginxinc/nginx-gateway-fabric/issues/1108")
113+
runRestartNodeTest(teaURL, coffeeURL, files, &ns, false)
114+
})
113115
})
114116

115117
func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Namespace, drain bool) {
@@ -146,27 +148,28 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
146148
}
147149
}
148150

149-
output, err := exec.Command(
151+
containerOutput, err := exec.Command(
150152
"docker",
151153
"container",
152154
"ls",
153155
).CombinedOutput()
154156
if err != nil {
155157
Expect(err).ToNot(HaveOccurred())
156158
}
157-
158-
fmt.Println(string(output))
159+
fmt.Println(string(containerOutput))
159160

160161
var containerName string
161-
for _, line := range strings.Split(string(output), "\n") {
162+
for _, line := range strings.Split(string(containerOutput), "\n") {
162163
for _, word := range strings.Split(line, " ") {
164+
// This is a potential weak spot in the code where we rely on the container which NGF
165+
// is running on to contain "control-plane" in the name and for no other container to have that either.
166+
// This is currently working in our test framework may break in the future.
163167
if strings.Contains(word, "control-plane") {
164168
containerName = strings.TrimSpace(word)
165169
break
166170
}
167171
}
168172
}
169-
170173
Expect(containerName).ToNot(Equal(""))
171174

172175
// really jank - get the string that contains "control-plane"
@@ -182,9 +185,10 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
182185
Expect(err).ToNot(HaveOccurred())
183186
}
184187

188+
// need to wait for docker container to restart and be running before polling for ready NGF Pods or else we will error
185189
Eventually(
186190
func() bool {
187-
output, err = exec.Command(
191+
output, err := exec.Command(
188192
"docker",
189193
"container",
190194
"inspect",
@@ -212,42 +216,10 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
212216
ports := []string{fmt.Sprintf("%d:80", ngfHTTPForwardedPort), fmt.Sprintf("%d:443", ngfHTTPSForwardedPort)}
213217
portForwardStopCh = make(chan struct{})
214218
err = framework.PortForward(ctlr.GetConfigOrDie(), ngfNamespace, ngfPodName, ports, portForwardStopCh)
215-
address = "127.0.0.1"
216-
portFwdPort = ngfHTTPForwardedPort
217-
portFwdHTTPSPort = ngfHTTPSForwardedPort
218219
Expect(err).ToNot(HaveOccurred())
219220
}
220221

221-
Eventually(
222-
func() error {
223-
return checkForWorkingTraffic(teaURL, coffeeURL)
224-
}).
225-
WithTimeout(timeoutConfig.RequestTimeout).
226-
WithPolling(500 * time.Millisecond).
227-
Should(Succeed())
228-
229-
Expect(resourceManager.DeleteFromFiles(files, ns.Name)).To(Succeed())
230-
231-
Eventually(
232-
func() error {
233-
return checkForFailingTraffic(teaURL, coffeeURL)
234-
}).
235-
WithTimeout(timeoutConfig.RequestTimeout).
236-
WithPolling(500 * time.Millisecond).
237-
Should(Succeed())
238-
239-
Expect(resourceManager.ApplyFromFiles(files, ns.Name)).To(Succeed())
240-
Expect(resourceManager.WaitForAppsToBeReadyWithPodCount(ns.Name, 2)).To(Succeed())
241-
242-
Eventually(
243-
func() error {
244-
return checkForWorkingTraffic(teaURL, coffeeURL)
245-
}).
246-
WithTimeout(timeoutConfig.RequestTimeout).
247-
WithPolling(500 * time.Millisecond).
248-
Should(Succeed())
249-
250-
checkContainerLogsForErrors(ngfPodName)
222+
checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, files, ns)
251223
}
252224

253225
func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files []string, ns *core.Namespace) {
@@ -276,37 +248,7 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
276248
WithPolling(500 * time.Millisecond).
277249
Should(Succeed())
278250
}
279-
280-
Eventually(
281-
func() error {
282-
return checkForWorkingTraffic(teaURL, coffeeURL)
283-
}).
284-
WithTimeout(timeoutConfig.RequestTimeout).
285-
WithPolling(500 * time.Millisecond).
286-
Should(Succeed())
287-
288-
Expect(resourceManager.DeleteFromFiles(files, ns.Name)).To(Succeed())
289-
290-
Eventually(
291-
func() error {
292-
return checkForFailingTraffic(teaURL, coffeeURL)
293-
}).
294-
WithTimeout(timeoutConfig.RequestTimeout).
295-
WithPolling(500 * time.Millisecond).
296-
Should(Succeed())
297-
298-
Expect(resourceManager.ApplyFromFiles(files, ns.Name)).To(Succeed())
299-
Expect(resourceManager.WaitForAppsToBeReadyWithPodCount(ns.Name, 2)).To(Succeed())
300-
301-
Eventually(
302-
func() error {
303-
return checkForWorkingTraffic(teaURL, coffeeURL)
304-
}).
305-
WithTimeout(timeoutConfig.RequestTimeout).
306-
WithPolling(500 * time.Millisecond).
307-
Should(Succeed())
308-
309-
checkContainerLogsForErrors(ngfPodName)
251+
checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, files, ns)
310252
}
311253

312254
func restartContainer(ngfPodName, containerName string) {
@@ -404,6 +346,39 @@ func expectRequestToFail(appURL, address string) error {
404346
return nil
405347
}
406348

349+
func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName string, files []string, ns *core.Namespace) {
350+
Eventually(
351+
func() error {
352+
return checkForWorkingTraffic(teaURL, coffeeURL)
353+
}).
354+
WithTimeout(timeoutConfig.RequestTimeout).
355+
WithPolling(500 * time.Millisecond).
356+
Should(Succeed())
357+
358+
Expect(resourceManager.DeleteFromFiles(files, ns.Name)).To(Succeed())
359+
360+
Eventually(
361+
func() error {
362+
return checkForFailingTraffic(teaURL, coffeeURL)
363+
}).
364+
WithTimeout(timeoutConfig.RequestTimeout).
365+
WithPolling(500 * time.Millisecond).
366+
Should(Succeed())
367+
368+
Expect(resourceManager.ApplyFromFiles(files, ns.Name)).To(Succeed())
369+
Expect(resourceManager.WaitForAppsToBeReadyWithPodCount(ns.Name, 2)).To(Succeed())
370+
371+
Eventually(
372+
func() error {
373+
return checkForWorkingTraffic(teaURL, coffeeURL)
374+
}).
375+
WithTimeout(timeoutConfig.RequestTimeout).
376+
WithPolling(500 * time.Millisecond).
377+
Should(Succeed())
378+
379+
checkContainerLogsForErrors(ngfPodName)
380+
}
381+
407382
// checkContainerLogsForErrors checks both nginx and ngf container's logs for any possible errors.
408383
// Since this function retrieves all the logs from both containers and the NGF pod may be shared between tests,
409384
// the logs retrieved may contain log messages from previous tests, thus any errors in the logs from previous tests

0 commit comments

Comments
 (0)