testSpec "testing lists" $describe "Prelude.head" $ do it "returns the first element of a list" $ do head [23 ..]
shouldBe` (23 :: Int)
it "throws an exception if the list is empty" $
head [] `shouldThrow` anyException
// This describe a more or less ideal API for global resources management | |
// This trait allows to insert setup/teardown actions guaranteed to execute only once | |
// and making sure that the teardown action will always happen at the end of the | |
// specification execution | |
trait GlobalBeforeAfter extends SpecificationStructure with FragmentsFactory { | |
def globalBefore: Fragment | |
def globalAfter: Fragment | |
override def map(fs: =>Fragments): Fragments = super.map(fs).prepend( |
import qualified System.Console.Concurrent as Concurrent | |
trace :: [Char] -> a -> a | |
trace string expr = | |
unsafePerformIO $ do | |
traceIO string | |
return expr | |
traceIO :: [Char] -> IO () | |
traceIO string = do |
# for example | |
TAG=dade6249f8206e13150f464ad2b0df4cc1a07bd5 | |
for i in 'sailfish' 'smartlog' 'epilog' 'apollo' 'api-server' 'txe' 'txe-postgres' 'api-server'; do docker pull us.gcr.io/development-148212/$i:$TAG; done |
# find all txe log files from pod logs and copy them locally with an incrementing number | |
# 0.log, 1.log, 2.log, 3.log | |
# this uses: | |
# - https://github.com/sharkdp/fd (fast alternative to find) | |
# - https://github.com/BurntSushi/ripgrep (fast alternative to rg) | |
fd 0.log | rg txe | cat -n | while read n f; do cp -n "$f" "$n.log"; done | |
# extract the 'message' field from each log file and write it to txe-1.log, | |
# txe-2.log, txe-3.log, txe-4.log | |
for i in 1 2 3 4; do cat ~/Downloads/symbiont/logs/$i.log | jq '.log | fromjson | .message' > txe-$i.log; done |
# remove publish payloads for versions 1-5 | |
for i in {1..5}; do cat $i.json | jq -c '.channelActionAndSequencedTransaction |= map(select(.[1].contents[4].tag != "Publish"))' | jq --indent 4 . > $i-x.json; rm $i.json; mv $i-x.json $i.json; done | |
# remove publish payloads for version 6 | |
for i in {6..6}; do cat $i.json | jq -c '.channelActionAndSequencedTransaction |= map(select(.[2][4].tag != "Publish"))' | jq --indent 4 . > $i-x.json; rm $i.json; mv $i-x.json $i.json; done | |
# remove publish payloads for versions 7-8 | |
for i in {7..8}; do cat $i.json | jq -c '.channelActionAndSequencedTransaction |= map(select(.[2].wcaChannelAction.tag? != "Publish"))' | jq --indent 4 . > $i-x.json; done |
DROP DATABASE IF EXISTS state_db; | |
DROP ROLE IF EXISTS datadog; | |
DROP ROLE IF EXISTS txe; | |
DROP ROLE IF EXISTS sailfish; | |
DROP ROLE IF EXISTS api_server; | |
CREATE DATABASE state_db; |
testCase "Example test case" $ do | |
assertBool "arithmetic is still sane" $ 2 + 2 == 4 |
module ConcurrentMap where | |
import Control.Concurrent.STM.TVar (TVar) | |
import Control.Concurrent.STM (STM) | |
import Data.Hashable (Hashable) | |
import Data.HashMap.Strict (HashMap) | |
import Data.Vector (Vector) | |
import qualified Control.Concurrent.STM.TVar as TVar | |
import qualified Data.Hashable as Hashable |