Skip to content

Commit

Permalink
fix: reorder tests - lightpush first
Browse files Browse the repository at this point in the history
- test workflow
  • Loading branch information
romanzac committed Aug 7, 2024
1 parent cbfb97f commit b9abfc5
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 19 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/nim_waku_daily_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test Nim -> Nim Waku Interop Tests

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false

on:
push:
branches:
- chore-rlnv2-tests-update
workflow_dispatch:

jobs:
test-common:
uses: ./.github/workflows/test_common_test.yml
secrets: inherit
with:
node1: "wakuorg/nwaku:latest"
node2: "wakuorg/nwaku:latest"
additional_nodes: "wakuorg/nwaku:latest,wakuorg/nwaku:latest,wakuorg/nwaku:latest"
caller: "nim"
112 changes: 112 additions & 0 deletions .github/workflows/test_common_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Test Interop Tests Common

on:
workflow_call:
inputs:
node1:
required: true
description: "Node that usually publishes messages. Used for all tests"
type: string
default: "wakuorg/go-waku:latest"
node2:
required: true
description: "Node that usually queries for published messages. Used for all tests"
type: string
default: "wakuorg/nwaku:latest"
additional_nodes:
required: false
description: "Additional optional nodes used in e2e tests, separated by ,"
type: string
default: "wakuorg/nwaku:latest,wakuorg/go-waku:latest,wakuorg/nwaku:latest"
caller:
required: false
description: "Workflow caller. Used in reporting"
type: string

env:
FORCE_COLOR: "1"
NODE_1: ${{ inputs.node1 }}
NODE_2: ${{ inputs.node2 }}
ADDITIONAL_NODES: ${{ inputs.additional_nodes }}
CALLER: ${{ inputs.caller || 'manual' }}
RLN_CREDENTIALS: ${{ secrets.RLN_CREDENTIALS }}

jobs:

tests:
name: tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:

- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'

- run: pip install -r requirements.txt

- name: Run tests
run: |
pytest tests/relay/test_rln.py
- name: Get allure history
if: always()
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages

- name: Setup allure report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: allure-results
gh_pages: gh-pages/${{ env.CALLER }}
allure_history: allure-history
keep_reports: 30
report_url: https://waku-org.github.io/waku-interop-tests/${{ env.CALLER }}

- name: Deploy report to Github Pages
uses: peaceiris/actions-gh-pages@v3
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: allure-history
destination_dir: ${{ env.CALLER }}

- name: Create job summary
if: always()
env:
JOB_STATUS: ${{ job.status }}
run: |
echo "## Run Information" >> $GITHUB_STEP_SUMMARY
echo "- **Event**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Actor**: ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
echo "- **Node1**: ${{ env.NODE_1 }}" >> $GITHUB_STEP_SUMMARY
echo "- **Node2**: ${{ env.NODE_2 }}" >> $GITHUB_STEP_SUMMARY
echo "- **Additonal Nodes**: ${{ env.ADDITIONAL_NODES }}" >> $GITHUB_STEP_SUMMARY
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "Allure report will be available at: https://waku-org.github.io/waku-interop-tests/${{ env.CALLER }}/${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
if [ "$JOB_STATUS" != "success" ]; then
echo "There are failures with nwaku node. cc <@&1111608257824440330>" >> $GITHUB_STEP_SUMMARY
fi
{
echo 'JOB_SUMMARY<<EOF'
cat $GITHUB_STEP_SUMMARY
echo EOF
} >> $GITHUB_ENV
- name: Send report to Discord
uses: rjstone/discord-webhook-notify@v1
if: always() && env.CALLER != 'manual'
with:
severity: ${{ job.status == 'success' && 'info' || 'error' }}
username: ${{ github.workflow }}
description: "## Job Result: ${{ job.status }}"
details: ${{ env.JOB_SUMMARY }}
webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }}
39 changes: 20 additions & 19 deletions tests/relay/test_rln.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ class TestRelayRLN(StepsRLN, StepsRelay):
SAMPLE_INPUTS_RLN = SAMPLE_INPUTS + SAMPLE_INPUTS + SAMPLE_INPUTS

@pytest.mark.usefixtures("register_main_rln_relay_nodes")
def test_valid_payloads_lightpush_at_spam_rate(self):
message_limit = 1
epoch_sec = 1
self.setup_first_rln_relay_node(lightpush="true", rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec)
self.setup_second_rln_lightpush_node(rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec)
self.subscribe_main_relay_nodes()
start = math.trunc(time())
for i, payload in enumerate(SAMPLE_INPUTS[:5]):
logger.debug(f'Running test with payload {payload["description"]}')
message = self.create_message(payload=to_base64(payload["value"]))
try:
logger.debug(f"Sending message No. #{i + 1}")
now = math.trunc(time())
self.publish_message(message=message, sender=self.light_push_node2, use_lightpush=True)
if i > message_limit and (now - start) <= epoch_sec:
raise AssertionError("Publish with RLN enabled at spam rate worked!!!")
except Exception as e:
assert "RLN validation failed" or "NonceLimitReached" in str(e)

def test_valid_payloads_at_slow_rate(self):
message_limit = 20
self.setup_main_rln_relay_nodes(rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=600)
Expand Down Expand Up @@ -124,7 +143,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self):
message = self.create_message(payload=to_base64(payload["value"]))
try:
logger.debug(f"Sending message No. #{i + 1}")
self.check_published_message_reaches_relay_peer(message, message_propagation_delay=0.1)
self.check_published_message_reaches_relay_peer(message, message_propagation_delay=0.2)
except Exception as e:
logger.error(f'Payload {payload["description"]} failed: {str(e)}')
failed_payloads.append(payload["description"])
Expand Down Expand Up @@ -173,24 +192,6 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self):
except Exception as e:
assert "RLN validation failed" or "NonceLimitReached" in str(e)

def test_valid_payloads_lightpush_at_spam_rate(self):
message_limit = 1
epoch_sec = 1
self.setup_first_rln_relay_node(lightpush="true", rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec)
self.setup_second_rln_lightpush_node(rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec)
self.subscribe_main_relay_nodes()
start = math.trunc(time())
for i, payload in enumerate(SAMPLE_INPUTS[:5]):
logger.debug(f'Running test with payload {payload["description"]}')
message = self.create_message(payload=to_base64(payload["value"]))
try:
now = math.trunc(time())
self.publish_message(message=message, sender=self.light_push_node2, use_lightpush=True)
if i > message_limit and (now - start) <= epoch_sec:
raise AssertionError("Publish with RLN enabled at spam rate worked!!!")
except Exception as e:
assert "RLN validation failed" or "NonceLimitReached" in str(e)

@pytest.mark.skipif("go-waku" in ADDITIONAL_NODES, reason="Test works only with nwaku")
@pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes")
def test_valid_payloads_with_optional_nodes_at_slow_rate(self):
Expand Down

0 comments on commit b9abfc5

Please sign in to comment.