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

Add detect rhel version to testkomodo script #664

Merged
merged 3 commits into from
Feb 23, 2024
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
24 changes: 23 additions & 1 deletion ci/testkomodo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ copy_test_files () {
cp $CI_SOURCE_ROOT/pyproject.toml $CI_TEST_ROOT
}

get_os_arch () {
uname_info=$(uname -a)

rhel7=$(echo "$uname_info" | grep "el7")
rhel8=$(echo "$uname_info" | grep "el8")

os_arch="undetermined"

if [ "$rhel7" ]; then
os_arch="x86_64_RH_7"
elif [ "$rhel8" ]; then
os_arch="x86_64_RH_8"
else
echo "$os_arch"
exit 1
fi

echo "$os_arch"
exit 0
}

start_tests () {
pytest -n auto --flow-simulator="/project/res/x86_64_RH_7/bin/flowdaily" --eclipse-simulator="runeclipse"
os_arch="$(get_os_arch)"
pytest -n auto --flow-simulator="/project/res/$os_arch/bin/flowdaily" --eclipse-simulator="runeclipse"
}
3 changes: 3 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ running tests that rely upon a black oil simulation.

.. code-block:: console

# running on redhat 7
pytest -n auto --flow-simulator="/project/res/x86_64_RH_7/bin/flowdaily" --eclipse-simulator="runeclipse"

# running on redhat 8
pytest -n auto --flow-simulator="/project/res/x86_64_RH_8/bin/flowdaily" --eclipse-simulator="runeclipse"

Code style
----------
Expand Down
16 changes: 16 additions & 0 deletions src/subscript/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import sys
from pathlib import Path

try:
from importlib import metadata
Expand All @@ -9,6 +10,21 @@
pass


def detect_os(release_file: Path = Path("/etc/redhat-release")) -> str:
"""Detect operating system string in runtime, just use default if not found."""
default_os_version = "x86_64_RH_7"

if release_file.is_file():
with open(release_file, "r", encoding="utf-8") as buffer:
tokens = buffer.read().split()
for t in tokens:
if "." in t:
major = t.split(".")[0]
return f"x86_64_RH_{major}"
raise ValueError("Could not detect RHEL version")
return default_os_version


def getLogger(module_name="subscript"):
# pylint: disable=invalid-name
"""Provides a unified logger for subscript scripts.
Expand Down
17 changes: 2 additions & 15 deletions src/subscript/runrms/runrms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import yaml

from subscript import getLogger
from subscript import detect_os, getLogger

logger = getLogger(__name__)

Expand Down Expand Up @@ -288,7 +288,7 @@ def __init__(self):
self.warn_empty_version = False
self.aps_toolbox_path = None

self.detect_os()
self.osver = detect_os(RHEL_ID)

self.oldpythonpath = ""
if "PYTHONPATH" in os.environ:
Expand All @@ -304,19 +304,6 @@ def __init__(self):
_BColors.ENDC,
)

def detect_os(self):
"""Detect operating system string in runtime, just use default if not found."""
if RHEL_ID.is_file():
with open(RHEL_ID, "r", encoding="utf-8") as buffer:
tokens = buffer.read().split()
for t in tokens:
if "." in t:
major = t.split(".")[0]
self.osver = f"x86_64_RH_{major}"
logger.debug("RHEL version found in %s", RHEL_ID)
return
raise ValueError("Could not detect RHEL version")

def do_parse_args(self, args):
"""Parse command line args."""
if args is None:
Expand Down
Loading