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

concurrent requests #126

Merged
merged 27 commits into from
Feb 16, 2024
Merged

concurrent requests #126

merged 27 commits into from
Feb 16, 2024

Conversation

ackintosh
Copy link
Owner

@ackintosh ackintosh commented Jul 29, 2023

Added new test case for testing concurrent requests.

concurrent-requests

testground run single \
  --plan=discv5-testground \
  --testcase=concurrent-requests \
  --builder=docker:generic \
  --runner=local:docker \
  --instances=2 \
  --wait
sequenceDiagram
    participant Node1
    participant Node2
    Note over Node1: Start discv5 server
    Note over Node2: Start discv5 server

    rect rgb(10, 10, 10)
    Note left of Node1: They communicate with each other<br> to establish a session.
    Node1 ->> Node2: message
    Node2 ->> Node1: message
    Note over Node1,Node2: Session established
    end

    rect rgb(100, 100, 0)
    Note right of Node2: In this test case, Node2 session timeout <br>is set to short term (a few seconds)<br> to reproduce session expiration.
    Note over Node2: Session expired
    end

    rect rgb(10, 10, 10)
    Note left of Node1: Node1 sends multiple requests<br> **in parallel**.
    par 
    Node1 ->> Node2: FINDNODE
    and 
    Node1 ->> Node2: FINDNODE
    end
    end

Loading

concurrent-requests_whoareyou-timeout

A test case where WHOAREYOU packet times out.

testground run single \
  --plan=discv5-testground \
  --testcase=concurrent-requests_whoareyou-timeout \
  --builder=docker:generic \
  --runner=local:docker \
  --instances=2 \
  --wait
sequenceDiagram
    participant Node1
    participant Node2

    Node2 ->> Node1: Random packet
    Node1 ->> Node2: WHOAREYOU
    rect rgb(100, 100, 0)
    Note over Node2: ** Discard the WHOAREYOU packet<br>to reproduce kind of network issue. **
    end

    rect rgb(10, 10, 10)
    Note left of Node1: Node1 want to send FINDNODE to Node2<br>but active_challenge exists.<br>So insert requests into pending_requests.
    par 
    Note over Node1: pending_requests.insert()
    and 
    Note over Node1: pending_requests.insert()
    end
    end

    rect rgb(100, 100, 0)
    Note over Node1: The challenge in active_challenges<br>has been expired.
    end

Loading

concurrent-requests_before-establishing-session

A test case where a node attempts to send requests in parallel before establishing a session.

testground run single \
  --plan=discv5-testground \
  --testcase=concurrent-requests_before-establishing-session \
  --builder=docker:generic \
  --runner=local:docker \
  --instances=2 \
  --wait
sequenceDiagram
    participant Node1
    participant Node2

    Note over Node1: No session with Node2

    rect rgb(10, 10, 10)
    Note left of Node1: Node1 attempts to send multiple requests in parallel <br> but no session with Node2.<br> So Node1 sends a random packet for the first request, <br>and the rest of the requests are inserted into pending_requests.
    par
    Node1 ->> Node2: Random packet (id:1)
    Note over Node1: Insert the request into `active_requests`
    and
    Note over Node1: Insert Request(id:2) into *pending_requests*
    and
    Note over Node1: Insert Request(id:3) into *pending_requests*
    end
    end

    Node2 ->> Node1: WHOAREYOU (id:1)

    Note over Node1: New session established with Node2

    rect rgb(0, 100, 0)
    Note over Node1: Send pending requests since a session has been established.
    Node1 ->> Node2: Request (id:2)
    Node1 ->> Node2: Request (id:3)
    end

    Node1 ->> Node2: Handshake message (id:1)

    Note over Node2: New session established with Node1

    Node2 ->> Node1: Response (id:2)
    Node2 ->> Node1: Response (id:3)
    Node2 ->> Node1: Response (id:1)

    Note over Node1: The request (id:2) completed.
    Note over Node1: The request (id:3) completed.
    Note over Node1: The request (id:1) completed.
Loading

sandbox

testground run single \
  --plan=discv5-testground \
  --testcase=sandbox \
  --builder=docker:generic \
  --runner=local:docker \
  --instances=2 \
  --wait
sequenceDiagram
    participant Node1
    participant Node2

    Note left of Node1: Node1 attempts to send two requests(id:1 and id2)<br> in parallel
    Note right of Node2: Node2 doesn't send responses <br>but only WHOAREYOU

    Node1 ->> Node2: Random packet(id:1)
    Note over Node1: Insert Request(id:2) into `pending_requests`
    Node1 ->> Node1: Request(id:2)

    Node2 -->> Node1: WHOAREYOU(id:1)

    rect rgb(10, 10, 10)
    Note over Node1: New session
    Node1 ->> Node2: Handshake message(id:1)
    Note over Node2: Ignore Handshake message(id:1)
    Note over Node1: Send pending requests
    Node1 ->> Node2: Request(id:2)
    Node2 -->> Node1: WHOAREYOU(id:2)
    end

    rect rgb(10, 10, 10)
    Note over Node1: New session
    Node1 ->> Node2: Handshake message(id:2)
    Note over Node2: Ignore Handshake message(id:2)
    Note over Node1: Replay active requests
    Node1 ->> Node2: Request(id:1)
    Node2 -->> Node1: WHOAREYOU(id:1)
    end 

    rect rgb(10, 10, 10)
    rect rgb(10, 100, 10)
    Note over Node1: Handshake message(id:1) already sent
    Note over Node1: Request(id:1) failed
    Note over Node1: Request(id:2) failed
    end
    end
Loading

@ackintosh ackintosh marked this pull request as ready for review February 16, 2024 06:51
@ackintosh ackintosh merged commit d96207e into main Feb 16, 2024
4 checks passed
@ackintosh ackintosh deleted the concurrent-requests branch February 16, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant