Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split tests into groups for parallel execution in CI/CD runners #417

Merged
merged 7 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ env:

jobs:
run_tests:
name: Run tests with ${{ matrix.os }}, Python ${{ matrix.py_v}}, RedisAI ${{ matrix.rai }}
name: Run tests ${{ matrix.subset }} with ${{ matrix.os }}, Python ${{ matrix.py_v}}, RedisAI ${{ matrix.rai }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
subset: [backends, slow_tests, group_a, group_b]
Copy link
Contributor

Choose a reason for hiding this comment

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

Other than the opaque group names, this is simple & effective. LGTM as the first step toward test domination!

os: [macos-12, ubuntu-20.04] # Operating systems
compiler: [8] # GNU compiler version
rai: [1.2.7] # Redis AI versions
Expand Down Expand Up @@ -121,10 +122,19 @@ jobs:
- name: Run Pylint
run: make check-lint

# Run pytest (backends subdirectory)
- name: Run Pytest
if: (matrix.subset == 'backends')
run: |
echo "SMARTSIM_LOG_LEVEL=debug" >> $GITHUB_ENV
py.test -s --import-mode=importlib -o log_cli=true --cov=$(smart site) --cov-report=xml --cov-config=./tests/test_configs/cov/local_cov.cfg --ignore=tests/full_wlm/ ./tests/
py.test -s --import-mode=importlib -o log_cli=true --cov=$(smart site) --cov-report=xml --cov-config=./tests/test_configs/cov/local_cov.cfg --ignore=tests/full_wlm/ ./tests/backends

# Run pytest (test subsets)
- name: Run Pytest
if: "!contains(matrix.subset, 'backends')" # if not running backend tests
run: |
echo "SMARTSIM_LOG_LEVEL=debug" >> $GITHUB_ENV
py.test -s --import-mode=importlib -o log_cli=true --cov=$(smart site) --cov-report=xml --cov-config=./tests/test_configs/cov/local_cov.cfg --ignore=tests/full_wlm/ -m ${{ matrix.subset }} ./tests

# Upload artifacts on failure, ignoring binary files
- name: Upload Artifact
Expand Down
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ To be released at some future point in time

Description

- Split tests into groups for parallel execution in CI/CD pipeline
- Change signature of `Experiment.summary()`
- Expose first_device parameter for scripts, functions, models
- Added support for MINBATCHTIMEOUT in model execution
Expand All @@ -27,6 +28,7 @@ Description

Detailed Notes

- Split tests into `group_a`, `group_b`, `slow_tests` for parallel execution in CI/CD pipeline (PR417_)
- Change `format` argument to `style` in `Experiment.summary()`, this is
an API break (PR391_)
- Added support for first_device parameter for scripts, functions,
Expand All @@ -43,6 +45,7 @@ Detailed Notes
- Add support for creation of multiple databases with unique identifiers. (PR342_)


.. _PR417: https://github.com/CrayLabs/SmartSim/pull/417
.. _PR391: https://github.com/CrayLabs/SmartSim/pull/391
.. _PR342: https://github.com/CrayLabs/SmartSim/pull/342
.. _PR394: https://github.com/CrayLabs/SmartSim/pull/394
Expand Down
3 changes: 3 additions & 0 deletions tests/test_alps_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from smartsim.error import SSUnsupportedError
from smartsim.settings import AprunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_aprun_settings():
settings = AprunSettings("python")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_batch_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from smartsim.settings import BsubBatchSettings, QsubBatchSettings, SbatchSettings
from smartsim.settings.settings import create_batch_settings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_create_pbs_batch():
pbs_batch = create_batch_settings(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_buildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from smartsim._core._install.buildenv import Version_
from pkg_resources import packaging # type: ignore

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_version_hash_eq():
"""Ensure hashes are equal if data is equal"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
configure_parser as validate_parser,
)

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def mock_execute_custom(msg: str = None, good: bool = True) -> int:
retval = 0 if good else 1
print(msg)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cobalt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import pytest

from smartsim._core.launcher.cobalt import cobaltParser

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_parse_step_id():
output = "JobName JobId \n" "=====================\n" "smartsim 507975 \n"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_colo_model_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
from smartsim.error import SSUnsupportedError
from smartsim.entity import Model

# The tests in this file belong to the slow_tests group
pytestmark = pytest.mark.slow_tests


if sys.platform == "darwin":
supported_dbs = ["tcp", "deprecated"]
else:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_colo_model_lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import smartsim.settings.base
from smartsim.settings.lsfSettings import JsrunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


is_mac = sys.platform == "darwin"

Expand Down
5 changes: 3 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
from pathlib import Path

import os
from re import A, L
import pytest
import shutil
import typing as t

from smartsim._core.config.config import Config
from smartsim.error import SSConfigError

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_all_config_defaults():
config = Config()
Expand Down
7 changes: 5 additions & 2 deletions tests/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@
import pytest

from smartsim import Experiment, status
from smartsim._core.utils import installed_redisai_backends
from smartsim.database import Orchestrator
from smartsim.entity import Ensemble, Model
from smartsim.entity import Ensemble
from smartsim.settings.containers import Singularity

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


# Check if singularity is available as command line tool
singularity_exists = which("singularity") is not None
containerURI = "docker://alrigazzi/smartsim-testing:latest"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_controller_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from smartsim.error.errors import SSUnsupportedError
from smartsim.settings import RunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_finished_entity_orc_error():
"""Orchestrators are never 'finished', either run forever or stopped by user"""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_dbnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
from smartsim.entity.dbnode import DBNode, LaunchedShardData
from smartsim.error.errors import SmartSimError

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_parse_db_host_error():
orc = Orchestrator()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
from smartsim.error import EntityExistsError, SSUnsupportedError, UserStrategyError
from smartsim.settings import RunSettings

# The tests in this file belong to the slow_tests group
pytestmark = pytest.mark.slow_tests


"""
Test ensemble creation

Expand Down
3 changes: 3 additions & 0 deletions tests/test_entitylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from smartsim.entity import EntityList
from smartsim.settings import RunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_entity_list_init():
with pytest.raises(NotImplementedError):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import contextlib

import pytest

from smartsim import Experiment
from smartsim.entity import Model
from smartsim.error import SmartSimError
from smartsim.settings import RunSettings

# The tests in this file belong to the slow_tests group
pytestmark = pytest.mark.slow_tests


def test_model_prefix(fileutils):
exp_name = "test_prefix"
Expand Down
5 changes: 4 additions & 1 deletion tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import filecmp
from os import path as osp

import pytest

from smartsim import Experiment
Expand All @@ -35,6 +34,10 @@
from smartsim.settings import RunSettings
from tabulate import tabulate

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


rs = RunSettings("python", exe_args="sleep.py")


Expand Down
4 changes: 4 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import pytest

from smartsim._core.utils.helpers import cat_arg_and_value

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_double_dash_concat():
result = cat_arg_and_value("--foo", "FOO")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


__author__ = "Sam Partee"


Expand Down
5 changes: 4 additions & 1 deletion tests/test_interrupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
import os
import signal
import time
Expand All @@ -33,6 +33,9 @@
from smartsim import Experiment
from smartsim.settings import RunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def keyboard_interrupt(pid):
"""Interrupt main thread"""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_launch_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
from smartsim.error import SSUnsupportedError
from smartsim.settings import JsrunSettings, RunSettings

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


def test_unsupported_run_settings():
exp_name = "test-unsupported-run-settings"
Expand Down
6 changes: 5 additions & 1 deletion tests/test_local_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
from smartsim import Experiment, status

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


"""
Test the launch of simple entity types with local launcher
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/test_local_multi_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
from smartsim import Experiment, status

# The tests in this file belong to the group_a group
pytestmark = pytest.mark.group_a


"""
Test the launch of simple entity types with local launcher
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/test_local_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
from smartsim import Experiment, status

# The tests in this file belong to the group_b group
pytestmark = pytest.mark.group_b


"""
Test restarting ensembles and models.
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/test_lsf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
from smartsim._core.launcher.lsf import lsfParser

# The tests in this file belong to the group_b group
pytestmark = pytest.mark.group_b


# -- bsub ---------------------------------------------------------


Expand Down
5 changes: 3 additions & 2 deletions tests/test_lsf_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


from pprint import pformat

import pytest

from smartsim.error import SSUnsupportedError
from smartsim.settings import BsubBatchSettings, JsrunSettings

# The tests in this file belong to the group_b group
pytestmark = pytest.mark.group_b

# ------ Jsrun ------------------------------------------------


Expand Down
Loading