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

Make test_framework available for users when creating scenarios #621

Merged
merged 13 commits into from
Sep 30, 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
61 changes: 0 additions & 61 deletions .github/workflows/deploy.yml

This file was deleted.

39 changes: 1 addition & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,8 @@ jobs:
enable-cache: true
- run: uvx ruff format . --check

build-image:
needs: [ruff, ruff-format]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v5
with:
file: resources/images/commander/Dockerfile
context: .
tags: bitcoindevproject/warnet-commander:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/commander.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: commander
path: /tmp/commander.tar

test:
needs: [build-image]
needs: [ruff, ruff-format]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -80,11 +54,6 @@ jobs:
memory: 4000m
- name: Start minikube's loadbalancer tunnel
run: minikube tunnel &> /dev/null &
- name: Download commander artifact
uses: actions/download-artifact@v4
with:
name: commander
path: /tmp
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
Expand All @@ -94,12 +63,6 @@ jobs:
run: uv python install $PYTHON_VERSION
- name: Install project
run: uv sync --all-extras --dev
- name: Install commander image
run: |
echo loading commander image into minikube docker
eval $(minikube -p minikube docker-env)
docker load --input /tmp/commander.tar
docker image ls -a
- name: Run tests
run: |
source .venv/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ build-backend = "setuptools.build_meta"
include-package-data = true

[tool.setuptools.packages.find]
where = ["src", "."]
where = ["src", ".", "resources/scenarios"]
include = ["warnet*", "test_framework*", "resources*"]

[tool.setuptools.package-data]
Expand Down
9 changes: 0 additions & 9 deletions resources/charts/commander/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "commander.fullname" . }}-scenario
labels:
{{- include "commander.labels" . | nindent 4 }}
binaryData:
scenario.py: {{ .Values.scenario }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "commander.fullname" . }}-warnet
labels:
Expand Down
35 changes: 20 additions & 15 deletions resources/charts/commander/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@ metadata:
mission: commander
spec:
restartPolicy: {{ .Values.restartPolicy }}
initContainers:
- name: init
image: busybox
command: ["/bin/sh", "-c"]
args:
- |
while [ ! -f /shared/archive.pyz ]; do
echo "Waiting for /shared/archive.pyz to exist..."
sleep 2
done
volumeMounts:
- name: shared-volume
mountPath: /shared
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: python:3.12-slim
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- |
python3 /scenario.py {{ .Values.args }}
python3 /shared/archive.pyz {{ .Values.args }}
volumeMounts:
- name: scenario
mountPath: /scenario.py
subPath: scenario.py
- name: warnet
mountPath: /warnet.json
subPath: warnet.json
- name: shared-volume
mountPath: /shared
volumes:
- name: scenario
configMap:
name: {{ include "commander.fullname" . }}-scenario
- name: warnet
configMap:
name: {{ include "commander.fullname" . }}-warnet
- name: shared-volume
emptyDir: {}
8 changes: 0 additions & 8 deletions resources/charts/commander/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ namespace: warnet

restartPolicy: Never

image:
repository: bitcoindevproject/warnet-commander
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
Expand Down Expand Up @@ -71,8 +65,6 @@ volumeMounts: []

port:

scenario: ""

warnet: ""

args: ""
11 changes: 0 additions & 11 deletions resources/images/commander/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions resources/networks/6_node_bitcoin/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,5 @@ nodes:
connect:
- tank-0006
- name: tank-0006
fork_observer:
enabled: true
caddy:
enabled: true
3 changes: 1 addition & 2 deletions resources/scenarios/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import signal
import sys
import tempfile
from pathlib import Path
from typing import Dict

from test_framework.authproxy import AuthServiceProxy
Expand All @@ -21,7 +20,7 @@
from test_framework.test_node import TestNode
from test_framework.util import PortSeed, get_rpc_proxy

WARNET_FILE = Path(os.path.dirname(__file__)) / "warnet.json"
WARNET_FILE = "/shared/warnet.json"

try:
with open(WARNET_FILE) as file:
Expand Down
12 changes: 6 additions & 6 deletions resources/scenarios/ln_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

from time import sleep

# The base class exists inside the commander container
try:
from commander import Commander
except ImportError:
from resources.scenarios.commander import Commander
from commander import Commander


class LNInit(Commander):
Expand Down Expand Up @@ -185,5 +181,9 @@ def funded_lnnodes():
)


if __name__ == "__main__":
def main():
LNInit().main()


if __name__ == "__main__":
main()
12 changes: 6 additions & 6 deletions resources/scenarios/miner_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

from time import sleep

# The base class exists inside the commander container
try:
from commander import Commander
except ImportError:
from resources.scenarios.commander import Commander
from commander import Commander


class Miner:
Expand Down Expand Up @@ -72,5 +68,9 @@ def run_test(self):
sleep(self.options.interval)


if __name__ == "__main__":
def main():
MinerStd().main()


if __name__ == "__main__":
main()
13 changes: 6 additions & 7 deletions resources/scenarios/reconnaissance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import socket

# The base class exists inside the commander container when deployed,
# but requires a relative path inside the python source code for other functions.
try:
from commander import Commander
except ImportError:
from resources.scenarios.commander import Commander
from commander import Commander

# The entire Bitcoin Core test_framework directory is available as a library
from test_framework.messages import MSG_TX, CInv, hash256, msg_getdata
Expand Down Expand Up @@ -85,5 +80,9 @@ def run_test(self):
self.log.info(f"Got notfound message from {dstaddr}:{dstport}")


if __name__ == "__main__":
def main():
Reconnaissance().main()


if __name__ == "__main__":
main()
11 changes: 5 additions & 6 deletions resources/scenarios/signet_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
# we use the authproxy from the test framework.
###

# The base class exists inside the commander container
try:
from commander import Commander
except ImportError:
from resources.scenarios.commander import Commander
from commander import Commander

import json
import logging
Expand Down Expand Up @@ -566,5 +562,8 @@ def get_args(parser):

return args

if __name__ == "__main__":
def main():
SignetMinerScenario().main()

if __name__ == "__main__":
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ def run_test(self):
raise Exception("Failed execution!")


if __name__ == "__main__":
def main():
Failure().main()


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,9 @@ def assert_connection(self, connector, connectee_index, connection_type: Connect
raise ValueError("ConnectionType must be of type DNS or IP")


if __name__ == "__main__":
def main():
ConnectDag().main()


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ def run_test(self):
p2p_block_store.wait_until(lambda: p2p_block_store.blocks[best_block] == 1)


if __name__ == "__main__":
def main():
GetdataTest().main()


if __name__ == "__main__":
main()
Loading