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

charts: split off defaultConfig from [node] config #622

Merged
merged 3 commits into from
Oct 3, 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
22 changes: 1 addition & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
test:
- conf_test.py
- dag_connection_test.py
- graph_test.py
- logging_test.py
- rpc_test.py
- services_test.py
Expand Down Expand Up @@ -87,24 +88,3 @@ jobs:
name: kubernetes-logs-${{ matrix.test }}
path: ./k8s-logs
retention-days: 5
test-without-mk:
runs-on: ubuntu-latest
strategy:
matrix:
test:
- graph_test.py
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
version: "latest"
enable-cache: true
- name: Install Python
run: uv python install $PYTHON_VERSION
- name: Install project
run: uv sync --all-extras --dev
- name: Run tests
run: |
source .venv/bin/activate
./test/${{matrix.test}}
1 change: 1 addition & 0 deletions resources/charts/bitcoincore/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data:
rpcport={{ index .Values .Values.chain "RPCPort" }}
zmqpubrawblock=tcp://0.0.0.0:{{ .Values.ZMQBlockPort }}
zmqpubrawtx=tcp://0.0.0.0:{{ .Values.ZMQTxPort }}
{{- .Values.defaultConfig | nindent 4 }}
{{- .Values.config | nindent 4 }}
{{- range .Values.connect }}
{{- print "connect=" . | nindent 4}}
Expand Down
2 changes: 2 additions & 0 deletions resources/charts/bitcoincore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ baseConfig: |

config: ""

defaultConfig: ""

connect: []
loadSnapshot:
enabled: false
Expand Down
5 changes: 5 additions & 0 deletions resources/networks/6_node_bitcoin/network.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
nodes:
- name: tank-0001
config: uacomment=tank0001
image:
tag: "26.0"
connect:
- tank-0002
- tank-0003
- name: tank-0002
config: uacomment=tank0002
resources:
limits:
cpu: 100m
Expand All @@ -17,14 +19,17 @@ nodes:
- tank-0003
- tank-0004
- name: tank-0003
config: uacomment=tank0003
connect:
- tank-0004
- tank-0005
- name: tank-0004
config: uacomment=tank0004
connect:
- tank-0005
- tank-0006
- name: tank-0005
config: uacomment=tank0005
connect:
- tank-0006
- name: tank-0006
Expand Down
2 changes: 1 addition & 1 deletion resources/networks/6_node_bitcoin/node-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: "27.0"

config: |
defaultConfig: |
dns=1
debug=rpc
2 changes: 1 addition & 1 deletion resources/networks/fork_observer/node-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: "27.0"

config: |
defaultConfig: |
dns=1
debug=rpc
rpcauth=forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c
Expand Down
5 changes: 2 additions & 3 deletions src/warnet/bitcoin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
import re
import subprocess
import sys
from datetime import datetime
from io import BytesIO

import click
from urllib3.exceptions import MaxRetryError

from test_framework.messages import ser_uint256
from test_framework.p2p import MESSAGEMAP
from urllib3.exceptions import MaxRetryError

from .k8s import get_default_namespace, get_mission
from .process import run_command
Expand Down Expand Up @@ -187,7 +187,6 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
file_path = f"{base_dir}/{dir_name}/{file}"
# Fetch the file contents from the container
cmd = f"kubectl exec {tank_a} -- cat {file_path}"
import subprocess
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't there a reason this was in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its up top now, i thought that might be what the linter was complaining about since it does not inform me, the guy trying to pass CI, what it was complaining about 🔥


blob = subprocess.run(
cmd, shell=True, capture_output=True, executable="bash"
Expand Down
2 changes: 1 addition & 1 deletion test/data/signet/node-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ chain: signet
spec:
restartPolicy: Always

config: |
defaultConfig: |
debug=rpc
debug=net
signetchallenge=0014d33b6e11ca95c4edccd8e986434358d79e919730
73 changes: 52 additions & 21 deletions test/graph_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import json
import os
import shutil

import pexpect
from test_base import TestBase
Expand All @@ -15,34 +15,65 @@ def __init__(self):

def run_test(self):
try:
# cwd out of the git repo for remainder of script
os.chdir(self.tmpdir)
self.directory_not_exist()
os.mkdir(NETWORKS_DIR)
self.directory_exists()

self.run_created_network()
finally:
shutil.rmtree(NETWORKS_DIR) if os.path.exists(NETWORKS_DIR) else None
self.cleanup()

def directory_not_exist(self):
self.sut = pexpect.spawn("warnet create")
self.sut.expect("init", timeout=50)
try:
self.log.info("testing warnet create, dir doesn't exist")
self.sut = pexpect.spawn("warnet create")
self.sut.expect("init", timeout=10)
except Exception as e:
print(f"\nReceived prompt text:\n {self.sut.before.decode('utf-8')}\n")
raise e

def directory_exists(self):
self.sut = pexpect.spawn("warnet create")
self.sut.expect("name", timeout=10)
self.sut.sendline("ANewNetwork")
self.sut.expect("many", timeout=10)
self.sut.sendline("")
self.sut.expect("connections", timeout=10)
self.sut.sendline("")
self.sut.expect("version", timeout=10)
self.sut.sendline("")
self.sut.expect("enable fork-observer", timeout=10)
self.sut.sendline("")
self.sut.expect("seconds", timeout=10)
self.sut.sendline("")
self.sut.expect("enable grafana", timeout=10)
self.sut.sendline("")
self.sut.expect("successfully", timeout=50)
try:
self.log.info("testing warnet create, dir does exist")
self.sut = pexpect.spawn("warnet create")
self.sut.expect("name", timeout=10)
self.sut.sendline("ANewNetwork")
self.sut.expect("many", timeout=10)
self.sut.sendline("")
self.sut.expect("connections", timeout=10)
self.sut.sendline("")
self.sut.expect("version", timeout=10)
self.sut.sendline("")
self.sut.expect("enable fork-observer", timeout=10)
self.sut.sendline("")
self.sut.expect("seconds", timeout=10)
self.sut.sendline("")
self.sut.expect("enable grafana", timeout=10)
self.sut.sendline("")
self.sut.expect("successfully", timeout=50)
except Exception as e:
print(f"\nReceived prompt text:\n {self.sut.before.decode('utf-8')}\n")
raise e

def run_created_network(self):
self.log.info("adding custom config to one tank")
with open("networks/ANewNetwork/network.yaml") as f:
s = f.read()
s = s.replace(" name: tank-0000\n", " name: tank-0000\n config: debug=mempool\n")
with open("networks/ANewNetwork/network.yaml", "w") as f:
f.write(s)

self.log.info("deploying new network")
self.warnet("deploy networks/ANewNetwork")
self.wait_for_all_tanks_status(target="running")
debugs = json.loads(self.warnet("bitcoin rpc tank-0000 logging"))
# set in defaultConfig
assert debugs["rpc"]
# set in config just for this tank
assert debugs["mempool"]
# santy check
assert not debugs["zmq"]


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def setup_logging(self):
logging.config.dictConfig(logging_config)
self.log = logging.getLogger("test")
self.log.info("Logging started")
self.log.info(f"Testdir: {self.tmpdir}")

def cleanup(self, signum=None, frame=None):
try:
Expand Down