SlideShare a Scribd company logo
1 of 46
Download to read offline
Introduction to Snabbkae
@k32
April 25, 2021
1 / 46
©2021 EMQ Technologies Co., Ltd.
Outline
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
2 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
3 / 46
©2021 EMQ Technologies Co., Ltd.
What is snabbkae
I Snabbkae is a library that allows to test concurrent and distributed
systems
I It does so by moving focus from states to eects
I Developers nd bugs by looking at the logs, snabbkae does the same and
automates the process
I Advanced modes of testing: fault and scheduling injection
I Eciency: run test scenario once, verify multiple properties
4 / 46
©2021 EMQ Technologies Co., Ltd.
Name
I Snabbkaffe means instant coee in Swedish
I There is no hidden meaning, the name was chosen randomly
5 / 46
©2021 EMQ Technologies Co., Ltd.
Nondeterminism
Denitions
I Deterministic functions always produce the same output for the same input
I Nondeterministic functions can produce dierent outputs for the same input
Sources of nondeterminism
I Process schedulings
I Fault-tolerance (failovers)
I Network (packet loss and reordering)
I Load balancing, worker pools
Nondeterminism is an inherent property of concurrent systems
6 / 46
©2021 EMQ Technologies Co., Ltd.
Why change the paradigm of testing?
Diculty levels
1. Easy: Pure functions
2. Normal: Stateful systems
3. Hard: Nondeterministic systems
4. Nightmare: Nondeterministic fault-tolerant distributed systems
Traditional approach
I Traditional approach is sucient for testing pure functions. There are a
variety of excellent tools for this, like PropER
I It can do pretty well with stateful systems (stateful PropER)
I Where it starts to crack: typical Erlang application assembled together
7 / 46
©2021 EMQ Technologies Co., Ltd.
Challenges of testing Erlang applications in situ
Erlang partitions the state of the system between processes
I It eliminates some concurrency bugs and isolates failures
I But it makes the system harder to analyze
I More often than not it's impossible to inspect state of the process
(sys:get_state)
I Often it's useless
I Tests that rely on the state usually need to wait for the system to stabilize,
it can be slow, and they can't analyze the system in motion
I Asynchronous data processing patterns (e.g. job queues) are incredibly
annoying to test using traditional methods
8 / 46
©2021 EMQ Technologies Co., Ltd.
Possible solution to this problem?
Move away from states and embrace events and their temporal relationships
9 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
10 / 46
©2021 EMQ Technologies Co., Ltd.
Tracing macros
1. Replace your regular logs with structured logs (the industry is moving
towards structured logs anyway)
2. Include snabbkaffe/include/trace.hrl header to your module
3. Use ?tp or ?tp_span macros for logging (tp stands for Trace Point)
I In the release build these macros will become regular logger messages
I In the test build these macros will emit trace events
11 / 46
©2021 EMQ Technologies Co., Ltd.
Examples
%% Disappears in the release build:
?tp(rlog_replica_import_trans,
#{ seqno = SeqNo
, txid = TXID
, transaction = Transaction
})
%% Becomes a notice message
?tp(notice, Remote process died,
#{ reason = Reason
, my_state = State
})
%% Emits two events:
?tp_span(trans_write, #{record = Record, txid = get_txid()},
mnesia:write(Record)).
12 / 46
©2021 EMQ Technologies Co., Ltd.
Distributed tracing
Forward traces from the remote node:
%% on the ct_master:
snabbkaffe:forward_trace(Node)
All features (incl. fault and scheduling injections) will work
13 / 46
©2021 EMQ Technologies Co., Ltd.
Why not using erlang tracing?
An often asked question: why not using dbg:tracer or the like?
It was a conscious design choice:
I Traces obtained this way are tightly bound to the structure of the code.
Refactoring the code or adding a new function argument would break the
tests
I Debug traces are excessive, it would be hard to see the forest through the
trees
I Log messages are typically placed in interesting places
I Interesting for humans = interesting for tests
14 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
15 / 46
©2021 EMQ Technologies Co., Ltd.
Stages of the test
Every testcase is split in two stages:
Run stage
where the program runs and emits the event trace
Check stage
where the trace is collected as a list of Erlang maps and validated against the
spec(s)
16 / 46
©2021 EMQ Technologies Co., Ltd.
check_trace macro
my_test() -
?check_trace(begin
%% Run stage:
launch_system(),
do_stuff(),
wait_for_completion(),
get_result()
end,
fun(Result, Trace) -
%% Check stage:
?assertMatch(ok, Result),
check_history(Trace),
check_history2(Trace),
...
end).
17 / 46
©2021 EMQ Technologies Co., Ltd.
Waiting for events
It is possible to block run stage until a certain event occurs:
?block_until(#{ ?snk_kind := message_acked
, message_id := Id
} when Id  42,
Timeout, BackInTime)
This macro will return immediately as soon as the event happens, so it's more
ecient and less prone to akiness than a sleep.
18 / 46
©2021 EMQ Technologies Co., Ltd.
Starting an asynchronous action
?block_until is ne, but it requires timeout tuning. What if the same event
happened in the past?
?wait_async_action( send_async_request(Req)
, #{ ?snk_kind := request_handled
, request := Req
}
[, Timeout]
)
This macro doesn't have to look into the past.
19 / 46
©2021 EMQ Technologies Co., Ltd.
Integrating with PropER
It's not a problem to combine stateless PropER tests with snabbkae.
?check_trace macro can be used inside proper's ?FORALL macro.
Snabbkae provides some convenience macros that simplify
trace-property-based testing:
trace_prop_test(Config) -
Prop = ?forall_trace(
X, list(),
begin
%% Run stage:
do_stuff(X)
end,
fun(Result, Trace) -
%% Check stage
true
end),
?run_prop(Config, Prop).
20 / 46
©2021 EMQ Technologies Co., Ltd.
Misc. macros
There are a few macros that are not directly related to trace-based testing, but
often needed:
?panic
?panic(Unexpected result, #{result = A})
Throw an error
?retry
?retry(_RetryPeriod = 100, _MaxRetries = 10,
some_action_that_can_fail())
Run some code periodically until it succeeds (use as the last resort, when
?block_until won't work)
?give_or_take
?give_or_take(_Expected = 20, _Deviation = 2, Value)
Check that an integer value is within range
21 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
22 / 46
©2021 EMQ Technologies Co., Ltd.
Structure of the trace event
[#{ ?snk_kind = foo
, ?snk_meta = #{ domain = [foo, bar]
, node = 'foo@localhost'
, time = monotonic time
, pid = 0.343.0
, group_leader = 0.67.0
, custom_field1 = baz
, custom_field2 = foobar
}
, field1 = 42
, field2 = foo
},
...
]
23 / 46
©2021 EMQ Technologies Co., Ltd.
Structure of the span trace
[#{ ?snk_kind = foo
, ?snk_meta = #{ ... }
, ?snk_span = start
, field1 = 42
, field2 = foo
},
#{ ?snk_kind = foo
, ?snk_meta = #{ ... }
, ?snk_span = {complete, ReturnValue}
, field1 = 42
, field2 = foo
}
]
24 / 46
©2021 EMQ Technologies Co., Ltd.
Filtering the trace
?of_kind macro
FooEvents = ?of_kind(foo, Trace)
FooOrBarEvents = ?of_kind([foo, bar], Trace)
?of_domain macro
EMQXEvents = ?of_domain([emqx|_], Trace)
?of_node macro
NodeFooEvents = ?of_node('foo@localhost', Trace)
More complex ltering
Of course, lists:filter and list comprehensions work too
25 / 46
©2021 EMQ Technologies Co., Ltd.
Extracting elds
[1, 2] = ?projection(id, ?of_kind(handle_message, Trace))
[{1, hello}, {2, world}] =
?projection( [id, message]
, ?of_kind(handle_message, Trace)
)
26 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
27 / 46
©2021 EMQ Technologies Co., Ltd.
?strict_causality macro
?strict_causality( #{?snk_kind := msg_received, id := _Id}
, #{?snk_kind := msg_processed, id := _Id}
, Trace
)
Return value:
I true if some matching events were found
I false if no events were found
I exception if causality is violated
28 / 46
©2021 EMQ Technologies Co., Ltd.
?strict_causality with guard
Suppose we're testing a base64 server:
?strict_causality( #{req := _Req}
, #{resp := _Resp}
, _Resp =:= base64:encode(_Req)
, Trace
)
29 / 46
©2021 EMQ Technologies Co., Ltd.
?causality macro
Overall, it's the same as ?strict_causality, except it doesn't require each
cause to have an eect
?causality( #{?snk_kind := msg_received, id := _Id}
, #{?snk_kind := msg_processed, id := _Id}
[, Guard]
, Trace
)
30 / 46
©2021 EMQ Technologies Co., Ltd.
Pitfalls
There is a potential problem with causality macros:
1. Format of the event is changed in the code
2. Match expressions in causality stop matching the events
3. Tests still pass, even though they didn't nd any events
Solution:
Always wrap ?causality and ?strict_causality in ?assert, unless there
are legit situations when no events can be produced in the test
31 / 46
©2021 EMQ Technologies Co., Ltd.
?nd_pairs macro
?find_pairs(Strict, MatchCause, MatchEffect [, Guard] , Trace)
1. It returns a list of {pair, Cause, Effect} or {singleton, Cause}
2. When Strict is true this macro also checks that eects don't occur
before causes (much like ?causality)
32 / 46
©2021 EMQ Technologies Co., Ltd.
Splitting traces
Often it is useful to split traces to parts before and after some event (for
example, restart)
There are a variety of macros for this:
split_at
?split_trace_at(bar, [foo, bar, baz, bar]).
{[foo], [bar, baz, bar]}.
splitr
?splitr_trace(foo, [1, 2, foo, 1, 2, foo])
[[1, 2], [foo, 1, 2], [foo]].
splitl
?splitl_trace(foo, [1, 2, foo, 1, 2, foo]).
[[1, 2, foo], [1, 2, foo]].
33 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
34 / 46
©2021 EMQ Technologies Co., Ltd.
Are your supervisors tested?
I Taking fault-tolerance seriously is one of the selling points of Erlang.
Organizing processes in supervisor trees is used widely, but not often tested
I Tuning supervisor trees is an art
I Snabbkae wants to turn it into a chore
I It does so by injecting deliberate faults into the system
35 / 46
©2021 EMQ Technologies Co., Ltd.
Fault injection
Any tracepoint can be used to inject errors into the system
?inject_crash( #{?snk_meta := #{domain := [ekka, rlog|_]}}
, snabbkaffe_nemesis:random_crash(0.1)
)
I First argument: event matching expression
I Second argument: fault scenario
36 / 46
©2021 EMQ Technologies Co., Ltd.
Fault scenarios
Always crash:
?inject_crash(..., snabbkaffe_nemesis:always_crash())
Crash N times:
?inject_crash(..., snabbkaffe_nemesis:recover_after(10))
Crash randomly with probability P:
?inject_crash(..., snabbkaffe_nemesis:random_crash(0.1))
Crash periodically:
snabbkaffe_nemesis:periodic_crash(
_Period = 10, _DutyCycle = 0.5, _Phase = math:pi())
37 / 46
©2021 EMQ Technologies Co., Ltd.
Manipulating process schedulings
I Sometimes it is necessary to test a certain process scheduling
I Imagine working on a bugx using TDD-style
I For example, normally eect foo occurs after eect bar, and everything
works. But in rare cases the opposite happens, and the bug occurs
I Snabbkae can manipulate process schedulings to some extend:
%% run stage...
?force_ordering(#{?snk_kind := bar}, #{?snk_kind := foo})
(It also supports guards)
38 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
39 / 46
©2021 EMQ Technologies Co., Ltd.
Disclaimer
I This usecase is a secondary, and quite rudimentary. Don't expect much
I It lacks many features of proper benchmarking libraries, such as
I Warmup
I Advanced statistical analysis, e.g. outlier detection
40 / 46
©2021 EMQ Technologies Co., Ltd.
Reporting metrics
%% Report a single scalar datapoint:
snabbkaffe:push_stat(scalar_metric_name, Value),
%% Report a single datapoint with X coord:
snabbkaffe:push_stat(metric_name, X, Value),
%% Report multiple scalar datapoints:
snabbkaffe:push_stats(metric_name, [Val1, Val2, ...]),
%% Report multiple datapoints with X coord:
snabbkaffe:push_stats(metric_name, X, [Val1, Val2, ...])
41 / 46
©2021 EMQ Technologies Co., Ltd.
Using spans to analyze performance
push_stats function also works together with ?find_pairs macro:
Pairs = ?find_pairs( #{ ?snk_span := start
, ?snk_kind := foo
, pid := _Pid
}
, #{ ?snk_span := {complete, _}
, ?snk_kind := foo
, pid := _Pid
}
),
snabbkaffe:push_stats(metric_name, [X,] Pairs)
42 / 46
©2021 EMQ Technologies Co., Ltd.
Analyzing the results
Use the following function in the end of check stage:
snabbkaffe:analyze_statistics()
It will print the results in the console:
Mean scalar_metric_name: 10.0
Statisitics of metric_name
100.479087 ^ *
| *
| *
|
| *
| *
0 +----------------------------------------
0 1100
43 / 46
©2021 EMQ Technologies Co., Ltd.
Topic
Background and motivation
Instrumenting the code
Testing
Basic functions for working with traces
Event correlations
Nemesis
Using snabbkae as a benchmark library
Conclusion
44 / 46
©2021 EMQ Technologies Co., Ltd.
Useful links
https://github.com/kafka4beam/snabbkaffe
The library is being actively developed.
Suggestions, bug reports and patches are welcome!
Snabbkae in action
Feel free to use as an example (clickable links):
I brod
I kow
I ekka
I EMQ X
45 / 46
©2021 EMQ Technologies Co., Ltd.
Questions?
46 / 46
©2021 EMQ Technologies Co., Ltd.

