Skip to content

Conversation

bpkroth
Copy link
Contributor

@bpkroth bpkroth commented May 28, 2025

Pull Request

Title

Refactor storage tests to support testing multiple backends on schema changes


Description

  • adds the ability to run mysql and postgres servers in a container as a part of pytest
  • checks that they succeed with schema setup
  • fixes the ones that were broken with mysql

Type of Change

  • 🛠️ Bug fix
  • 🔄 Refactor
  • 🧪 Tests

Testing

  • CI tests

Additional Notes (optional)

Part of a series of changes to help improve testing for schedulers.

Next will be schema changes to allow storing fractional seconds in MySQL.

Merge after #987


@Copilot Copilot AI review requested due to automatic review settings May 28, 2025 23:03
@bpkroth bpkroth requested a review from a team as a code owner May 28, 2025 23:03
@bpkroth bpkroth added WIP Work in progress - do not merge yet tests Add or fix unit tests bug Something isn't working labels May 28, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the storage test suite to enable running MySQL and PostgreSQL backends alongside SQLite, updates schema-reset helpers, and aligns config files accordingly

  • Adds session‐scoped fixtures and helper functions for MySQL/PostgreSQL servers via pytest-docker
  • Introduces _reset_schema and drop_all_tables methods to clear test schemas after each run
  • Provides Docker Compose files, up/down scripts, and updates JSONC storage configs to use the mlos_bench database

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/storage/sql/fixtures.py Added MySQL/Postgres fixtures and context manager
tests/storage/sql/docker-compose.yml Defined MySQL/Postgres services for testing
tests/storage/sql/down.sh Manual teardown script for SQL test containers
tests/storage/sql/init.py Declared server names and SqlTestServerInfo class
tests/storage/conftest.py Exposed new storage fixtures in the root conftest
tests/conftest.py Added docker_hostname fixture and included SQL compose file
storage/sql/storage.py Added _reset_schema for test cleanup
storage/sql/schema.py Made col‐length constants instance attributes; added drop_all_tables
storage/sql/alembic/README.md / alembic.ini Expanded Alembic workflow for multiple backends
config/storage/mysql.jsonc / postgresql.jsonc Corrected database name to mlos_bench
tests/services/remote/ssh/… Switched SSH fixtures to use docker_hostname and wait_docker_service_socket
Comments suppressed due to low confidence (4)

mlos_bench/mlos_bench/tests/storage/sql/fixtures.py:118

  • The json module is not imported in this file; add import json at the top.
            global_configs=[json.dumps(global_config)],

mlos_bench/mlos_bench/tests/storage/sql/fixtures.py:154

  • The docstring refers to "MySQL" for the postgres_storage fixture; update it to PostgreSQL.
    """
    Fixture of a MySQL backed SqlStorage engine.
    """

mlos_bench/mlos_bench/tests/storage/sql/init.py:55

  • The docstring in get_port mentions SSH; adjust to reference the SQL test server.
        """
        Gets the port that the SSH test server is listening on.
        """

mlos_bench/mlos_bench/tests/conftest.py:38

  • The sys module is used but not imported; add import sys at the top of this file.
    if sys.platform != "win32" and resolve_host_name(HOST_DOCKER_NAME):

@bpkroth bpkroth added ready for review Ready for review and removed WIP Work in progress - do not merge yet labels Jun 2, 2025
@bpkroth bpkroth enabled auto-merge (squash) June 12, 2025 02:17
@bpkroth bpkroth merged commit c060039 into microsoft:main Jun 13, 2025
15 of 16 checks passed
@bpkroth bpkroth deleted the refactor/storage-tests branch June 13, 2025 04:13
bpkroth added a commit that referenced this pull request Jun 13, 2025
# Pull Request

## Title

MySQL schema change to support fractional time

______________________________________________________________________

## Description

- Changes the storage schema to support a variant for MySQL that can
handle fractional time.
- Adds a custom column comparator to be able to pick that up by default
in the future.
- Adjusts tests to check for fractional time support.

______________________________________________________________________

## Type of Change

- 🛠️ Bug fix
- ✨ New feature
- 🔄 Refactor
- 🧪 Tests

______________________________________________________________________

## Testing

- A lot of manual testing with docker.
- Additional CI tests
- Existing CI tests

______________________________________________________________________

## Additional Notes (optional)

Part of a series of changes, should be merged after #983 

______________________________________________________________________

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Ready for review tests Add or fix unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants