version: 1
style: unit
description: must issue Connections to threads in the order that the threads entered the queue
poolOptions:
  maxPoolSize: 1
  waitQueueTimeoutMS: 1000
operations:
    # Check out sole connection in pool
  - name: checkOut
    label: conn0
    # Create 4 threads, have them all queue up for connections
    # Note: this might become non-deterministic depending on how you
    # implement your test runner. The goal is for each thread to
    # have started and begun checkOut before the next thread starts.
    # The sleep operations should make this more consistent.
  - name: start
    target: thread1
  - name: checkOut
    thread: thread1
    label: conn1
  - name: waitForEvent
    event: ConnectionCheckOutStarted
    count: 2
  - name: start
    target: thread2
  - name: checkOut
    thread: thread2
    label: conn2
  - name: waitForEvent
    event: ConnectionCheckOutStarted
    count: 3
  - name: start
    target: thread3
  - name: checkOut
    thread: thread3
    label: conn3
  - name: waitForEvent
    event: ConnectionCheckOutStarted
    count: 4
  - name: start
    target: thread4
  - name: checkOut
    thread: thread4
    label: conn4
  - name: waitForEvent
    event: ConnectionCheckOutStarted
    count: 5
    # From main thread, keep checking in connection and then wait for appropriate thread
    # Test will timeout if threads are not enqueued in proper order
  - name: checkIn
    connection: conn0
  - name: waitForThread
    target: thread1
  - name: checkIn
    connection: conn1
  - name: waitForThread
    target: thread2
  - name: checkIn
    connection: conn2
  - name: waitForThread
    target: thread3
  - name: checkIn
    connection: conn3
  - name: waitForThread
    target: thread4
events:
  - type: ConnectionCheckOutStarted
  - type: ConnectionCheckedOut
    connectionId: 42
  - type: ConnectionCheckOutStarted
  - type: ConnectionCheckOutStarted
  - type: ConnectionCheckOutStarted
  - type: ConnectionCheckOutStarted
  - type: ConnectionCheckedIn
    connectionId: 42
  - type: ConnectionCheckedOut
    connectionId: 42
  - type: ConnectionCheckedIn
    connectionId: 42
  - type: ConnectionCheckedOut
    connectionId: 42
  - type: ConnectionCheckedIn
    connectionId: 42
  - type: ConnectionCheckedOut
    connectionId: 42
  - type: ConnectionCheckedIn
    connectionId: 42
  - type: ConnectionCheckedOut
    connectionId: 42
ignore:
  - ConnectionCreated
  - ConnectionReady
  - ConnectionClosed
  - ConnectionPoolCreated
