Skip to content
Merged
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
10 changes: 8 additions & 2 deletions .github/workflows/python-daily-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ jobs:
- uses: fedora-python/tox-github-action@main
with:
tox_env: ${{ matrix.tox_env }}
workdir: "daily_tests/"
...
workdir: "daily-tests/"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: daily-tests-unit
files: daily-tests/coverage.xml
fail_ci_if_error: false
8 changes: 7 additions & 1 deletion .github/workflows/python-ocp-generator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ jobs:
with:
tox_env: ${{ matrix.tox_env }}
workdir: "ocp-stream-generator/"
...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ocp-stream-generator-unit
files: ocp-stream-generator/coverage.xml
fail_ci_if_error: false
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@
.idea
.vscode
__pycache__


# Unit tests / coverage reports
.tox/
.coverage
.coverage.*
.cache
coverage.xml
coverage-unit.xml
coverage-integration.xml
.pytest_cache/
17 changes: 17 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "50...100"

flags:
daily-tests-unit:
carryforward: true
ocp-stream-generator-unit:
carryforward: true

comment:
layout: "reach,diff,flags,files"
behavior: default
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added daily-tests/tests/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest


import show_logs
from daily_tests import show_logs

TEST_DIR = Path(__file__).parent.absolute()
sys.path.append(str(TEST_DIR))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# pylint: disable=import-error,redefined-outer-name
import sys
import pytest

from pathlib import Path
from unittest.mock import MagicMock, patch

import pytest
from daily_tests import download_logs

import download_logs

TEST_DIR = Path(__file__).parent.absolute()
sys.path.insert(0, str(TEST_DIR.parent))
Expand Down Expand Up @@ -94,7 +95,9 @@ def test_download_log_success(self, downloader, tmp_path):
mock_response.status_code = 200
mock_response.content = b"log content"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
result = downloader.download_log("http://example.com/log.txt", "log.txt")

assert result is True
Expand All @@ -107,7 +110,9 @@ def test_download_log_success_failed_dir(self, downloader, tmp_path):
mock_response.status_code = 200
mock_response.content = b"failed log"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
result = downloader.download_log(
"http://example.com/fail.log", "fail.log", is_failed=True
)
Expand All @@ -120,8 +125,10 @@ def test_download_log_failure_after_retries(self, downloader, tmp_path, capsys):
mock_response = MagicMock()
mock_response.status_code = 404

