-
-
Notifications
You must be signed in to change notification settings - Fork 243
Description
Background: #229
I've pushed a few changes that make the chain
struct thread-safe:
This automatically makes many structs thread-safe too: Expect, Value, Array, Object, etc. It's true for matcher structs which contains only a chain + immutable data.
The next step is to manually implement thread-safety for the following structs:
- Environment
- Request
- Websocket
These three structs has mutable state and should be protected manually. For each of them, we should add sync.RWMutex field and protect all operations. We can remove noCopy fields from these structs.
Request struct needs special care: it contains transforms
and matchers
callbacks that are invoked during Expect() call. We should NOT call them under a lock because otherwise it would be easy to write code with deadlocks (if you use the same request from this callbacks).
Websocket also needs some special handling. It should allow to read and write messages concurrently and to call disconnect concurrently (similarly as gorilla websocket which it uses under the hood).
After finishing this, we should update docs:
- add thread-safety section to package documentation, mention limitation placed by httpexpect, testify, and standard testing
- add note to README
In addition, we should improve our testing suite:
- add
make race
target which runs all tests under race detector - add corresponding step to CI
- create issue for implementing stress test