Skip to content

Add lifecycle hooks test and verify probe coverage#15

Merged
dciangot merged 4 commits intomainfrom
copilot/add-test-case-prestop-hook
Apr 9, 2026
Merged

Add lifecycle hooks test and verify probe coverage#15
dciangot merged 4 commits intomainfrom
copilot/add-test-case-prestop-hook

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 28, 2026

Adds test coverage for Kubernetes lifecycle hooks (postStart/preStop) and confirms all probe types are tested.

Changes

New test template: 115-lifecycle-hooks.yaml

  • postStart hook: Creates marker file at /tmp/poststart-marker, validated by main container
  • preStop hook: Writes to file during pod deletion (triggered by cleanup)
  • 5 log pattern validations ensure postStart executes correctly
  • 30s timeout for postStart validation
  • Container runs indefinitely until terminated by pod deletion

Probe coverage verification

  • Existing 090-probes.yaml covers all three probe types: startup, liveness, readiness
  • No additional probe tests needed

Implementation notes

The postStart hook uses tee + append to avoid race conditions:

lifecycle:
  postStart:
    exec:
      command: ["/bin/sh", "-c", |
        echo "postStart hook executed!" | tee /tmp/poststart-marker
        echo "postStart hook marker file created" >> /tmp/poststart-marker
      ]

The container runs indefinitely (while true; do sleep 30; done) so that preStop is triggered during pod deletion by cleanup, not by normal container exit. preStop hook execution is validated by ensuring the pod deletion completes without errors. Direct log validation of preStop output is not possible because cleanup occurs after validation completes in the test framework.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a test case check preStop hook for a pod</issue_title>
<issue_description>Also check that all other kind of kubernetes pod probes are checked</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 28, 2026 08:52
Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test case to check preStop hook for a pod Add lifecycle hooks test and verify probe coverage Jan 28, 2026
Copilot AI requested a review from dciangot January 28, 2026 08:58
Copy link
Copy Markdown
Member

@dciangot dciangot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dciangot dciangot marked this pull request as ready for review January 28, 2026 09:05
@dciangot dciangot requested a review from Copilot April 9, 2026 08:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new vk-test-set template intended to validate Kubernetes container lifecycle hooks (postStart/preStop) and documents that existing probe tests already cover startup/liveness/readiness probes.

Changes:

  • Added a new 115-lifecycle-hooks.yaml template that uses a postStart hook to create a marker file and validates it from the main container.
  • Added log-based validations intended to confirm preStop hook execution order/messages.
  • Confirmed probe-type coverage is already handled by existing 090-probes.yaml (no changes made there).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vktestset/templates/115-lifecycle-hooks.yaml
Comment thread vktestset/templates/115-lifecycle-hooks.yaml Outdated
Copilot AI requested a review from dciangot April 9, 2026 08:54
@dciangot dciangot merged commit a94d465 into main Apr 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a test case check preStop hook for a pod

3 participants