From 547934c1015bd378c1424cbaf52edf4e3ae84867 Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Wed, 2 Feb 2022 14:09:04 +0100 Subject: [PATCH] docs(course): add preliminary table of content --- doc/advanced-testing-mini-course/README.md | 51 ++++++++++++++++++++++ doc/demo-journal/slides-journal.md | 4 ++ 2 files changed, 55 insertions(+) create mode 100644 doc/advanced-testing-mini-course/README.md diff --git a/doc/advanced-testing-mini-course/README.md b/doc/advanced-testing-mini-course/README.md new file mode 100644 index 00000000..fd63dca9 --- /dev/null +++ b/doc/advanced-testing-mini-course/README.md @@ -0,0 +1,51 @@ +## Advanced property-based testing mini-course + +### Table of content + +0. Assume familiarity with Haskell and QuickCheck +1. State machine testing + - Coverage + - Metrics + - References? +2. Consumer-driven contract tests using state machines +3. Concurrent state machine testing with linearisability +4. Fault-injection +5. Simulation testing + +### Simulation testing + +```haskell +data Network = Network + { deploy :: Addr -> IO Server -- bind and listen + , connect :: Addr -> IO Client + , send :: [(Client, Msg)] -> IO () + , select :: [Server] -> IO (Addr, Msg, Time) -- accept and recv + } + +eventLoop :: Network -> [(Addr, StateMachine)] -> IO () +eventLoop nw nodes = do + servers <- mapM (deploy nw) (map fst nodes) + let env = nodes `zip` initialStates + go env + where + go env = do + (receiver, msg, time) <- select servers + (outgoing, env') <- step env receiver msg time + send nw outgoing + go env' + +fakeSend :: Heap -> Addr -> Msg -> (Heap, ()) +fakeSend heap addr msg = do + t <- genArrivalTime + (enqueue (addr, msg, t) heap, ()) + +newFakeNetwork :: IO Network +newFakeNetwork = do + heap <- newIORef emptyHeap + let send = do + h <- readIORef heap + let (h', ()) = fakeSend h + writeIORef heap h' + ... + return Network {..} +``` diff --git a/doc/demo-journal/slides-journal.md b/doc/demo-journal/slides-journal.md index 984342b2..952b58fc 100644 --- a/doc/demo-journal/slides-journal.md +++ b/doc/demo-journal/slides-journal.md @@ -115,6 +115,10 @@ nocite: | * Counters * Histograms +# Design of the event loop + +* TODO + # Demo * The first version uses SQLite to persist the application log, all reads and