Skip to content

Commit

Permalink
Merge pull request #689 from skalenetwork/fix-init
Browse files Browse the repository at this point in the history
Fix preinstall checks
  • Loading branch information
badrogger authored Dec 16, 2022
2 parents e1c3e93 + 240a13d commit f5c2053
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 3 additions & 1 deletion node_cli/core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def get_static_params(
env_type: str = 'mainnet',
config_path: str = CONTAINER_CONFIG_PATH
) -> Dict:
with open(STATIC_PARAMS_FILEPATH) as requirements_file:
status_params_filename = os.path.basename(STATIC_PARAMS_FILEPATH)
static_params_filepath = os.path.join(config_path, status_params_filename)
with open(static_params_filepath) as requirements_file:
ydata = yaml.load(requirements_file, Loader=yaml.Loader)
return ydata['envs'][env_type]

Expand Down
16 changes: 13 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
import yaml

from node_cli.configs import (
STATIC_PARAMS_FILEPATH,
GLOBAL_SKALE_DIR,
CONTAINER_CONFIG_TMP_PATH,
GLOBAL_SKALE_CONF_FILEPATH,
REMOVED_CONTAINERS_FOLDER_PATH
GLOBAL_SKALE_DIR,
REMOVED_CONTAINERS_FOLDER_PATH,
STATIC_PARAMS_FILEPATH
)
from node_cli.configs import META_FILEPATH
from node_cli.configs.resource_allocation import RESOURCE_ALLOCATION_FILEPATH
Expand Down Expand Up @@ -227,3 +228,12 @@ def ensure_meta_removed():
finally:
if os.path.isfile(META_FILEPATH):
os.remove(META_FILEPATH)


@pytest.fixture
def tmp_config_dir():
os.mkdir(CONTAINER_CONFIG_TMP_PATH)
try:
yield CONTAINER_CONFIG_TMP_PATH
finally:
shutil.rmtree(CONTAINER_CONFIG_TMP_PATH)
14 changes: 13 additions & 1 deletion tests/core_checks_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import os
from pip._internal import main as pipmain
import shutil
import time
from pip._internal import main as pipmain

import mock
import pytest

from node_cli.configs import STATIC_PARAMS_FILEPATH

from node_cli.core.checks import (
CheckType,
DockerChecker,
generate_report_from_result,
get_all_checkers,
get_checks,
get_report,
get_static_params,
MachineChecker,
merge_reports,
PackageChecker,
Expand Down Expand Up @@ -375,3 +379,11 @@ def test_merge_report():
{'name': 'test2', 'status': 'ok', 'info': 'Test1'},
{'name': 'test3', 'status': 'failed', 'info': 'Test1'}
]


def test_get_static_params(tmp_config_dir):
params = get_static_params()
shutil.copy(STATIC_PARAMS_FILEPATH, tmp_config_dir)
tmp_params = get_static_params(config_path=tmp_config_dir)
assert params['server']['cpu_total'] == 8
assert params == tmp_params

0 comments on commit f5c2053

Please sign in to comment.