diff --git a/CHANGELOG.md b/CHANGELOG.md
index 407d2ae..cf1f19e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,7 +17,12 @@ and this project adheres to [Calendar Versioning](https://calver.org).
- bump mapped convert2rhel composes/targets to Alma Linux and Rocky Linux 8.9, Oracle Linux 8.8
(8.9 is absent on the AWS marketplace)
- use all mapped compose targets when `-t/--target` not specified for the leapp-repository package
+- `-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
diff --git a/README.md b/README.md
index f95e48e..8c01691 100644
--- a/README.md
+++ b/README.md
@@ -134,7 +134,7 @@ As of now tesar is able to perform two tasks.
The goal of tesar is to make requesting test jobs as easy as possible.
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.
In case you have the Build ID handy, you can use that instead of the reference.
-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.
+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.
Multiple `--plans` can be specified and will be dispatched in separate jobs. The same applies to `--planfilter` and `--testfilter`.
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.
@@ -161,7 +161,7 @@ options:
Mutually exclusive with respect to --reference. For brew: Specify the TASK ID for required brew build. NOTE: Double check, that you are passing TASK ID for copr builds, not BUILD ID otherwise
testing farm will not install the package. For copr: Specify the BUILD ID for required copr build.
-g GIT [GIT ...], --git GIT [GIT ...]
- Provide repository base (github, gitlab, gitlab.cee.redhat) owner of the repository and a branch containing the tests you want to run. Default: '['github', 'oamg', 'main']'
+ Provide repository base (github, gitlab, gitlab.cee.redhat) owner of the repository, repository name and a branch containing the tests you want to run.
-gp GIT_PATH, --git-path GIT_PATH
Path to the metadata tree root. Should be relative to the git repository root provided in the url parameter. Default: '.'
-a ARCHITECTURE, --architecture ARCHITECTURE
diff --git a/src/dispatch/__init__.py b/src/dispatch/__init__.py
index bc0044d..cc88513 100644
--- a/src/dispatch/__init__.py
+++ b/src/dispatch/__init__.py
@@ -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(
diff --git a/src/dispatch/__main__.py b/src/dispatch/__main__.py
index 8cfe381..40ae1d6 100644
--- a/src/dispatch/__main__.py
+++ b/src/dispatch/__main__.py
@@ -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:
@@ -89,7 +102,7 @@ def main():
testfilter = None
item = item.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:
@@ -135,7 +148,7 @@ def main():
)
submit_test(
repo_base_url,
- ARGS.git[2],
+ git_ref,
ARGS.git_path,
plan,
planfilter,
diff --git a/src/report/__main__.py b/src/report/__main__.py
index 1329a82..46259f5 100644
--- a/src/report/__main__.py
+++ b/src/report/__main__.py
@@ -433,7 +433,6 @@ def build_table():
if ARGS.split_planname:
planname_split_index = ARGS.split_planname
-
def _gen_row(uuid="", target="", arch="", testplan="", testcase="", result=""):
if "UUID" in fields:
yield uuid
diff --git a/tests/test_args.py b/tests/test_args.py
index c5f1890..95c3b80 100644
--- a/tests/test_args.py
+++ b/tests/test_args.py
@@ -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",
+ ]
+ )