with patch("download_logs.requests.get", return_value=mock_response):
with patch("download_logs.time.sleep"):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
with patch("daily_tests.download_logs.time.sleep"):
result = downloader.download_log(
"http://example.com/missing.log", "missing.log"
)
Expand Down Expand Up @@ -163,7 +170,9 @@ def test_download_tmt_logs_downloads_logs_and_sets_data_link(
mock_response.status_code = 200
mock_response.content = b"log content"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
downloader.download_tmt_logs()

assert downloader.data_dir_url_link == "http://example.com/data"
Expand Down Expand Up @@ -208,7 +217,9 @@ def test_download_container_logs_success(self, downloader, tmp_path):
mock_response.text = "<html>data dir</html>"
mock_response.content = b"log"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
result = downloader.download_container_logs()

assert result is True
Expand All @@ -222,7 +233,9 @@ def test_download_container_logs_failed_directory(self, downloader, tmp_path):
mock_response.text = "<html>results</html>"
mock_response.content = b"log"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
result = downloader.download_container_logs(is_failed=True)

assert result is True
Expand All @@ -232,7 +245,9 @@ def test_download_container_logs_http_error(self, downloader, capsys):
mock_response = MagicMock()
mock_response.status_code = 404

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
result = downloader.download_container_logs()

assert result is False
Expand All @@ -248,9 +263,12 @@ def test_get_xml_report_public_url_for_fedora(self, downloader, capsys):
mock_response.status_code = 200
mock_response.content = b"<testsuites></testsuites>"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
with patch(
"download_logs.xmltodict.parse", return_value={"testsuites": {}}
"daily_tests.download_logs.xmltodict.parse",
return_value={"testsuites": {}},
):
result = downloader.get_xml_report()

Expand All @@ -270,9 +288,12 @@ def test_get_xml_report_public_url_for_c9s(
mock_response.status_code = 200
mock_response.content = b"<testsuites></testsuites>"

with patch("download_logs.requests.get", return_value=mock_response):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
with patch(
"download_logs.xmltodict.parse", return_value={"testsuites": {}}
"daily_tests.download_logs.xmltodict.parse",
return_value={"testsuites": {}},
):
result = downloader.get_xml_report()

Expand All @@ -291,10 +312,11 @@ def test_get_xml_report_private_url_for_rhel(
mock_response.content = b"<testsuites></testsuites>"

with patch(
"download_logs.requests.get", return_value=mock_response
"daily_tests.download_logs.requests.get", return_value=mock_response
) as mock_get:
with patch(
"download_logs.xmltodict.parse", return_value={"testsuites": {}}
"daily_tests.download_logs.xmltodict.parse",
return_value={"testsuites": {}},
):
result = downloader.get_xml_report()

Expand All @@ -306,8 +328,10 @@ def test_get_xml_report_failure_after_retries(self, downloader, capsys):
mock_response = MagicMock()
mock_response.status_code = 500

with patch("download_logs.requests.get", return_value=mock_response):
with patch("download_logs.time.sleep"):
with patch(
"daily_tests.download_logs.requests.get", return_value=mock_response
):
with patch("daily_tests.download_logs.time.sleep"):
result = downloader.get_xml_report()

assert result is False
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions daily-tests/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tox]
package = skip

[testenv]
commands = python3 -m pytest --color=yes -v --cov=daily_tests --cov-report=xml:coverage.xml
deps =
pytest
pytest-cov
PyYAML
requests
xmltodict
3 changes: 0 additions & 3 deletions daily_tests/pytest.ini

This file was deleted.

7 changes: 0 additions & 7 deletions daily_tests/tox.ini

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
import yaml
import json
import sys
from distribution_data import abbreviations, images, latest_description
from ocp_stream_generator.distribution_data import (
abbreviations,
images,
latest_description,
)


class YamlLoader:
Expand Down
3 changes: 0 additions & 3 deletions ocp-stream-generator/pytest.ini

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion ocp-stream-generator/tests/test_imagestream_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3


from stream_generator import ImagestreamFile
from ocp_stream_generator.stream_generator import ImagestreamFile


def test_create_isf():
Expand Down
24 changes: 12 additions & 12 deletions ocp-stream-generator/tests/test_json_builder.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env python3
import json
import re
from stream_generator import JsonBuilder
from stream_generator import Tag
from stream_generator import LatestTag
from stream_generator import CustomTag
from stream_generator import ImagestreamFile
from data.data_json_builder import add_tag_result
from data.data_json_builder import add_tag_latest_result
from data.data_json_builder import add_tag_custom_result
from data.data_json_builder import create_annotation_result
from data.data_json_builder import create_annotation_latest_result
from data.data_json_builder import create_header_result
from data.data_json_builder import generate_json_result
from ocp_stream_generator.stream_generator import JsonBuilder
from ocp_stream_generator.stream_generator import Tag
from ocp_stream_generator.stream_generator import LatestTag
from ocp_stream_generator.stream_generator import CustomTag
from ocp_stream_generator.stream_generator import ImagestreamFile
from tests.data.data_json_builder import add_tag_result
from tests.data.data_json_builder import add_tag_latest_result
from tests.data.data_json_builder import add_tag_custom_result
from tests.data.data_json_builder import create_annotation_result
from tests.data.data_json_builder import create_annotation_latest_result
from tests.data.data_json_builder import create_header_result
from tests.data.data_json_builder import generate_json_result

builder = JsonBuilder()

Expand Down
4 changes: 2 additions & 2 deletions ocp-stream-generator/tests/test_yaml_loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3


from stream_generator import YamlLoader
from data.data_yaml_loader import load_yaml_result
from ocp_stream_generator.stream_generator import YamlLoader
from tests.data.data_yaml_loader import load_yaml_result


def test_load_yaml():
Expand Down
3 changes: 2 additions & 1 deletion ocp-stream-generator/tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[testenv]
commands = python3 -m pytest --color=yes -v
commands = python3 -m pytest --color=yes -v --cov=ocp_stream_generator --cov-report=xml:coverage.xml
deps =
pytest
pytest-cov
PyYAML
2 changes: 1 addition & 1 deletion run_nightly_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function run_tests() {
touch "${DAILY_REPORTS_TESTS_DIR}/tmt_failed"
fi
cp "${LOG_FILE}" "${DAILY_REPORTS_TESTS_DIR}/testing_farm_${TARGET}_${TESTS}.txt"
python3 /root/ci-scripts/daily_tests/download_logs.py "${LOG_FILE}" "${TARGET}" "${TESTS}"
python3 /root/ci-scripts/daily-tests/daily_tests/download_logs.py "${LOG_FILE}" "${TARGET}" "${TESTS}"
}

if [[ "$TESTS" != "test" ]] && [[ "$TESTS" != "test-pytest" ]] && [[ "$TESTS" != "test-upstream" ]] && [[ "$TESTS" != "test-openshift-pytest" ]] && [[ "$TESTS" != "test-openshift-4" ]]; then
Expand Down
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
envlist = daily-tests, ocp-stream-generator

[testenv:daily-tests]
changedir = daily-tests
commands = python3 -m pytest --color=yes -v --cov=daily_tests --cov-report=xml:coverage.xml
deps =
pytest
pytest-cov
PyYAML
requests
xmltodict

[testenv:ocp-stream-generator]
changedir = ocp-stream-generator
commands = python3 -m pytest --color=yes -v --cov=ocp_stream_generator --cov-report=xml:coverage.xml
deps =
pytest
pytest-cov
PyYAML
Loading