-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split plan to multiple plans by --max tests
- Loading branch information
Showing
17 changed files
with
393 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/plan: | ||
discover: | ||
how: shell | ||
tests: | ||
- name: Test 1 | ||
test: echo "1" | ||
- name: Test 2 | ||
test: echo "2" | ||
- name: Test 3 | ||
test: echo "3" | ||
- name: Test 4 | ||
test: echo "4" | ||
- name: Test 5 | ||
test: echo "5" | ||
provision: | ||
how: local | ||
execute: | ||
how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
summary: Verify --max option splits plans into smaller plans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
rlJournalStart | ||
rlPhaseStartSetup | ||
rlRun "run=\$(mktemp -d)" 0 "Create run directory" | ||
rlRun "pushd data" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest | ||
rlRun -s "tmt run -vv --id $run --max 3" | ||
rlAssertGrep "Splitting plan to batches of 3 tests." $rlRun_LOG | ||
rlAssertGrep "3 tests selected" $rlRun_LOG | ||
rlAssertGrep "summary: 3 tests passed" $rlRun_LOG | ||
rlAssertGrep "2 tests selected" $rlRun_LOG | ||
rlAssertGrep "summary: 2 tests passed" $rlRun_LOG | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
rlRun "rm -r $run" 0 "Remove run directory" | ||
rlPhaseEnd | ||
rlJournalEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from collections.abc import Iterator | ||
from typing import TYPE_CHECKING, Any, Callable | ||
|
||
import tmt.log | ||
import tmt.utils | ||
from tmt.plugins import PluginRegistry | ||
|
||
if TYPE_CHECKING: | ||
from tmt.base import Plan, Test | ||
from tmt.options import ClickOptionDecoratorType | ||
|
||
|
||
PlanShaperClass = type['PlanShaper'] | ||
|
||
|
||
_PLAN_SHAPER_PLUGIN_REGISTRY: PluginRegistry[PlanShaperClass] = PluginRegistry() | ||
|
||
|
||
def provides_plan_shaper( | ||
shaper: str) -> Callable[[PlanShaperClass], PlanShaperClass]: | ||
""" | ||
A decorator for registering plan shaper plugins. | ||
Decorate a plan shaper plugin class to register a plan shaper. | ||
""" | ||
|
||
def _provides_plan_shaper(plan_shaper_cls: PlanShaperClass) -> PlanShaperClass: | ||
_PLAN_SHAPER_PLUGIN_REGISTRY.register_plugin( | ||
plugin_id=shaper, | ||
plugin=plan_shaper_cls, | ||
logger=tmt.log.Logger.get_bootstrap_logger()) | ||
|
||
return plan_shaper_cls | ||
|
||
return _provides_plan_shaper | ||
|
||
|
||
class PlanShaper(tmt.utils.Common): | ||
""" A base class for plan shaper plugins """ | ||
|
||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
super().__init__(*args, **kwargs) | ||
|
||
@classmethod | ||
def run_options(cls) -> list['ClickOptionDecoratorType']: | ||
""" Return additional options for ``tmt run`` """ | ||
|
||
raise NotImplementedError | ||
|
||
@classmethod | ||
def check(cls, plan: 'Plan', tests: list[tuple[str, 'Test']]) -> bool: | ||
""" Check whether this shaper should be applied to the given plan """ | ||
|
||
raise NotImplementedError | ||
|
||
@classmethod | ||
def apply( | ||
cls, | ||
plan: 'Plan', | ||
tests: list[tuple[str, 'Test']]) -> Iterator['Plan']: | ||
""" | ||
Apply the shaper to a given plan and a set of tests. | ||
:returns: a sequence of plans replacing the original plan. | ||
""" | ||
|
||
raise NotImplementedError |
Oops, something went wrong.