Skip to content

Commit

Permalink
tests: fmf/tmt combination for tests in upstrean and Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
jscotka committed Apr 7, 2021
1 parent 0cf160f commit 45fa5ae
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 90 deletions.
6 changes: 5 additions & 1 deletion .packit.yaml
@@ -1,7 +1,11 @@
---
synced_files:
- src: fedora-tests/
- src: tests/
dest: tests/
- src: plans/
dest: plans/
- src: .fmf/
dest: .fmf/
# packit was already taken on PyPI
upstream_package_name: packitos
upstream_project_url: https://github.com/packit/packit
Expand Down
6 changes: 0 additions & 6 deletions fedora-tests/simple.py

This file was deleted.

26 changes: 0 additions & 26 deletions fedora-tests/tests.yml

This file was deleted.

25 changes: 0 additions & 25 deletions fedora-tests/upstream.sh

This file was deleted.

1 change: 0 additions & 1 deletion files/local-tests-requirements.yaml
Expand Up @@ -5,7 +5,6 @@
project_dir: "{{ playbook_dir }}/.."
tasks:
- include_tasks: tasks/rpm-test-deps.yaml
- include_tasks: tasks/configure-git.yaml
- include_tasks: tasks/ogr.yaml
- include_tasks: tasks/sandcastle.yaml
# To (re-)generate tests_recording/test_data/
Expand Down
1 change: 0 additions & 1 deletion files/packit-testing-farm-prepare.yaml
Expand Up @@ -5,5 +5,4 @@
- include_tasks: tasks/generic-dnf-requirements.yaml
- include_tasks: tasks/python-compile-deps.yaml
- include_tasks: tasks/rpm-test-deps.yaml
- include_tasks: tasks/configure-git.yaml
- include_tasks: tasks/sandcastle.yaml
5 changes: 0 additions & 5 deletions files/tasks/configure-git.yaml

This file was deleted.

1 change: 0 additions & 1 deletion files/zuul-tests-session-recording.yaml
Expand Up @@ -6,7 +6,6 @@
tasks:
- include_tasks: tasks/rpm-test-deps.yaml
- include_tasks: tasks/install-packit.yaml
- include_tasks: tasks/configure-git.yaml
- include_tasks: tasks/sandcastle.yaml
- name: Run session recorded tests
command: make check TESTS_TARGET=tests_recording
Expand Down
1 change: 0 additions & 1 deletion files/zuul-tests.yaml
Expand Up @@ -6,7 +6,6 @@
tasks:
- include_tasks: tasks/rpm-test-deps.yaml
- include_tasks: tasks/install-packit.yaml
- include_tasks: tasks/configure-git.yaml
- include_tasks: tasks/sandcastle.yaml
- name: Run unit, integration and functional tests
command: make check
Expand Down
13 changes: 5 additions & 8 deletions plans/full.fmf
@@ -1,9 +1,6 @@
summary:
Unit, integration & functional tests.
prepare:
how: ansible
playbooks:
- files/packit-testing-farm-prepare.yaml
summary: Unit, integration & functional tests.
discover:
how: fmf
filter: tier:1
execute:
script:
- make check
how: tmt
25 changes: 17 additions & 8 deletions plans/session-recording.fmf
@@ -1,9 +1,18 @@
summary:
Tests using pre-recorded responses from external services.
prepare:
how: ansible
playbooks:
- files/packit-testing-farm-prepare-session-recording.yaml
summary: Session recording testcases
discover:
how: fmf
filter: tier:2
execute:
script:
- make check TESTS_TARGET=tests_recording
how: tmt
adjust:
when: "distro <= rhel-8 or distro <= centos-8"
prepare:
- how: install
name: ensure_copr_plugin
order: 10
package:
- dnf-plugins-core
- how: shell
name: requre_copr
order: 20
script: 'dnf -y copr enable jscotka/requre'
10 changes: 5 additions & 5 deletions plans/smoke.fmf
@@ -1,6 +1,6 @@
summary:
Basic smoke tests.
summary: Basic simple tests
discover:
how: fmf
filter: tier:0
execute:
script:
- packit --version
- packit --help
how: tmt
33 changes: 33 additions & 0 deletions tests/conftest.py
Expand Up @@ -23,6 +23,8 @@
import shutil
from pathlib import Path
from typing import Tuple
import subprocess
import tempfile