More Related Content

What's hot

Automated Program Repair Keynote talk
Automated Program Repair Keynote talkAutomated Program Repair Keynote talk
Automated Program Repair Keynote talkAbhik Roychoudhury
 
Secure application programming in the presence of side channel attacks
Secure application programming in the presence of side channel attacksSecure application programming in the presence of side channel attacks
Secure application programming in the presence of side channel attacksDharmalingam Ganesan
 
Session 6 sv_randomization
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomizationNirav Desai
 
Test Automation Maturity: A Self-Assessment Tool
Test Automation Maturity: A Self-Assessment ToolTest Automation Maturity: A Self-Assessment Tool
Test Automation Maturity: A Self-Assessment ToolUniversity of Antwerp
 
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...VLSICS Design
 
Online Workflow Management and Performance Analysis with Stampede
Online Workflow Management and Performance Analysis with StampedeOnline Workflow Management and Performance Analysis with Stampede
Online Workflow Management and Performance Analysis with StampedeDan Gunter
 
implementation of area efficient high speed eddr architecture
implementation of area efficient high speed eddr architectureimplementation of area efficient high speed eddr architecture
implementation of area efficient high speed eddr architectureKumar Goud
 
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...Eswar Publications
 
Automated Vulnerability Testing Using Machine Learning and Metaheuristic Search
Automated Vulnerability Testing Using Machine Learning and Metaheuristic SearchAutomated Vulnerability Testing Using Machine Learning and Metaheuristic Search
Automated Vulnerability Testing Using Machine Learning and Metaheuristic SearchLionel Briand
 
SAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeSAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeAndrey Karpov
 
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)Sung Kim
 
Search-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability DetectionSearch-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability DetectionLionel Briand
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...acijjournal
 
Adaptive fault tolerance in real time cloud_computing
Adaptive fault tolerance in real time cloud_computingAdaptive fault tolerance in real time cloud_computing
Adaptive fault tolerance in real time cloud_computingwww.pixelsolutionbd.com
 
Multi-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect PredictionMulti-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect PredictionSebastiano Panichella
 
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...VLSICS Design
 

What's hot (19)

Bt34433436
Bt34433436Bt34433436
Bt34433436
 
Automated Program Repair Keynote talk
Automated Program Repair Keynote talkAutomated Program Repair Keynote talk
Automated Program Repair Keynote talk
 
Secure application programming in the presence of side channel attacks
Secure application programming in the presence of side channel attacksSecure application programming in the presence of side channel attacks
Secure application programming in the presence of side channel attacks
 
Session 6 sv_randomization
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomization
 
Test Automation Maturity: A Self-Assessment Tool
Test Automation Maturity: A Self-Assessment ToolTest Automation Maturity: A Self-Assessment Tool
Test Automation Maturity: A Self-Assessment Tool
 
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...
COVERAGE DRIVEN FUNCTIONAL TESTING ARCHITECTURE FOR PROTOTYPING SYSTEM USING ...
 
