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

Redefine default test location for leapp-repository #52

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ and this project adheres to [Calendar Versioning](https://calver.org).<br>
(8.9 is absent on the AWS marketplace)
- use all mapped compose targets when `-t/--target` not specified for the leapp-repository package
- make `--plans`, `--planfilter` and `--testfilter` compatible
- `-g/--git` accepts 4 arguments - base (github, gitlab, gitlab.cee.redhat), repo owner, repo name, git reference (branch, etc.)
- `gitlab.cee.redhat.com/oamg/leapp-tests/-/tree/master` set as default location for tests if `-g/--git` is not specified
- git reference can be specified for leapp-repository tests
### Removed

## [2023.07.12]
### Added
- `-s/--short` display short test and plan names
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ As of now tesar is able to perform two tasks.
The goal of tesar is to make requesting test jobs as easy as possible.<br>
Instead of looking for build IDs to pass to the payload, all you need to know is a `--reference` for a pull request number associated with the build you need to test. For brew builds you just need to know the release version.<br>
In case you have the Build ID handy, you can use that instead of the reference.<br>
Use `-g/--git` to point from where the test metadata and code should be run. Specify the repository base e.g. github, repository owner and the branch from which the tests should run.<br>
Multiple `--plans` can be specified and will be dispatched in separate jobs.
Use `-g/--git` to point from where the test metadata and code should be run. Specify the repository base e.g. github, repository owner, repository name and the branch from which the tests should run.<br>
Multiple `--plans` can be specified and will be dispatched in separate jobs.<br>
When using `--planfilter` or `--testfilter` to specify singular test it is disallowed to request multiple `--plans` in one command.<br>
You can look for possible [targeted OS' below](#mapped-composes), multiple can be requested and will be dispatched in separate jobs.
Use `-w/--wait` to override the default 20 seconds waiting time for successful response from the endpoint, or `-nw/--no-wait` to skip the wait time.
Expand Down
6 changes: 2 additions & 4 deletions src/tesar/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ def get_arguments(args=None):
test.add_argument(
"-g",
"--git",
nargs="+",
default=["github", "oamg", "main"],
help="""Provide repository base (github, gitlab, gitlab.cee.redhat)\nowner of the repository\nand a branch containing the tests you want to run.
Default: '%(default)s'""",
nargs=4,
help="""Provide repository base (github, gitlab, gitlab.cee.redhat) owner of the repository, repository name and a branch containing the tests you want to run.""",
)

test.add_argument(
Expand Down
47 changes: 30 additions & 17 deletions src/tesar/dispatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,39 @@
COMPOSE_MAPPING = get_compose_mapping()


def main():
copr_repo = PACKAGE_MAPPING[ARGS.package]
copr_package = PACKAGE_MAPPING[ARGS.package]
git_repo = PACKAGE_MAPPING.get(ARGS.package)
if ARGS.package == "leapp-repository":
def main(
git_base=None,
git_owner=None,
git_repo=None,
git_ref=None,
copr_repo=None,
copr_package=PACKAGE_MAPPING[ARGS.package],
):
if ARGS.package == "c2r":
git_base = "github"
git_owner = "oamg"
git_repo = PACKAGE_MAPPING.get(ARGS.package)
git_ref = "main"
copr_repo = PACKAGE_MAPPING[ARGS.package]
elif ARGS.package == "leapp-repository":
git_base = "gitlab.cee.redhat"
git_owner = "oamg"
git_repo = "leapp-tests"
git_ref = "master"
copr_repo = "leapp"

if ARGS.git:
git_base = ARGS.git[0]
if ".com" in git_base:
git_base = git_base.strip(".com")
git_owner = ARGS.git[1]
git_repo = ARGS.git[2]
git_ref = ARGS.git[3]
try:
repo_base_url = "https://{}.com/{}/{}".format(
ARGS.git[0], ARGS.git[1], git_repo
)
repo_base_url = "https://{}.com/{}/{}".format(git_base, git_owner, git_repo)
git_response = requests.get(repo_base_url)
if (
ARGS.git[0] != "gitlab"
and ARGS.git[0] != "github"
and ARGS.git[0] != "gitlab.cee.redhat"
):
if git_base not in ["gitlab", "github", "gitlab.cee.redhat"]:
LOGGER.critical(
"Bad git base reference, please provide correct values.\ngithub / gitlab"
"Bad git base reference, please provide correct values.\ngithub / gitlab / gitlab.cee.redhat"
)
sys.exit(99)
elif git_response.status_code == 404:
Expand Down Expand Up @@ -90,7 +103,7 @@ def main():
for plan in plans:
item = plan.rstrip("/")
# Usually the best approach is to let Testing Farm to choose the most suitable pool.
# Recently the AWS pools are releasing the guests during test execution.
# Occasionally the AWS pools are releasing the guests during test execution.
# If the pool-workaround option is passed, use the baseosci-openstack pool
pool = ""
if ARGS.pool_workaround:
Expand Down Expand Up @@ -123,7 +136,7 @@ def main():
)
submit_test(
repo_base_url,
ARGS.git[2],
git_ref,
ARGS.git_path,
plan,
ARGS.planfilter,
Expand Down
47 changes: 47 additions & 0 deletions tests/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,50 @@ def test_cmd_args_are_appended():
"http://artifacts.osci.redhat.com/testing-farm/14612a82-002d-4a8d-a5c4-613a0a75efeb/",
]
)
get_arguments(
[
"report",
"-c",
"http://artifacts.osci.redhat.com/testing-farm/909143cf-89ca-4d62-8f81-959bf8ab4d03/",
"http://artifacts.osci.redhat.com/testing-farm/14612a82-002d-4a8d-a5c4-613a0a75efeb/",
]
)


def test_git_arg_four_nargs():
"""Unit test covering tesar test -g accepting four arguments."""
# Pass all four arguments to the --git arg
args = get_arguments(
[
"test",
"copr",
"c2r",
"-r",
"pr123",
"-p",
"mock_plan",
"-g",
"github",
"oamg",
"convert2rhel",
"devel",
]
)
assert len(args.git) == 4
# Pass less than 4 arguments
with pytest.raises(SystemExit):
get_arguments(
[
"test",
"copr",
"c2r",
"-r",
"pr123",
"-p",
"mock_plan",
"-g",
"github",
"oamg",
"devel",
]
)
Loading