Lab 8.2 — Implement the Fix, Write the Test, Format the Patch

Lab type: Fix-It (real JIRA)
Estimated time: 2–6 hours


Step 1 — Implement the Minimum Fix

Rules:

  • Change only what is necessary to fix the bug
  • Do not reformat surrounding code
  • Do not add unrelated improvements
  • Do not add comments unless they explain the fix
  • If the fix requires changes in multiple files, make all changes in one commit

Step 2 — Write the Test

Every Tez patch must include a test that:

  1. Fails on the original code (without the fix)
  2. Passes on the patched code

The test must be in the same test class as existing tests for the modified class.

Test quality checklist:

  • Test name clearly describes what it is testing
  • @Test(timeout = 5000) annotation (prevents hung tests from blocking CI)
  • No Thread.sleep() (use DrainDispatcher.await() or CountDownLatch instead)
  • Assertion messages explain what was expected vs. what was found
  • No hardcoded absolute paths or ports

Step 3 — Run the Full Test Module

cd ~/tez-src
mvn test -pl tez-dag -q 2>&1 | tail -10

All tests must pass.


Step 4 — Run Checkstyle

mvn checkstyle:check -pl tez-dag -q 2>&1 | grep -E "ERROR|violation" | head -20

Zero violations required.


Step 5 — Format the Patch

cd ~/tez-src
git diff HEAD > /tmp/TEZ-NNNN.001.patch

Verify:

# No trailing whitespace
grep -nP "\\s+$" /tmp/TEZ-NNNN.001.patch

# Patch applies cleanly
git apply --check /tmp/TEZ-NNNN.001.patch

Step 6 — Upload to JIRA

  1. Open your JIRA issue
  2. Click "Attach File" and upload /tmp/TEZ-NNNN.001.patch
  3. Set the "Patch Available" flag (the checkbox in the issue screen, NOT the workflow button)
  4. Update the description or add a comment:
Attaching patch TEZ-NNNN.001.patch

Changes:
- [ClassName.java]: [one-line description of the fix]
- [TestClassName.java]: [one-line description of the new test]

The test fails on unpatched code and passes with the fix applied.

After You Submit

You will typically receive review feedback within a few days to a few weeks. Common feedback categories:

FeedbackMeaningYour response
"Can you add a test?"Test is missingAdd test, re-upload
"This is too broad"Change is larger than neededNarrow scope, re-upload
"Style nit: …"Checkstyle or code styleFix, re-upload
"+1"Committer approvesWait for commit, or ask "Is this ready to commit?"
"-1"Hard blockAddress all -1 comments before re-uploading