Online Workflow Management and Performance Analysis with Stampede
Online Workflow Management and Performance Analysis with StampedeOnline Workflow Management and Performance Analysis with Stampede
Online Workflow Management and Performance Analysis with Stampede
 
Maestro_Abstract
Maestro_AbstractMaestro_Abstract
Maestro_Abstract
 
implementation of area efficient high speed eddr architecture
implementation of area efficient high speed eddr architectureimplementation of area efficient high speed eddr architecture
implementation of area efficient high speed eddr architecture
 
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...
Robust Fault-Tolerant Training Strategy Using Neural Network to Perform Funct...
 
Automated Vulnerability Testing Using Machine Learning and Metaheuristic Search
Automated Vulnerability Testing Using Machine Learning and Metaheuristic SearchAutomated Vulnerability Testing Using Machine Learning and Metaheuristic Search
Automated Vulnerability Testing Using Machine Learning and Metaheuristic Search
 
SAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeSAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the code
 
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
 
Mobilesoft 2017 Keynote
Mobilesoft 2017 KeynoteMobilesoft 2017 Keynote
Mobilesoft 2017 Keynote
 
Search-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability DetectionSearch-driven String Constraint Solving for Vulnerability Detection
Search-driven String Constraint Solving for Vulnerability Detection
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
 