import pytest
from flexmock import flexmock
Expand All @@ -41,6 +43,20 @@
)


TMP_DIR = "/tmp/pytest_tmp_path/"

# define own tmp_path fixture for older version of pytest (Centos)
try:
from _pytest import tmpdir

_ = tmpdir.tmp_path
except (ImportError, AttributeError, KeyError):

@pytest.fixture()
def tmp_path():
return Path(tempfile.mkdtemp(prefix=TMP_DIR))


def get_git_repo_and_remote(
target_dir: Path, repo_template_path: Path
) -> Tuple[Path, Path]:
Expand Down Expand Up @@ -187,3 +203,20 @@ def copr_client_mock(get_list_return=None):

copr_mock = flexmock(mock_chroot_proxy=flexmock(get_list=lambda: get_list_return))
return copr_mock


@pytest.fixture(autouse=True)
def configure_git():
CMDS = [
["git", "config", "--global", "user.email", "packit@redhat.com"],
["git", "config", "--global", "user.name", "Packit Test"],
]
# verify that git is already configured
try:
output = subprocess.check_output(["git", "config", "-l", "--global"])
except subprocess.CalledProcessError:
output = ""
if "user.name" in output if isinstance(output, str) else output.decode():
return
for item in CMDS:
subprocess.call(item)
24 changes: 24 additions & 0 deletions tests/full.fmf
@@ -0,0 +1,24 @@
require:
- python3-flexmock
- python3-pytest
- python3-setuptools_scm_git_archive
- python3-setuptools_scm
- python3-distro
- python3-devel
- packit
- python3-packit
- python3-pytest-cov
- rpm-build
- rpmdevtools
- python3-bodhi-client
- fedpkg
- git
- make
#- rpmautospec-rpm-macros
component:
- packit
tier: 1
tag:
- basic
test: pytest-3 -v .
duration: 30m
6 changes: 4 additions & 2 deletions tests/integration/test_patches.py
Expand Up @@ -8,6 +8,8 @@
from pathlib import Path
from packit.patches import PatchGenerator, PatchMetadata

TESTS_DIR = str(Path(__file__).parent.parent)


@pytest.fixture
def git_repo(tmpdir):
Expand All @@ -18,14 +20,14 @@ def git_repo(tmpdir):
"""
repo = git.Repo.init(tmpdir)
shutil.copytree(
src="tests/data/patches/previous/",
src=f"{TESTS_DIR}/data/patches/previous/",
dst=repo.working_tree_dir,
dirs_exist_ok=True,
)
repo.git.add(repo.working_tree_dir)
repo.git.commit("-mInitial patches")
shutil.copytree(
src="tests/data/patches/regenerated/",
src=f"{TESTS_DIR}/data/patches/regenerated/",
dst=repo.working_tree_dir,
dirs_exist_ok=True,
)
Expand Down
8 changes: 8 additions & 0 deletions tests/smoke.fmf
@@ -0,0 +1,8 @@
require:
- packit
- python3-packit
summary: Basic smoke test
test: ./smoke.sh
tag:
- smoke
tier: 0
5 changes: 5 additions & 0 deletions tests/smoke.sh
@@ -0,0 +1,5 @@
#!/bin/bash
set -eux

packit --version
packit --help
13 changes: 13 additions & 0 deletions tests_recording/main.fmf
@@ -0,0 +1,13 @@
require:
- python3-flexmock
- python3-requre
- python3-pytest
- packit
- python3-packit
component:
- packit
tier: 2
tag:
- requre
test: pytest-3 -v .
duration: 10m

0 comments on commit 45fa5ae

Please sign in to comment.