Skip to content

Commit

Permalink
proxytest: fix log after test finished (#5878)
Browse files Browse the repository at this point in the history
(cherry picked from commit 02fb75e)
  • Loading branch information
AndersonQ committed Nov 4, 2024
1 parent f057a3a commit 430f865
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions testing/integration/monitoring_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (runner *EndpointMetricsMonRunner) SetupSuite() {
require.NoErrorf(runner.T(), err, "Policy Response was: %v", pkgPolicyResp)

runner.T().Log("Polling for endpoint-security to become Healthy")
ctx, cancel = context.WithTimeout(ctx, time.Minute*3)
ctx, cancel = context.WithTimeout(ctx, time.Minute*6)
defer cancel()

agentClient := runner.fixture.Client()
Expand All @@ -98,7 +98,7 @@ func (runner *EndpointMetricsMonRunner) SetupSuite() {

require.Eventually(runner.T(),
func() bool { return agentAndEndpointAreHealthy(runner.T(), ctx, agentClient) },
time.Minute*3,
time.Minute*5,
time.Second,
"Endpoint component or units are not healthy.",
)
Expand Down Expand Up @@ -144,7 +144,7 @@ func (runner *EndpointMetricsMonRunner) TestEndpointMetricsAfterRestart() {
require.NoError(runner.T(), err)

// wait for endpoint to come back up. We use `pgrep`
// since the agent health status won't imidately register that the endpoint process itself is gone.
// since the agent health status won't immediately register that the endpoint process itself is gone.
require.Eventually(runner.T(), func() bool {
cmd := exec.Command("pgrep", "-f", "endpoint")
pgrep, err := cmd.CombinedOutput()
Expand All @@ -162,7 +162,7 @@ func (runner *EndpointMetricsMonRunner) TestEndpointMetricsAfterRestart() {

require.Eventually(runner.T(),
func() bool { return agentAndEndpointAreHealthy(runner.T(), ctx, agentClient) },
time.Minute*3,
time.Minute*5,
time.Second,
"Endpoint component or units are not healthy.",
)
Expand Down
6 changes: 4 additions & 2 deletions testing/proxytest/proxytest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ func TestProxy(t *testing.T) {
func TestHTTPSProxy(t *testing.T) {
targetHost := "not-a-server.co"
proxy, client, target := prepareMTLSProxyAndTargetServer(t, targetHost)
defer proxy.Close()
defer target.Close()
t.Cleanup(func() {
proxy.Close()
target.Close()
})

tcs := []struct {
name string
Expand Down

0 comments on commit 430f865

Please sign in to comment.