Adaptive fault tolerance in real time cloud_computing
Adaptive fault tolerance in real time cloud_computingAdaptive fault tolerance in real time cloud_computing
Adaptive fault tolerance in real time cloud_computing
 
Multi-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect PredictionMulti-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect Prediction
 
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...
IMPLEMENTATION OF COMPACTION ALGORITHM FOR ATPG GENERATED PARTIALLY SPECIFIED...
 

Similar to Introduction to Snabbkaffe

Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
System verilog important
System verilog importantSystem verilog important
System verilog importantelumalai7
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis Engineering Software Lab
 
Concurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and GotchasConcurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and Gotchasamccullo
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017XavierDevroey
 
20090918 Agile Computer Control of a Complex Experiment
20090918 Agile Computer Control of a Complex Experiment20090918 Agile Computer Control of a Complex Experiment
20090918 Agile Computer Control of a Complex ExperimentJonathan Blakes
 
Tempest scenariotests 20140512
Tempest scenariotests 20140512Tempest scenariotests 20140512
Tempest scenariotests 20140512Masayuki Igawa
 
Automock: Interaction-Based Mock Code Generation
Automock: Interaction-Based Mock Code GenerationAutomock: Interaction-Based Mock Code Generation
Automock: Interaction-Based Mock Code GenerationSabrina Souto
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Cωνσtantίnoς Giannoulis
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShareyayao
 
Software Testing Tecniques
Software Testing TecniquesSoftware Testing Tecniques
Software Testing Tecniquesersanbilik
 
"Quantum" Performance Effects
"Quantum" Performance Effects"Quantum" Performance Effects
"Quantum" Performance EffectsSergey Kuksenko
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdfamitbhachne
 

Similar to Introduction to Snabbkaffe (20)

Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
Concurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and GotchasConcurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and Gotchas
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
20090918 Agile Computer Control of a Complex Experiment
20090918 Agile Computer Control of a Complex Experiment20090918 Agile Computer Control of a Complex Experiment
20090918 Agile Computer Control of a Complex Experiment
 
43
4343
43
 
Tempest scenariotests 20140512
Tempest scenariotests 20140512Tempest scenariotests 20140512
Tempest scenariotests 20140512
 
Automock: Interaction-Based Mock Code Generation
Automock: Interaction-Based Mock Code GenerationAutomock: Interaction-Based Mock Code Generation
Automock: Interaction-Based Mock Code Generation
 
PID2143641
PID2143641PID2143641
PID2143641
 
Unit test
Unit testUnit test
Unit test
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShare
 
Software Testing Tecniques
Software Testing TecniquesSoftware Testing Tecniques
Software Testing Tecniques
 
"Quantum" Performance Effects
"Quantum" Performance Effects"Quantum" Performance Effects
"Quantum" Performance Effects
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf
 
Java ug
Java ugJava ug
Java ug
 
Symbolic Execution And KLEE
Symbolic Execution And KLEESymbolic Execution And KLEE
Symbolic Execution And KLEE
 

More from EMQ

An Introduction to Hamler
An Introduction to HamlerAn Introduction to Hamler
An Introduction to HamlerEMQ
 
Introduction to MQTT
Introduction to MQTTIntroduction to MQTT
Introduction to MQTTEMQ
 
