Skip to content

Conversation

@reidkwja
Copy link
Contributor

Motivation

Adding tests for subcmd modules, improving test coverage for the overall MITuna source code. The coverage report identified significant gaps in four key subcommand modules:

  • tuna/miopen/subcmd/export_db.py (47% coverage)
  • tuna/miopen/subcmd/import_configs.py (70% coverage)
  • tuna/miopen/subcmd/load_job.py (72% coverage)
  • tuna/miopen/subcmd/merge_db.py (49% coverage)

These modules handle critical database export/import operations, and the missing coverage represented untested error paths, edge cases, and conditional branches.

Technical Details

The tests cover the following areas:

export_db.py (tests/test_export_db_branches.py):

  • Filename generation variants (OpenCL/HIP, num_cu encoding, kernel/perf/find db extensions)
  • Golden version validation requiring arch parameter
  • Non-convolution config type handling in fin_net_cfg_job
  • Duplicate solver entry detection in add_entry_to_solvers
  • FDB entry trimming to top 4 results in build_miopen_fdb
  • Kernel db extension handling (.o, .mlir.o) and -mcpu injection
  • Multi-CU skew handling in build_miopen_fdb_skews and export_kdb
  • PDB building and ordering

import_configs.py (tests/test_import_configs_branches.py):

  • Query construction variants (tag/recurrent combinations)
  • Batch list parsing and iteration
  • Tag-only vs insert+tag processing paths
  • IntegrityError handling in add_model/add_frameworks
  • Missing framework/model ID validation in add_benchmark
  • Argument validation in check_import_benchmark_args
  • Multiple subcommand flag paths (print_models, add_model, add_framework, add_benchmark)

load_job.py (tests/test_load_job_branches.py):

  • Algorithm-to-solver mapping in arg_solvers
  • Missing tag name validation
  • Config query filtering by tag and command type
  • Compose query with tunable/dynamic/batch_norm filters
  • Empty results error logging
  • Tag error handling in run_load_job

merge_db.py (tests/test_merge_db_branches.py):

  • Argument parsing requiring one of perf_db/find_db/bin_cache
  • Input validation in target_merge (None/empty checks)
  • Float parsing for sort keys
  • copy_only short-circuit paths
  • SQLite binary cache duplicate handling
  • File list filtering (excluding non-gfx, DB_ALIAS entries)

All tests use mocking/monkeypatching to avoid database dependencies and test logic in isolation.

Test Plan

  1. Created four new test modules under tests/:

    • test_export_db_branches.py (12 tests)
    • test_import_configs_branches.py (10 tests)
    • test_load_job_branches.py (6 tests)
    • test_merge_db_branches.py (8 tests)
  2. Integrated tests into CI pipeline (vars/utils.groovy):

    • Added to pytestSuite1 with coverage tracking
    • Tests run with python3 -m coverage run -a -m pytest
  3. Fixed test failures:

    • Adjusted test_build_miopen_pdb for actual deduplication behavior
    • Fixed IntegrityError construction with required SQLAlchemy parameters
    • Enhanced load_job stubs with SQLAlchemy-compatible column/table attributes
    • Updated merge_db tests to use valid filename patterns and non-aliased entries

Test Result

All 36 new tests pass successfully in CI:

-  test_export_db_branches.py: 12/12 passed
-  test_import_configs_branches.py: 10/10 passed
-  test_load_job_branches.py: 6/6 passed
-  test_merge_db_branches.py: 8/8 passed

These tests target previously uncovered lines/branches, improving coverage for the four subcommand modules.

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.

2 participants