Skip to content

feat: show expires at and remaining columns in lease listing#343

Open
raballew wants to merge 3 commits intojumpstarter-dev:mainfrom
raballew:022-lease-expiration-display
Open

feat: show expires at and remaining columns in lease listing#343
raballew wants to merge 3 commits intojumpstarter-dev:mainfrom
raballew:022-lease-expiration-display

Conversation

@raballew
Copy link
Copy Markdown
Contributor

Summary

  • Replace BEGIN TIME and DURATION columns with EXPIRES AT and REMAINING in jmp get leases output
  • EXPIRES AT shows the calculated expiration timestamp
  • REMAINING shows human-readable time left (e.g. 2h 15m) or expired

Fixes #32

Test plan

  • Unit tests: column headers include EXPIRES AT and REMAINING (test_rich_add_columns_has_expires_at_and_remaining)
  • Unit tests: expiration computed from effective_end_time, effective_begin_time+duration, begin_time+duration (test_compute_expires_at_*)
  • Unit tests: remaining time formatting including expired state (test_format_remaining_*)
  • Unit tests: table rendering with and without timing data (test_rich_add_rows_*)
  • E2E BATS test: verify jmp get leases output contains EXPIRES AT and REMAINING columns

🤖 Generated with Claude Code

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 414292f
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/69cd195ea178b80008308eb5
😎 Deploy Preview https://deploy-preview-343--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6af68ba7-52ed-4550-8687-786839024637

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0aafe and 414292f.

📒 Files selected for processing (2)
  • e2e/tests.bats
  • python/packages/jumpstarter-cli/jumpstarter_cli/get_test.py
✅ Files skipped from review due to trivial changes (1)
  • e2e/tests.bats

📝 Walkthrough

Walkthrough

Replaces lease listing columns "BEGIN TIME" and "DURATION" with "EXPIRES AT" and "REMAINING", adds Lease helpers to compute expiration and remaining time, and adds unit and end-to-end tests validating the new display and computation logic.

Changes

Cohort / File(s) Summary
E2E Test
e2e/tests.bats
Added a Bats test that waits for exporter readiness, switches to test-client-oidc, creates a 1-day lease filtered by example.com/board=oidc, runs jmp get leases with wide columns, asserts EXPIRES AT and REMAINING columns appear, then deletes leases.
Lease Display Logic
python/packages/jumpstarter/jumpstarter/client/grpc.py
Replaced BEGIN TIME/DURATION columns with EXPIRES AT/REMAINING. Added Lease._compute_expires_at() and Lease._format_remaining() and refactored rich-row rendering to use them.
Unit Tests
python/packages/jumpstarter/jumpstarter/client/grpc_test.py, python/packages/jumpstarter-cli/jumpstarter_cli/get_test.py
Added TestLeaseRichDisplay covering column headers, _compute_expires_at() scenarios, and _format_remaining() behavior; updated get_test call site to include new all_clients=False argument in the tested invocation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mangelajo
  • bkhizgiy

Poem

🐇 I nibbled clocks and hopped through charts,
I chased the ends and counted hearts.
"EXPIRES AT" shines, "REMAINING" hums,
Leases now sing of distant drums.
A hop, a tweak — the rabbit drums 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing columns in lease listing output with EXPIRES AT and REMAINING columns.
Description check ✅ Passed The description clearly relates to the changeset, explaining the column replacement and providing test plan details aligned with the code changes.
Linked Issues check ✅ Passed The PR fulfills issue #32 requirements: replaces BEGIN TIME/DURATION with EXPIRES AT/REMAINING columns, shows expiration time by default, and provides human-readable time remaining.
Out of Scope Changes check ✅ Passed All changes are in-scope: modified lease table display (grpc.py), added corresponding tests (grpc_test.py, get_test.py), and added E2E test validating the new columns in actual output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
e2e/tests.bats (1)

345-357: Make this E2E test self-contained to avoid order dependence.

This test depends on suite-prepared state (test-client-oidc, active exporters) and uses jmp delete leases --all, which broadens side effects beyond the lease created here. Please make setup/cleanup local to this test so it can run deterministically in isolation.

Based on learnings: "E2E tests in bats should be runnable in isolation. Do not rely on prior suite setup or shared state across tests."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@e2e/tests.bats` around lines 345 - 357, This test is order-dependent because
it relies on pre-existing client and exporter state and uses a global cleanup;
modify the test to be self-contained by creating and using a unique test client
(instead of relying on "jmp config client use test-client-oidc"), ensure any
required exporter is started or validated with wait_for_exporter, create the
lease with a unique selector/label so it’s identifiable, capture the created
lease identifier from the "jmp create lease" output, assert on "jmp get leases"
as before, and then delete only that specific lease (and the test client) rather
than calling "jmp delete leases --all" so setup and teardown are local to the
test.
python/packages/jumpstarter/jumpstarter/client/grpc_test.py (1)

443-449: Add a deterministic non-expired REMAINING assertion.

Current tests validate expired and None, but not the positive formatting output (Xd Yh Zm). Adding one fixed-clock test would better protect the new display behavior from regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py` around lines 443
- 449, Add a deterministic positive-case test for Lease._format_remaining that
asserts a future datetime produces the expected "Xd Yh Zm" string: create a
fixed "now" (e.g., datetime(2020,1,1,0,0,0)), compute a future time (e.g., now +
timedelta(days=1, hours=2, minutes=3)), call
Lease._format_remaining(future_time) and assert it equals "1d 2h 3m"; add this
as test_format_remaining_future in grpc_test.py and ensure the test uses the
fixed clock (or computes expected output from that fixed reference) so it is
deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@e2e/tests.bats`:
- Around line 345-357: This test is order-dependent because it relies on
pre-existing client and exporter state and uses a global cleanup; modify the
test to be self-contained by creating and using a unique test client (instead of
relying on "jmp config client use test-client-oidc"), ensure any required
exporter is started or validated with wait_for_exporter, create the lease with a
unique selector/label so it’s identifiable, capture the created lease identifier
from the "jmp create lease" output, assert on "jmp get leases" as before, and
then delete only that specific lease (and the test client) rather than calling
"jmp delete leases --all" so setup and teardown are local to the test.

In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py`:
- Around line 443-449: Add a deterministic positive-case test for
Lease._format_remaining that asserts a future datetime produces the expected "Xd
Yh Zm" string: create a fixed "now" (e.g., datetime(2020,1,1,0,0,0)), compute a
future time (e.g., now + timedelta(days=1, hours=2, minutes=3)), call
Lease._format_remaining(future_time) and assert it equals "1d 2h 3m"; add this
as test_format_remaining_future in grpc_test.py and ensure the test uses the
fixed clock (or computes expected output from that fixed reference) so it is
deterministic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13b28fb4-15ef-4f17-9102-6798826273fe

📥 Commits

Reviewing files that changed from the base of the PR and between bb7493b and f958df9.

📒 Files selected for processing (3)
  • e2e/tests.bats
  • python/packages/jumpstarter/jumpstarter/client/grpc.py
  • python/packages/jumpstarter/jumpstarter/client/grpc_test.py

@raballew raballew force-pushed the 022-lease-expiration-display branch from f958df9 to 6c0aafe Compare March 20, 2026 15:32
…eases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raballew raballew force-pushed the 022-lease-expiration-display branch 2 times, most recently from 212a314 to 583f539 Compare March 20, 2026 15:37
Rich wraps the "EXPIRES AT" column header across two lines when the
terminal is narrower than the table, causing the substring assertion
to fail in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Show lease expiration time by default

1 participant