Introduction to EMQ X Enterprise
Introduction to EMQ X EnterpriseIntroduction to EMQ X Enterprise
Introduction to EMQ X EnterpriseEMQ
 
Introduction to EMQ
Introduction to EMQIntroduction to EMQ
Introduction to EMQEMQ
 
Introduction to CoAP
Introduction to CoAPIntroduction to CoAP
Introduction to CoAPEMQ
 
EMQ Company Deck
EMQ Company DeckEMQ Company Deck
EMQ Company DeckEMQ
 

More from EMQ (6)

An Introduction to Hamler
An Introduction to HamlerAn Introduction to Hamler
An Introduction to Hamler
 
Introduction to MQTT
Introduction to MQTTIntroduction to MQTT
Introduction to MQTT
 
Introduction to EMQ X Enterprise
Introduction to EMQ X EnterpriseIntroduction to EMQ X Enterprise
Introduction to EMQ X Enterprise
 
Introduction to EMQ
Introduction to EMQIntroduction to EMQ
Introduction to EMQ
 
Introduction to CoAP
Introduction to CoAPIntroduction to CoAP
Introduction to CoAP
 
EMQ Company Deck
EMQ Company DeckEMQ Company Deck
EMQ Company Deck
 

Recently uploaded

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 

Recently uploaded (20)

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 

