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

adding automatically generated comments #93

Merged
merged 4 commits into from
Oct 17, 2023
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
1 change: 1 addition & 0 deletions node-runner-cli/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
responses= "==0.23.3"
requests = "==2.31.0"
PyYAML = "==6.0.0"
deepmerge = "==0.3.0"
Expand Down
4 changes: 4 additions & 0 deletions node-runner-cli/config/BaseConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def to_yaml(self):
def to_file(self, config_file):
config_to_dump = self.to_dict()
with open(config_file, 'w') as f:
f.write("# WARNING!! This file is automatically generated and it is\n")
f.write("# overriden when on install/update commands.\n")
f.write("# Please consider re-running config/install commands rather\n")
f.write("# than manually edit this file\n")
yaml.dump(config_to_dump, f, sort_keys=True, default_flow_style=False)


Expand Down
5 changes: 5 additions & 0 deletions node-runner-cli/templates/node-monitoring.yml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

version: '2.4'

services:
Expand Down
5 changes: 5 additions & 0 deletions node-runner-cli/templates/radix-fullnode-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

version: '3.8'
services:
{% if core_node is not none and core_node is defined %}
Expand Down
5 changes: 5 additions & 0 deletions node-runner-cli/templates/standalone-gateway-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

version: '3.8'
services:
gateway_api: # This is the base -- the _image and _built containers are defined below
Expand Down
5 changes: 5 additions & 0 deletions node-runner-cli/templates/systemd-default.config.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

ntp=false
ntp.pool=pool.ntp.org

Expand Down
5 changes: 5 additions & 0 deletions node-runner-cli/tests/fixtures/gateway-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

version: '3.8'
services:
gateway_api: # This is the base -- the _image and _built containers are defined below
Expand Down
6 changes: 5 additions & 1 deletion node-runner-cli/tests/unit/test_gateway_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from deepdiff import DeepDiff
from yaml import UnsafeLoader

from config.BaseConfig import SetupMode
from config.DockerConfig import DockerConfig
from config.SystemDConfig import SystemDConfig
from setup.DockerSetup import DockerSetup
Expand Down Expand Up @@ -125,6 +126,8 @@ def render_compose_fixture(self):

@patch('sys.stdout', new_callable=StringIO)
def test_setup_gateway_ask_core_api(self, mockout):
SetupMode.instance()
SetupMode.mode = "DETAILED"
urllib3.disable_warnings()
keyboard_input = ["", "CoreNodeName"]
default_value = "http://localhost:3332"
Expand Down Expand Up @@ -185,7 +188,8 @@ def test_setup_gateway_compose_file_fixture_test(self, mockout):
with patch('builtins.input', side_effect=[install_keyboard_input]):
GatewaySetup.conditionaly_install_standalone_gateway(config)

fixture_file = "./tests/fixtures/gateway-docker-compose.yaml"
tests_dir = dirname(dirname(__file__))
fixture_file = join(tests_dir, "fixtures/gateway-docker-compose.yaml")
with open(fixture_file) as f1:
with open(config.gateway.docker_compose) as f2:
self.assertEqual(f1.read(), f2.read())
Expand Down
49 changes: 45 additions & 4 deletions node-runner-cli/tests/unit/test_systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest.mock import patch

import urllib3
import responses

from babylonnode import main
from config.CommonSystemDConfig import CommonSystemdConfig
Expand Down Expand Up @@ -68,15 +69,21 @@ def test_systemd_dependencies(self):
["main", "systemd", "dependencies"]):
main()

@responses.activate
@patch('sys.stdout', new_callable=StringIO)
def test_systemd_config(self, mockout):
urllib3.disable_warnings()
responses.add(
responses.GET,
f'https://api.github.com/repos/radixdlt/babylon-nginx/releases/latest',
json={'tag_name': "v1"},
status=200)
with patch('builtins.input', side_effect=['Y']):
with patch("sys.argv",
["main", "systemd", "config", "-m", "CORE", "-i", "18.133.170.30", "-t",
"radix://tn1q28eygvxshszxk48jhjxdmyne06m3x6hfyvxg7a45qt8cksffx6z7uu6392@15.236.228.96",
"-n", "2", "-k", "radix", "-d", "/tmp", "-dd", "/tmp", "-v", "randomvalidatoraddress", "-nk",
"-a"]):
"-a", "-r", "1"]):
main()

@unittest.skip("For verification only")
Expand All @@ -102,7 +109,12 @@ def test_systemd_setup_default_config(self, mockout):

f = open("/tmp/default.config", "r")
default_config = f.read()
fixture = """ntp=false
fixture = """# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

ntp=false
ntp.pool=pool.ntp.org

network.id=1
Expand Down Expand Up @@ -147,7 +159,12 @@ def test_systemd_setup_default_config_without_validator(self, mockout):

f = open("/tmp/default.config", "r")
default_config = f.read()
fixture = """ntp=false
fixture = """ # WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

ntp=false
ntp.pool=pool.ntp.org

network.id=1
Expand Down Expand Up @@ -186,7 +203,12 @@ def test_systemd_setup_default_config_jinja(self, mockout):
settings.migration.use_olympia = False
render_template = Renderer().load_file_based_template("systemd-default.config.j2").render(
settings.to_dict()).rendered
fixture = """ntp=false
fixture = """# WARNING!! This file is automatically generated and it is
# overriden when on install/update commands.
# Please consider re-running config/install commands rather
# than manually edit this file

ntp=false
ntp.pool=pool.ntp.org

network.id=1
Expand Down Expand Up @@ -317,7 +339,26 @@ def test_systemd_java_opts_increased_on_migration(self):
environment_yaml = settings.create_environment_yaml()
self.assertTrue("-Xms12g -Xmx12g" in environment_yaml)

@responses.activate
def test_systemd_version_update(self):
responses.add(
responses.GET,
f'https://api.github.com/repos/radixdlt/babylon-node/releases/latest',
json={'tag_name': "v1"},
status=200)

responses.add(
responses.GET,
f'https://api.github.com/repos/radixdlt/babylon-gateway/releases/latest',
json={'tag_name': "v1"},
status=200)

responses.add(
responses.GET,
f'https://api.github.com/repos/radixdlt/babylon-nginx/releases/latest',
json={'tag_name': "v1"},
status=200)

systemd_config = SystemDConfig({})
systemd_config.gateway.enabled = True
systemd_config.core_node.core_release = "oldversion"
Expand Down