0
0
Microservicessystem_design~10 mins

Chaos engineering basics in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the main goal of chaos engineering.

Microservices
chaos_engineering_goal = "[1]"
Drag options to blanks, or click blank then click option'
Ato avoid any system testing
Bto increase system downtime intentionally
Cto improve system resilience by testing failures
Dto reduce system monitoring
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing chaos engineering with causing system downtime.
Thinking chaos engineering avoids testing.
2fill in blank
medium

Complete the code to identify a common tool used in chaos engineering for microservices.

Microservices
common_chaos_tool = "[1]"
Drag options to blanks, or click blank then click option'
AChaos Monkey
BKubernetes
CDocker
DPrometheus
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing Kubernetes or Docker which are container tools, not chaos tools.
Selecting Prometheus which is a monitoring tool.
3fill in blank
hard

Fix the error in the code that simulates a failure injection in a microservice.

Microservices
def inject_failure(service):
    if service.status == 'healthy':
        service.status = '[1]'
    return service.status
Drag options to blanks, or click blank then click option'
Afailed
Brunning
Cstarting
Didle
Attempts:
3 left
💡 Hint
Common Mistakes
Setting status to 'running' or 'starting' which means the service is healthy.
Using 'idle' which does not indicate failure.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps microservice names to their failure status if they are unhealthy.

Microservices
failure_map = {service.name: service.status for service in services if service.status [1] '[2]'}
Drag options to blanks, or click blank then click option'
A!=
B==
Cfailed
Dhealthy
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' with 'healthy' which selects healthy services instead of failures.
Using '!=' with 'failed' which would select healthy services.
5fill in blank
hard

Fill all three blanks to create a function that triggers chaos experiments only if the system is stable and the experiment is approved.

Microservices
def trigger_chaos(system_status, experiment_approved):
    if system_status [1] 'stable' and experiment_approved [2] True:
        return '[3]'
    else:
        return 'Do not run experiment'
Drag options to blanks, or click blank then click option'
A==
B!=
CRun experiment
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which would invert the logic.
Returning 'False' or other strings instead of 'Run experiment'.