Skip to content

Add lifecycle hooks test and verify probe coverage#15

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-test-case-prestop-hook
Open

Add lifecycle hooks test and verify probe coverage#15
Copilot wants to merge 3 commits intomainfrom
copilot/add-test-case-prestop-hook

Conversation

Copy link

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: Logs 3-stage shutdown sequence before termination
  • 8 log pattern validations ensure hooks execute in correct order
  • 120s timeout accounts for image pulls and hook execution delays

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
      ]

preStop hook output may not be captured by all virtual kubelet implementations. Template includes validation checks but documents this limitation.

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
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
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

2 participants