Introduction to Snabbkaffe

  • 1. Introduction to Snabbkae @k32 April 25, 2021 1 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 2. Outline Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 2 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 3. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 3 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 4. What is snabbkae I Snabbkae is a library that allows to test concurrent and distributed systems I It does so by moving focus from states to eects I Developers nd bugs by looking at the logs, snabbkae does the same and automates the process I Advanced modes of testing: fault and scheduling injection I Eciency: run test scenario once, verify multiple properties 4 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 5. Name I Snabbkaffe means instant coee in Swedish I There is no hidden meaning, the name was chosen randomly 5 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 6. Nondeterminism Denitions I Deterministic functions always produce the same output for the same input I Nondeterministic functions can produce dierent outputs for the same input Sources of nondeterminism I Process schedulings I Fault-tolerance (failovers) I Network (packet loss and reordering) I Load balancing, worker pools Nondeterminism is an inherent property of concurrent systems 6 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 7. Why change the paradigm of testing? Diculty levels 1. Easy: Pure functions 2. Normal: Stateful systems 3. Hard: Nondeterministic systems 4. Nightmare: Nondeterministic fault-tolerant distributed systems Traditional approach I Traditional approach is sucient for testing pure functions. There are a variety of excellent tools for this, like PropER I It can do pretty well with stateful systems (stateful PropER) I Where it starts to crack: typical Erlang application assembled together 7 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 8. Challenges of testing Erlang applications in situ Erlang partitions the state of the system between processes I It eliminates some concurrency bugs and isolates failures I But it makes the system harder to analyze I More often than not it's impossible to inspect state of the process (sys:get_state) I Often it's useless I Tests that rely on the state usually need to wait for the system to stabilize, it can be slow, and they can't analyze the system in motion I Asynchronous data processing patterns (e.g. job queues) are incredibly annoying to test using traditional methods 8 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 9. Possible solution to this problem? Move away from states and embrace events and their temporal relationships 9 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 10. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 10 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 11. Tracing macros 1. Replace your regular logs with structured logs (the industry is moving towards structured logs anyway) 2. Include snabbkaffe/include/trace.hrl header to your module 3. Use ?tp or ?tp_span macros for logging (tp stands for Trace Point) I In the release build these macros will become regular logger messages I In the test build these macros will emit trace events 11 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 12. Examples %% Disappears in the release build: ?tp(rlog_replica_import_trans, #{ seqno = SeqNo , txid = TXID , transaction = Transaction }) %% Becomes a notice message ?tp(notice, Remote process died, #{ reason = Reason , my_state = State }) %% Emits two events: ?tp_span(trans_write, #{record = Record, txid = get_txid()}, mnesia:write(Record)). 12 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 13. Distributed tracing Forward traces from the remote node: %% on the ct_master: snabbkaffe:forward_trace(Node) All features (incl. fault and scheduling injections) will work 13 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 14. Why not using erlang tracing? An often asked question: why not using dbg:tracer or the like? It was a conscious design choice: I Traces obtained this way are tightly bound to the structure of the code. Refactoring the code or adding a new function argument would break the tests I Debug traces are excessive, it would be hard to see the forest through the trees I Log messages are typically placed in interesting places I Interesting for humans = interesting for tests 14 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 15. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 15 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 16. Stages of the test Every testcase is split in two stages: Run stage where the program runs and emits the event trace Check stage where the trace is collected as a list of Erlang maps and validated against the spec(s) 16 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 17. check_trace macro my_test() - ?check_trace(begin %% Run stage: launch_system(), do_stuff(), wait_for_completion(), get_result() end, fun(Result, Trace) - %% Check stage: ?assertMatch(ok, Result), check_history(Trace), check_history2(Trace), ... end). 17 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 18. Waiting for events It is possible to block run stage until a certain event occurs: ?block_until(#{ ?snk_kind := message_acked , message_id := Id } when Id 42, Timeout, BackInTime) This macro will return immediately as soon as the event happens, so it's more ecient and less prone to akiness than a sleep. 18 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 19. Starting an asynchronous action ?block_until is ne, but it requires timeout tuning. What if the same event happened in the past? ?wait_async_action( send_async_request(Req) , #{ ?snk_kind := request_handled , request := Req } [, Timeout] ) This macro doesn't have to look into the past. 19 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 20. Integrating with PropER It's not a problem to combine stateless PropER tests with snabbkae. ?check_trace macro can be used inside proper's ?FORALL macro. Snabbkae provides some convenience macros that simplify trace-property-based testing: trace_prop_test(Config) - Prop = ?forall_trace( X, list(), begin %% Run stage: do_stuff(X) end, fun(Result, Trace) - %% Check stage true end), ?run_prop(Config, Prop). 20 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 21. Misc. macros There are a few macros that are not directly related to trace-based testing, but often needed: ?panic ?panic(Unexpected result, #{result = A}) Throw an error ?retry ?retry(_RetryPeriod = 100, _MaxRetries = 10, some_action_that_can_fail()) Run some code periodically until it succeeds (use as the last resort, when ?block_until won't work) ?give_or_take ?give_or_take(_Expected = 20, _Deviation = 2, Value) Check that an integer value is within range 21 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 22. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 22 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 23. Structure of the trace event [#{ ?snk_kind = foo , ?snk_meta = #{ domain = [foo, bar] , node = 'foo@localhost' , time = monotonic time , pid = 0.343.0 , group_leader = 0.67.0 , custom_field1 = baz , custom_field2 = foobar } , field1 = 42 , field2 = foo }, ... ] 23 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 24. Structure of the span trace [#{ ?snk_kind = foo , ?snk_meta = #{ ... } , ?snk_span = start , field1 = 42 , field2 = foo }, #{ ?snk_kind = foo , ?snk_meta = #{ ... } , ?snk_span = {complete, ReturnValue} , field1 = 42 , field2 = foo } ] 24 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 25. Filtering the trace ?of_kind macro FooEvents = ?of_kind(foo, Trace) FooOrBarEvents = ?of_kind([foo, bar], Trace) ?of_domain macro EMQXEvents = ?of_domain([emqx|_], Trace) ?of_node macro NodeFooEvents = ?of_node('foo@localhost', Trace) More complex ltering Of course, lists:filter and list comprehensions work too 25 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 26. Extracting elds [1, 2] = ?projection(id, ?of_kind(handle_message, Trace)) [{1, hello}, {2, world}] = ?projection( [id, message] , ?of_kind(handle_message, Trace) ) 26 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 27. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 27 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 28. ?strict_causality macro ?strict_causality( #{?snk_kind := msg_received, id := _Id} , #{?snk_kind := msg_processed, id := _Id} , Trace ) Return value: I true if some matching events were found I false if no events were found I exception if causality is violated 28 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 29. ?strict_causality with guard Suppose we're testing a base64 server: ?strict_causality( #{req := _Req} , #{resp := _Resp} , _Resp =:= base64:encode(_Req) , Trace ) 29 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 30. ?causality macro Overall, it's the same as ?strict_causality, except it doesn't require each cause to have an eect ?causality( #{?snk_kind := msg_received, id := _Id} , #{?snk_kind := msg_processed, id := _Id} [, Guard] , Trace ) 30 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 31. Pitfalls There is a potential problem with causality macros: 1. Format of the event is changed in the code 2. Match expressions in causality stop matching the events 3. Tests still pass, even though they didn't nd any events Solution: Always wrap ?causality and ?strict_causality in ?assert, unless there are legit situations when no events can be produced in the test 31 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 32. ?nd_pairs macro ?find_pairs(Strict, MatchCause, MatchEffect [, Guard] , Trace) 1. It returns a list of {pair, Cause, Effect} or {singleton, Cause} 2. When Strict is true this macro also checks that eects don't occur before causes (much like ?causality) 32 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 33. Splitting traces Often it is useful to split traces to parts before and after some event (for example, restart) There are a variety of macros for this: split_at ?split_trace_at(bar, [foo, bar, baz, bar]). {[foo], [bar, baz, bar]}. splitr ?splitr_trace(foo, [1, 2, foo, 1, 2, foo]) [[1, 2], [foo, 1, 2], [foo]]. splitl ?splitl_trace(foo, [1, 2, foo, 1, 2, foo]). [[1, 2, foo], [1, 2, foo]]. 33 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 34. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 34 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 35. Are your supervisors tested? I Taking fault-tolerance seriously is one of the selling points of Erlang. Organizing processes in supervisor trees is used widely, but not often tested I Tuning supervisor trees is an art I Snabbkae wants to turn it into a chore I It does so by injecting deliberate faults into the system 35 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 36. Fault injection Any tracepoint can be used to inject errors into the system ?inject_crash( #{?snk_meta := #{domain := [ekka, rlog|_]}} , snabbkaffe_nemesis:random_crash(0.1) ) I First argument: event matching expression I Second argument: fault scenario 36 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 37. Fault scenarios Always crash: ?inject_crash(..., snabbkaffe_nemesis:always_crash()) Crash N times: ?inject_crash(..., snabbkaffe_nemesis:recover_after(10)) Crash randomly with probability P: ?inject_crash(..., snabbkaffe_nemesis:random_crash(0.1)) Crash periodically: snabbkaffe_nemesis:periodic_crash( _Period = 10, _DutyCycle = 0.5, _Phase = math:pi()) 37 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 38. Manipulating process schedulings I Sometimes it is necessary to test a certain process scheduling I Imagine working on a bugx using TDD-style I For example, normally eect foo occurs after eect bar, and everything works. But in rare cases the opposite happens, and the bug occurs I Snabbkae can manipulate process schedulings to some extend: %% run stage... ?force_ordering(#{?snk_kind := bar}, #{?snk_kind := foo}) (It also supports guards) 38 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 39. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 39 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 40. Disclaimer I This usecase is a secondary, and quite rudimentary. Don't expect much I It lacks many features of proper benchmarking libraries, such as I Warmup I Advanced statistical analysis, e.g. outlier detection 40 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 41. Reporting metrics %% Report a single scalar datapoint: snabbkaffe:push_stat(scalar_metric_name, Value), %% Report a single datapoint with X coord: snabbkaffe:push_stat(metric_name, X, Value), %% Report multiple scalar datapoints: snabbkaffe:push_stats(metric_name, [Val1, Val2, ...]), %% Report multiple datapoints with X coord: snabbkaffe:push_stats(metric_name, X, [Val1, Val2, ...]) 41 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 42. Using spans to analyze performance push_stats function also works together with ?find_pairs macro: Pairs = ?find_pairs( #{ ?snk_span := start , ?snk_kind := foo , pid := _Pid } , #{ ?snk_span := {complete, _} , ?snk_kind := foo , pid := _Pid } ), snabbkaffe:push_stats(metric_name, [X,] Pairs) 42 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 43. Analyzing the results Use the following function in the end of check stage: snabbkaffe:analyze_statistics() It will print the results in the console: Mean scalar_metric_name: 10.0 Statisitics of metric_name 100.479087 ^ * | * | * | | * | * 0 +---------------------------------------- 0 1100 43 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 44. Topic Background and motivation Instrumenting the code Testing Basic functions for working with traces Event correlations Nemesis Using snabbkae as a benchmark library Conclusion 44 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 45. Useful links https://github.com/kafka4beam/snabbkaffe The library is being actively developed. Suggestions, bug reports and patches are welcome! Snabbkae in action Feel free to use as an example (clickable links): I brod I kow I ekka I EMQ X 45 / 46 ©2021 EMQ Technologies Co., Ltd.
  • 46. Questions? 46 / 46 ©2021 EMQ Technologies Co., Ltd.