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

Add test to check health check error message on reboot #1374

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions integration_test/ops_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4144,6 +4144,36 @@ func TestNoNvmlOtelReceiverWithoutGpu(t *testing.T) {
})
}

// TestNoHealthCheckNetworkErrorAfterRestartVM
func TestNoHealthCheckNetworkErrorAfterRestartVM(t *testing.T) {
t.Parallel()
gce.RunForEachPlatform(t, func(t *testing.T, platform string) {
t.Parallel()

ctx, logger, vm := agents.CommonSetup(t, platform)
if err := agents.SetupOpsAgent(ctx, logger.ToMainLog(), vm, ""); err != nil {
t.Fatal(err)
}

time.Sleep(60 * time.Second)
_, err := gce.QueryLog(ctx, logger.ToMainLog(), vm, "ops-agent-health", time.Hour, `jsonPayload.message=~"\[Network Check\] Result: ERROR"`, 5)
if err == nil {
t.Error("expected no logs to contain health check errors")
} else if !strings.Contains(err.Error(), "not found, exhausted retries") {
t.Fatalf("unexpected error: %v", err)
}

gce.RestartInstance(ctx, logger, vm)
time.Sleep(60 * time.Second)
_, err = gce.QueryLog(ctx, logger.ToMainLog(), vm, "ops-agent-health", time.Hour, `jsonPayload.message=~"[Network Check] Result: ERROR"`, 5)
if err == nil {
t.Error("expected no logs to contain health check errors after reboot")
} else if !strings.Contains(err.Error(), "not found, exhausted retries") {
t.Fatalf("unexpected error: %v", err)
}
})
}

func TestMain(m *testing.M) {
code := m.Run()
gce.CleanupKeysOrDie()
Expand Down