Skip to content

Commit

Permalink
Pull lfs but only run on amazon linux
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeShirnia committed Apr 29, 2024
1 parent 79fc3c0 commit db1c4e5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 22 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ jobs:
run: |
docker run --rm -v ${{ github.workspace }}:/app \
${{ env.REPOSITORY }}:${{ matrix.distro }}-pytest \
${{ steps.setup.outputs.command }} -v tests/test_system.py -p no:cacheprovider
${{ steps.setup.outputs.command }} -v tests/test_validate_options.py -p no:cacheprovider
test-systems-with-logs:
# We only want to pull large files once, so lets run this on a single runner
runs-on: ubuntu-latest
strategy:
matrix:
distro: ["amazonlinux"]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
lfs: true

- name: Run system tests with logs
run: |
docker run --rm -v ${{ github.workspace }}:/app \
${{ env.REPOSITORY }}:${{ matrix.distro }}-pytest \
pytest -v tests/test_large_log.py -p no:cacheprovider -s
50 changes: 50 additions & 0 deletions tests/test_large_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import sys
from optparse import Values

import pytest

# Add the parent directory to the path so we can import the latest version of the script
oom_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, oom_dir)

from oom_investigate import System, run, validate_options

# Ignore DeprecationWarning and PendingDeprecationWarning warnings
pytest.mark.filterwarnings("ignore::DeprecationWarning")
pytest.mark.filterwarnings("ignore::PendingDeprecationWarning")


class TestSystem:
system = System()
values = Values(
{
"file": False,
"show_counter": 5,
"reverse": False,
"journalctl": False,
"dmesg": False,
"quick": False,
"version": None,
"show_all": False,
}
)

def test_file_processing(self, capsys):
# Test specific functionality when '-f messages' is passed
options = self.values
options.file = "tests/assets/logs/messages"
# While we're here, we might as well test the --all functionality so we don't have to pass
# the large log file too many times
options.show_all = True

with pytest.raises(SystemExit) as ex:
self.system.log_to_use = options.file
run(self.system, options)
assert ex.code == 0

out, _ = capsys.readouterr()
assert "Using Log File: \x1b[0m\x1b[1;32mtests/assets/logs/messages" in out
assert "OOM Incidents: \x1b[0m\x1b[1;31m19\x1b[0m" in out
assert "OOM Incident: \x1b[0m\x1b[0;96m19\x1b[0m" in out
assert "Displaying all OOM incidents:" in out
21 changes: 1 addition & 20 deletions tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestSystem:
"dmesg": False,
"quick": False,
"version": None,
"show_all": False
"show_all": False,
}
)

Expand All @@ -37,25 +37,6 @@ def test_distro_info_imports(self):
assert distro_info[0] is not None
assert distro_info[1] is not None

def test_file_processing(self, capsys):
# Test specific functionality when '-f messages' is passed
options = self.values
options.file = "tests/assets/logs/messages"
# While we're here, we might as well test the --all functionality so we don't have to pass
# the large log file too many times
options.show_all = True

with pytest.raises(SystemExit) as ex:
self.system.log_to_use = options.file
run(self.system, options)
assert ex.code == 0

out, _ = capsys.readouterr()
assert "Using Log File: \x1b[0m\x1b[1;32mtests/assets/logs/messages" in out
assert "OOM Incidents: \x1b[0m\x1b[1;31m19\x1b[0m" in out
assert "OOM Incident: \x1b[0m\x1b[0;96m19\x1b[0m" in out
assert "Displaying all OOM incidents:" in out

def test_default_system_log(self):
# Test default system log file
options = self.values
Expand Down
2 changes: 1 addition & 1 deletion tests/test_validate_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestSystem:
"dmesg": False,
"quick": False,
"version": None,
"show_all": False
"show_all": False,
}
)

Expand Down

0 comments on commit db1c4e5

Please sign in to comment.