Bird
0
0

Consider this migration plan code snippet:

medium📝 Analysis Q13 of 15
Microservices - Migration from Monolith
Consider this migration plan code snippet:
services = ['auth', 'payment', 'order']
migrated = []
for s in services:
    migrate_service(s)
    migrated.append(s)
    if not test_service(s):
        rollback_service(s)
        break
print(migrated)

What will be the output if test_service('payment') returns False?
A['auth', 'payment']
B['auth', 'payment', 'order']
C[]
D['auth']
Step-by-Step Solution
Solution:
  1. Step 1: Trace migration and testing

    'auth' migrates, appends to migrated, tests OK. 'payment' migrates and appends to migrated.
  2. Step 2: Rollback and break loop

    On test failure for 'payment', rollback happens but 'payment' was already appended, then loop breaks.
  3. Final Answer:

    ['auth', 'payment'] -> Option A
  4. Quick Check:

    Appends before test, so includes failed service [OK]
Quick Trick: Stop migration on test failure, rollback last service [OK]
Common Mistakes:
  • Thinking failed service is not added to migrated list
  • Ignoring append before test
  • Continuing migration after failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes