Skip to content

Commit

Permalink
Merge pull request #1156 from golemfactory/scx1332/update_goth
Browse files Browse the repository at this point in the history
Update goth to 0.17
  • Loading branch information
shadeofblue authored Jun 3, 2024
2 parents 11bf4d0 + eae4238 commit 911da3f
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 73 deletions.
57 changes: 8 additions & 49 deletions .github/workflows/goth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,34 @@ on:
jobs:
goth-tests:
name: Run integration tests
runs-on: [goth, ubuntu-18.04]
runs-on: ubuntu-latest
steps:
- name: install docker-compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.4/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod a+x /usr/local/bin/docker-compose
- name: install ffi and gcc
run: sudo apt-get install -y libffi-dev build-essential

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'

- name: Install and configure Poetry
run: python -m pip install -U pip setuptools poetry==1.3.2
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.8.2

- name: Install dependencies
run: |
poetry env use python3.9
poetry install
- name: Disconnect Docker containers from default network
continue-on-error: true
# related to this issue: https://github.com/moby/moby/issues/23302
run: |
docker network inspect docker_default
sudo apt-get install -y jq
docker network inspect docker_default | jq ".[0].Containers | map(.Name)[]" | tee /dev/stderr | xargs --max-args 1 -- docker network disconnect -f docker_default
- name: Remove Docker containers
continue-on-error: true
run: docker rm -f $(docker ps -a -q)

- name: Restart Docker daemon
# related to this issue: https://github.com/moby/moby/issues/23302
run: sudo systemctl restart docker

- name: Log in to GitHub Docker repository
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin

- name: Initialize the test suite
run: poetry run poe tests_integration_init

- name: Run test suite
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: poetry run poe tests_integration

- name: Upload test logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: goth-logs
path: /tmp/goth-tests

# Only relevant for self-hosted runners
- name: Remove test logs
if: always()
run: rm -rf /tmp/goth-tests

