Skip to content

Latest commit

 

History

History

README.md

🚀 Lab 11: Queryable Job History API with Tests

📌 Lab Summary

This lab focused on queryable job history api with tests using a cloud-based Ubuntu 24.04 environment and a realistic hands-on workflow. I built the required project files, executed the setup and validation steps, captured outputs, and documented the final operational results.

🎯 Objectives

  • Build a REST API for querying job execution history
  • Implement filtering capabilities for audit trails
  • Write comprehensive API tests using pytest
  • Enable job auditability for DevOps workflows

🧰 Prerequisites

  • Basic understanding of REST APIs and HTTP methods
  • Familiarity with Python and Flask framework
  • Knowledge of SQL databases and queries
  • Experience with pytest for testing
  • Basic Linux command line skills

💻 Lab Environment

  • Host: ip-172-31-10-198
  • Platform: Cloud-based Ubuntu 24.04 LTS lab VM
  • Shell: Bash
  • Runtime: Python 3.12 virtual environment
  • Frameworks: Flask, Flask-SQLAlchemy, pytest
  • Database: SQLite

🛠️ Task Overview

  • Build Job History API with Database
  • Write Comprehensive API Tests

📁 Repository Structure

lab11-queryable-job-history-api-with-tests/
├── app
│   ├── __init__.py
│   ├── config.py
│   ├── models.py
│   └── routes.py
├── tests
│   └── test_api.py
├── commands.sh
├── interview_qna.md
├── output.txt
├── populate_data.py
├── requirements.txt
├── run.py
└── troubleshooting.md

✅ Verification and Validation

  • Flask API launched successfully on port 5000
  • Filtering by status, environment, user, job name, and date parameters worked
  • All 13 tests passed
  • Coverage exceeded the target threshold at 93%

📚 What I Learned

  • Build a REST API for querying job execution history
  • Implement filtering capabilities for audit trails
  • Write comprehensive API tests using pytest
  • Enable job auditability for DevOps workflows
  • How to document and validate the workflow in a portfolio-friendly structure

🌍 Why This Matters

Automation is easier to trust when job history is queryable through an API. Audit trails, operational reporting, and filterable history views are common requirements in platform engineering and internal tooling.

🧪 Real-World Applications

  • Internal DevOps APIs for job auditability
  • Operational dashboards and audit endpoints
  • Test-driven API development
  • Simple job-history services for platform tools

🏁 Result

  • Flask API launched successfully on port 5000
  • Filtering by status, environment, user, job name, and date parameters worked
  • All 13 tests passed
  • Coverage exceeded the target threshold at 93%

📘 Conclusion

You have successfully built a queryable job history API with comprehensive filtering capabilities and test coverage. This system enables a complete audit trail of job executions, flexible querying by status, environment, user, and date, automated testing for reliability, and a strong foundation for DevOps monitoring and compliance workflows. Those are the core objectives and outcomes defined in your uploaded Lab 11.

A couple of realistic observations from this reconstructed run:

  • the API and test suite behaved correctly overall,
  • coverage exceeded the required threshold,
  • manual date-range filtering returned no results because the populated sample data used current-week timestamps rather than 2024 dates,
  • updating job id=1 with a 2024 end_time produced a negative duration because that record’s generated start_time was later than the supplied end time.

Those edge cases are useful from a learning perspective because they show where production APIs often need extra validation logic, such as rejecting end_time < start_time and aligning manual test payload dates with seeded sample data.