# Only relevant for self-hosted runners
- name: Remove poetry virtual env
if: always()
# Python version below should agree with the version set up by this job.
# In future we'll be able to use the `--all` flag here to remove envs for
# all Python versions (https://github.com/python-poetry/poetry/issues/3208).
run: poetry env remove python3.9
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tests_unit = {cmd = "pytest --cov=yapapi --cov-report html --cov-report term -sv
tests_integration_init = { sequence = ["_gothv_env", "_gothv_requirements", "_gothv_assets"], help="Initialize the integration test environment"}
tests_integration = { cmd = ".envs/yapapi-goth/bin/python -m pytest -svx tests/goth_tests --config-override docker-compose.build-environment.use-prerelease=false --config-path tests/goth_tests/assets/goth-config.yml --ssh-verify-connection --reruns 3 --only-rerun AssertionError --only-rerun TimeoutError --only-rerun goth.runner.exceptions.TimeoutError --only-rerun goth.runner.exceptions.TemporalAssertionError --only-rerun urllib.error.URLError --only-rerun goth.runner.exceptions.CommandError --only-rerun requests.exceptions.ConnectionError --only-rerun OSError --only-rerun requests.exceptions.ReadTimeout", help = "Run the integration tests"}
_gothv_env = "python -m venv .envs/yapapi-goth"
_gothv_requirements = ".envs/yapapi-goth/bin/pip install -U --extra-index-url https://test.pypi.org/simple/ goth==0.14.1 pip pytest pytest-asyncio pytest-rerunfailures pexpect"
_gothv_requirements = ".envs/yapapi-goth/bin/pip install -U --extra-index-url https://test.pypi.org/simple/ goth==0.17.0 pip pytest pytest-asyncio pytest-rerunfailures pexpect"
_gothv_assets = ".envs/yapapi-goth/bin/python -m goth create-assets tests/goth_tests/assets"

clean = {cmd = "rm -rf .coverage .requirements.txt dist md handbook build", help = "Clean all development related files" }
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/___test_resubscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def worker(work_ctx, tasks):
async with Golem(
budget=10.0,
event_consumer=monitor.add_event_sync,
payment_network="rinkeby",
payment_network="holesky",
) as golem:
task: Task # mypy needs this for some reason
async for task in golem.execute_tasks(
Expand Down
4 changes: 2 additions & 2 deletions tests/goth_tests/test_agreement_termination/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ async def worker(ctx: WorkContext, tasks):
yield script
else:
# Simulate some work
script.run("/bin/sleep", "5")
script.run("/bin/sleep", "1")
yield script

task.accept_result()

async with Golem(
budget=10.0,
subnet_tag="goth",
payment_network="rinkeby",
payment_network="holesky",
) as golem:
tasks = [Task(data=n) for n in range(6)]
async for task in golem.execute_tasks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ async def test_agreement_termination(

# Wait for worker failure due to command error
assertion = cmd_monitor.add_assertion(assert_command_error)
agr_id = await assertion.wait_for_result(timeout=60)
agr_id = await assertion.wait_for_result(timeout=120)
logger.info("Detected command error in activity for agreement %s", agr_id)

# Make sure no new tasks are sent and the agreement is terminated
assertion = cmd_monitor.add_assertion(
partial(assert_agreement_cancelled, agr_id),
name=f"assert_agreement_cancelled({agr_id})",
)
await assertion.wait_for_result(timeout=10)
await assertion.wait_for_result(timeout=20)

# Wait for executor shutdown
await cmd_monitor.wait_for_pattern("ShutdownFinished", timeout=60)
await cmd_monitor.wait_for_pattern("ShutdownFinished", timeout=120)
logger.info("Requestor script finished")
2 changes: 1 addition & 1 deletion tests/goth_tests/test_async_task_generation/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def worker(work_ctx, tasks):
budget=10.0,
subnet_tag="goth",
event_consumer=log_event_repr,
payment_network="rinkeby",
payment_network="holesky",
) as golem:
# We use an async task generator that yields tasks removed from
# an async queue. Each computed task will potentially spawn
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_concurrent_executors/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def duplicator(work_ctx, tasks):
output = result.stdout.strip()
task.accept_result(output)

async with Golem(budget=1.0, subnet_tag="goth", payment_network="rinkeby") as golem:
async with Golem(budget=1.0, subnet_tag="goth", payment_network="holesky") as golem:
# Construct a pipeline:
#
# input_tasks
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_instance_restart/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def shutdown(self):


async def main():
async with Golem(budget=1.0, subnet_tag="goth", payment_network="rinkeby") as golem:
async with Golem(budget=1.0, subnet_tag="goth", payment_network="holesky") as golem:
# Start a cluster with a single service.
# The first instance will fail before reaching the `running` state
# due to an error. Another instance should be spawned in its place.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def main():
strategy=ShortDebitNoteIntervalAndPaymentTimeout(),
subnet_tag="goth",
event_consumer=log_event_repr,
payment_network="rinkeby",
payment_network="holesky",
) as golem:
logger = logging.getLogger("yapapi")
logger.handlers[0].setLevel(logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_multiactivity_agreement/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def worker(work_ctx, tasks):
budget=10.0,
subnet_tag="goth",
event_consumer=log_event_repr,
payment_network="rinkeby",
payment_network="holesky",
) as golem:
tasks = [Task(data=n) for n in range(3)]
async for task in golem.execute_tasks(
Expand Down
3 changes: 1 addition & 2 deletions tests/goth_tests/test_power_outage.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ async def test_power_outage(
provider_1 = runner.get_probes(probe_type=ProviderProbe)[0]

async with requestor.run_command_on_host(
"{} --subnet-tag goth --min-cpu-threads 1 "
"--payment-network rinkeby --log-file {}".format(
"{} --subnet-tag goth --min-cpu-threads 1 --log-file {}".format(
blender_path, log_dir / "test_power_outage.log"
),
env=os.environ,
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_recycle_ip/ssh_recycle_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def main():
async with Golem(
budget=1.0,
subnet_tag="goth",
payment_network="rinkeby",
payment_network="holesky",
) as golem:
network = await golem.create_network("192.168.0.1/24")
proxy = SocketProxy(ports=[2222])
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_run_blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def test_run_blender(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{blender_path} --subnet-tag goth --min-cpu-threads 1 --payment-network rinkeby",
f"{blender_path} --subnet-tag goth --min-cpu-threads 1",
env=os.environ,
) as (_cmd_task, cmd_monitor, _process_monitor):
# Add assertions to the command output monitor `cmd_monitor`:
Expand Down
3 changes: 1 addition & 2 deletions tests/goth_tests/test_run_custom_usage_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ async def test_run_custom_usage_counter(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{requestor_path} --running-time {RUNNING_TIME} "
f"--subnet-tag {SUBNET_TAG} --payment-network rinkeby",
f"{requestor_path} --running-time {RUNNING_TIME} --subnet-tag {SUBNET_TAG}",
env=os.environ,
) as (_cmd_task, cmd_monitor, _process_monitor):
cmd_monitor.add_assertion(assert_no_errors)
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_run_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def test_run_scan(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{requestor_path} --subnet-tag {SUBNET_TAG} --scan-size 3 --payment-network rinkeby",
f"{requestor_path} --subnet-tag {SUBNET_TAG} --scan-size 3",
env=os.environ,
) as (_cmd_task, cmd_monitor, process_monitor):
cmd_monitor.add_assertion(assert_no_errors)
Expand Down
3 changes: 1 addition & 2 deletions tests/goth_tests/test_run_simple_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ async def test_run_simple_service(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{requestor_path} --running-time {RUNNING_TIME} "
f"--subnet-tag {SUBNET_TAG} --payment-network rinkeby",
f"{requestor_path} --running-time {RUNNING_TIME} --subnet-tag {SUBNET_TAG}",
env=os.environ,
) as (_cmd_task, cmd_monitor, _process_monitor):
start_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_run_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def test_run_ssh(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{requestor_path} --subnet-tag {SUBNET_TAG} --payment-network rinkeby",
f"{requestor_path} --subnet-tag {SUBNET_TAG}",
env=os.environ,
) as (_cmd_task, cmd_monitor, process_monitor):
start_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_run_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def test_run_webapp(
requestor = runner.get_probes(probe_type=RequestorProbe)[0]

async with requestor.run_command_on_host(
f"{requestor_path} --subnet-tag {SUBNET_TAG} --port {port} --payment-network rinkeby",
f"{requestor_path} --subnet-tag {SUBNET_TAG} --port {port}",
env=os.environ,
) as (_cmd_task, cmd_monitor, process_monitor):
start_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion tests/goth_tests/test_run_yacat.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def test_run_yacat(
async with requestor.run_command_on_host(
f"{yacat_path} --mask ?a?a --hash $P$5ZDzPE45CigTC6EY4cXbyJSLj/pGee0 "
f"--subnet-tag goth --chunk-size {CHUNK_SIZE} --max-workers {PROVIDER_COUNT} "
f"--log-file {(log_dir / logfile).resolve()} --payment-network rinkeby",
f"--log-file {(log_dir / logfile).resolve()}",
env=os.environ,
) as (_cmd_task, cmd_monitor, _process_monitor):
# Add assertions to the command output monitor `cmd_monitor`:
Expand Down

0 comments on commit 911da3f

Please sign in to comment.